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
|
---|---|---|---|---|---|---|---|---|---|---|
playn/playn | core/src/playn/core/Keyboard.java | Keyboard.isKey | public static KeyEvent isKey (Key key, Event event) {
"""
A collector function for key events for {@code key}. Use it to obtain only events for a
particular key like so:
<pre>{@code
Input.keyboardEvents.collect(ev -> Keyboard.isKey(Key.X, ev)).connect(event -> {
// handle the 'x' key being pressed or released
});
}</pre>
"""
if (event instanceof KeyEvent && ((KeyEvent)event).key == key) {
return (KeyEvent)event;
} else {
return null;
}
} | java | public static KeyEvent isKey (Key key, Event event) {
if (event instanceof KeyEvent && ((KeyEvent)event).key == key) {
return (KeyEvent)event;
} else {
return null;
}
} | [
"public",
"static",
"KeyEvent",
"isKey",
"(",
"Key",
"key",
",",
"Event",
"event",
")",
"{",
"if",
"(",
"event",
"instanceof",
"KeyEvent",
"&&",
"(",
"(",
"KeyEvent",
")",
"event",
")",
".",
"key",
"==",
"key",
")",
"{",
"return",
"(",
"KeyEvent",
")",
"event",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | A collector function for key events for {@code key}. Use it to obtain only events for a
particular key like so:
<pre>{@code
Input.keyboardEvents.collect(ev -> Keyboard.isKey(Key.X, ev)).connect(event -> {
// handle the 'x' key being pressed or released
});
}</pre> | [
"A",
"collector",
"function",
"for",
"key",
"events",
"for",
"{",
"@code",
"key",
"}",
".",
"Use",
"it",
"to",
"obtain",
"only",
"events",
"for",
"a",
"particular",
"key",
"like",
"so",
":"
] | train | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Keyboard.java#L141-L147 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/VMath.java | VMath.setCol | public static void setCol(final double[][] m1, final int c, final double[] column) {
"""
Sets the <code>c</code>th column of this matrix to the specified column.
@param m1 Input matrix
@param c the index of the column to be set
@param column the value of the column to be set
"""
assert column.length == m1.length : ERR_DIMENSIONS;
for(int i = 0; i < m1.length; i++) {
m1[i][c] = column[i];
}
} | java | public static void setCol(final double[][] m1, final int c, final double[] column) {
assert column.length == m1.length : ERR_DIMENSIONS;
for(int i = 0; i < m1.length; i++) {
m1[i][c] = column[i];
}
} | [
"public",
"static",
"void",
"setCol",
"(",
"final",
"double",
"[",
"]",
"[",
"]",
"m1",
",",
"final",
"int",
"c",
",",
"final",
"double",
"[",
"]",
"column",
")",
"{",
"assert",
"column",
".",
"length",
"==",
"m1",
".",
"length",
":",
"ERR_DIMENSIONS",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m1",
".",
"length",
";",
"i",
"++",
")",
"{",
"m1",
"[",
"i",
"]",
"[",
"c",
"]",
"=",
"column",
"[",
"i",
"]",
";",
"}",
"}"
] | Sets the <code>c</code>th column of this matrix to the specified column.
@param m1 Input matrix
@param c the index of the column to be set
@param column the value of the column to be set | [
"Sets",
"the",
"<code",
">",
"c<",
"/",
"code",
">",
"th",
"column",
"of",
"this",
"matrix",
"to",
"the",
"specified",
"column",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/VMath.java#L1106-L1111 |
VoltDB/voltdb | src/frontend/org/voltdb/VoltDB.java | VoltDB.crashGlobalVoltDB | public static void crashGlobalVoltDB(String errMsg, boolean stackTrace, Throwable t) {
"""
Exit the process with an error message, optionally with a stack trace.
Also notify all connected peers that the node is going down.
"""
// for test code
wasCrashCalled = true;
crashMessage = errMsg;
if (ignoreCrash) {
throw new AssertionError("Faux crash of VoltDB successful.");
}
// end test code
// send a snmp trap crash notification
sendCrashSNMPTrap(errMsg);
try {
// turn off client interface as fast as possible
// we don't expect this to ever fail, but if it does, skip to dying immediately
if (!turnOffClientInterface()) {
return; // this will jump to the finally block and die faster
}
// instruct the rest of the cluster to die
instance().getHostMessenger().sendPoisonPill(errMsg);
// give the pill a chance to make it through the network buffer
Thread.sleep(500);
} catch (Exception e) {
e.printStackTrace();
// sleep even on exception in case the pill got sent before the exception
try { Thread.sleep(500); } catch (InterruptedException e2) {}
}
// finally block does its best to ensure death, no matter what context this
// is called in
finally {
crashLocalVoltDB(errMsg, stackTrace, t);
}
} | java | public static void crashGlobalVoltDB(String errMsg, boolean stackTrace, Throwable t) {
// for test code
wasCrashCalled = true;
crashMessage = errMsg;
if (ignoreCrash) {
throw new AssertionError("Faux crash of VoltDB successful.");
}
// end test code
// send a snmp trap crash notification
sendCrashSNMPTrap(errMsg);
try {
// turn off client interface as fast as possible
// we don't expect this to ever fail, but if it does, skip to dying immediately
if (!turnOffClientInterface()) {
return; // this will jump to the finally block and die faster
}
// instruct the rest of the cluster to die
instance().getHostMessenger().sendPoisonPill(errMsg);
// give the pill a chance to make it through the network buffer
Thread.sleep(500);
} catch (Exception e) {
e.printStackTrace();
// sleep even on exception in case the pill got sent before the exception
try { Thread.sleep(500); } catch (InterruptedException e2) {}
}
// finally block does its best to ensure death, no matter what context this
// is called in
finally {
crashLocalVoltDB(errMsg, stackTrace, t);
}
} | [
"public",
"static",
"void",
"crashGlobalVoltDB",
"(",
"String",
"errMsg",
",",
"boolean",
"stackTrace",
",",
"Throwable",
"t",
")",
"{",
"// for test code",
"wasCrashCalled",
"=",
"true",
";",
"crashMessage",
"=",
"errMsg",
";",
"if",
"(",
"ignoreCrash",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"\"Faux crash of VoltDB successful.\"",
")",
";",
"}",
"// end test code",
"// send a snmp trap crash notification",
"sendCrashSNMPTrap",
"(",
"errMsg",
")",
";",
"try",
"{",
"// turn off client interface as fast as possible",
"// we don't expect this to ever fail, but if it does, skip to dying immediately",
"if",
"(",
"!",
"turnOffClientInterface",
"(",
")",
")",
"{",
"return",
";",
"// this will jump to the finally block and die faster",
"}",
"// instruct the rest of the cluster to die",
"instance",
"(",
")",
".",
"getHostMessenger",
"(",
")",
".",
"sendPoisonPill",
"(",
"errMsg",
")",
";",
"// give the pill a chance to make it through the network buffer",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"// sleep even on exception in case the pill got sent before the exception",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e2",
")",
"{",
"}",
"}",
"// finally block does its best to ensure death, no matter what context this",
"// is called in",
"finally",
"{",
"crashLocalVoltDB",
"(",
"errMsg",
",",
"stackTrace",
",",
"t",
")",
";",
"}",
"}"
] | Exit the process with an error message, optionally with a stack trace.
Also notify all connected peers that the node is going down. | [
"Exit",
"the",
"process",
"with",
"an",
"error",
"message",
"optionally",
"with",
"a",
"stack",
"trace",
".",
"Also",
"notify",
"all",
"connected",
"peers",
"that",
"the",
"node",
"is",
"going",
"down",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltDB.java#L1416-L1447 |
skuzzle/semantic-version | src/it/java/de/skuzzle/semantic/VersionRegEx.java | VersionRegEx.min | public static VersionRegEx min(VersionRegEx v1, VersionRegEx v2) {
"""
Returns the lower of the two given versions by comparing them using their natural
ordering. If both versions are equal, then the first argument is returned.
@param v1 The first version.
@param v2 The second version.
@return The lower version.
@throws IllegalArgumentException If either argument is <code>null</code>.
@since 0.4.0
"""
require(v1 != null, "v1 is null");
require(v2 != null, "v2 is null");
return compare(v1, v2, false) <= 0
? v1
: v2;
} | java | public static VersionRegEx min(VersionRegEx v1, VersionRegEx v2) {
require(v1 != null, "v1 is null");
require(v2 != null, "v2 is null");
return compare(v1, v2, false) <= 0
? v1
: v2;
} | [
"public",
"static",
"VersionRegEx",
"min",
"(",
"VersionRegEx",
"v1",
",",
"VersionRegEx",
"v2",
")",
"{",
"require",
"(",
"v1",
"!=",
"null",
",",
"\"v1 is null\"",
")",
";",
"require",
"(",
"v2",
"!=",
"null",
",",
"\"v2 is null\"",
")",
";",
"return",
"compare",
"(",
"v1",
",",
"v2",
",",
"false",
")",
"<=",
"0",
"?",
"v1",
":",
"v2",
";",
"}"
] | Returns the lower of the two given versions by comparing them using their natural
ordering. If both versions are equal, then the first argument is returned.
@param v1 The first version.
@param v2 The second version.
@return The lower version.
@throws IllegalArgumentException If either argument is <code>null</code>.
@since 0.4.0 | [
"Returns",
"the",
"lower",
"of",
"the",
"two",
"given",
"versions",
"by",
"comparing",
"them",
"using",
"their",
"natural",
"ordering",
".",
"If",
"both",
"versions",
"are",
"equal",
"then",
"the",
"first",
"argument",
"is",
"returned",
"."
] | train | https://github.com/skuzzle/semantic-version/blob/2ddb66fb80244cd7f67c77ed5f8072d1132ad933/src/it/java/de/skuzzle/semantic/VersionRegEx.java#L246-L252 |
geomajas/geomajas-project-client-gwt | common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java | HtmlBuilder.trClass | public static String trClass(String clazz, String... content) {
"""
Build a HTML TableRow with given CSS class for a string.
Given content does <b>not</b> consists of HTML snippets and
as such is being prepared with {@link HtmlBuilder#htmlEncode(String)}.
@param clazz class for tr element
@param content content string
@return HTML tr element as string
"""
return tagClass(Html.Tag.TR, clazz, content);
} | java | public static String trClass(String clazz, String... content) {
return tagClass(Html.Tag.TR, clazz, content);
} | [
"public",
"static",
"String",
"trClass",
"(",
"String",
"clazz",
",",
"String",
"...",
"content",
")",
"{",
"return",
"tagClass",
"(",
"Html",
".",
"Tag",
".",
"TR",
",",
"clazz",
",",
"content",
")",
";",
"}"
] | Build a HTML TableRow with given CSS class for a string.
Given content does <b>not</b> consists of HTML snippets and
as such is being prepared with {@link HtmlBuilder#htmlEncode(String)}.
@param clazz class for tr element
@param content content string
@return HTML tr element as string | [
"Build",
"a",
"HTML",
"TableRow",
"with",
"given",
"CSS",
"class",
"for",
"a",
"string",
".",
"Given",
"content",
"does",
"<b",
">",
"not<",
"/",
"b",
">",
"consists",
"of",
"HTML",
"snippets",
"and",
"as",
"such",
"is",
"being",
"prepared",
"with",
"{",
"@link",
"HtmlBuilder#htmlEncode",
"(",
"String",
")",
"}",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java#L140-L142 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/sign/up/SignupPanel.java | SignupPanel.newUsernameTextField | protected Component newUsernameTextField(final String id, final IModel<T> model) {
"""
Factory method for creating the TextField for the username. This method is invoked in the
constructor from the derived classes and can be overridden so users can provide their own
version of a TextField for the username.
@param id
the id
@param model
the model
@return the text field
"""
final IModel<String> labelModel = ResourceModelFactory
.newResourceModel("global.username.label", this);
final IModel<String> placeholderModel = ResourceModelFactory
.newResourceModel("global.enter.your.username.label", this);
final LabeledTextFieldPanel<String, T> nameTextField = new LabeledTextFieldPanel<String, T>(
id, model, labelModel)
{
private static final long serialVersionUID = 1L;
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected TextField newTextField(final String id, final IModel<T> modelSuper)
{
final TextField<String> textField = new TextField<String>(id,
new PropertyModel<>(model, "username"));
textField.setOutputMarkupId(true);
textField.setRequired(true);
if (placeholderModel != null)
{
textField.add(new AttributeAppender("placeholder", placeholderModel));
}
return textField;
}
};
return nameTextField;
} | java | protected Component newUsernameTextField(final String id, final IModel<T> model)
{
final IModel<String> labelModel = ResourceModelFactory
.newResourceModel("global.username.label", this);
final IModel<String> placeholderModel = ResourceModelFactory
.newResourceModel("global.enter.your.username.label", this);
final LabeledTextFieldPanel<String, T> nameTextField = new LabeledTextFieldPanel<String, T>(
id, model, labelModel)
{
private static final long serialVersionUID = 1L;
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected TextField newTextField(final String id, final IModel<T> modelSuper)
{
final TextField<String> textField = new TextField<String>(id,
new PropertyModel<>(model, "username"));
textField.setOutputMarkupId(true);
textField.setRequired(true);
if (placeholderModel != null)
{
textField.add(new AttributeAppender("placeholder", placeholderModel));
}
return textField;
}
};
return nameTextField;
} | [
"protected",
"Component",
"newUsernameTextField",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"model",
")",
"{",
"final",
"IModel",
"<",
"String",
">",
"labelModel",
"=",
"ResourceModelFactory",
".",
"newResourceModel",
"(",
"\"global.username.label\"",
",",
"this",
")",
";",
"final",
"IModel",
"<",
"String",
">",
"placeholderModel",
"=",
"ResourceModelFactory",
".",
"newResourceModel",
"(",
"\"global.enter.your.username.label\"",
",",
"this",
")",
";",
"final",
"LabeledTextFieldPanel",
"<",
"String",
",",
"T",
">",
"nameTextField",
"=",
"new",
"LabeledTextFieldPanel",
"<",
"String",
",",
"T",
">",
"(",
"id",
",",
"model",
",",
"labelModel",
")",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"protected",
"TextField",
"newTextField",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"modelSuper",
")",
"{",
"final",
"TextField",
"<",
"String",
">",
"textField",
"=",
"new",
"TextField",
"<",
"String",
">",
"(",
"id",
",",
"new",
"PropertyModel",
"<>",
"(",
"model",
",",
"\"username\"",
")",
")",
";",
"textField",
".",
"setOutputMarkupId",
"(",
"true",
")",
";",
"textField",
".",
"setRequired",
"(",
"true",
")",
";",
"if",
"(",
"placeholderModel",
"!=",
"null",
")",
"{",
"textField",
".",
"add",
"(",
"new",
"AttributeAppender",
"(",
"\"placeholder\"",
",",
"placeholderModel",
")",
")",
";",
"}",
"return",
"textField",
";",
"}",
"}",
";",
"return",
"nameTextField",
";",
"}"
] | Factory method for creating the TextField for the username. This method is invoked in the
constructor from the derived classes and can be overridden so users can provide their own
version of a TextField for the username.
@param id
the id
@param model
the model
@return the text field | [
"Factory",
"method",
"for",
"creating",
"the",
"TextField",
"for",
"the",
"username",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"TextField",
"for",
"the",
"username",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/sign/up/SignupPanel.java#L140-L168 |
timols/java-gitlab-api | src/main/java/org/gitlab/api/GitlabAPI.java | GitlabAPI.deleteProjectMember | public void deleteProjectMember(GitlabProject project, GitlabUser user) throws IOException {
"""
Delete a project team member.
@param project the GitlabProject
@param user the GitlabUser
@throws IOException on gitlab api call error
"""
deleteProjectMember(project.getId(), user.getId());
} | java | public void deleteProjectMember(GitlabProject project, GitlabUser user) throws IOException {
deleteProjectMember(project.getId(), user.getId());
} | [
"public",
"void",
"deleteProjectMember",
"(",
"GitlabProject",
"project",
",",
"GitlabUser",
"user",
")",
"throws",
"IOException",
"{",
"deleteProjectMember",
"(",
"project",
".",
"getId",
"(",
")",
",",
"user",
".",
"getId",
"(",
")",
")",
";",
"}"
] | Delete a project team member.
@param project the GitlabProject
@param user the GitlabUser
@throws IOException on gitlab api call error | [
"Delete",
"a",
"project",
"team",
"member",
"."
] | train | https://github.com/timols/java-gitlab-api/blob/f03eedf952cfbb40306be3bf9234dcf78fab029e/src/main/java/org/gitlab/api/GitlabAPI.java#L3057-L3059 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java | NumberUtil.processMultiple | public static int processMultiple(int selectNum, int minNum) {
"""
可以用于计算双色球、大乐透注数的方法<br>
比如大乐透35选5可以这样调用processMultiple(7,5); 就是数学中的:C75=7*6/2*1
@param selectNum 选中小球个数
@param minNum 最少要选中多少个小球
@return 注数
"""
int result;
result = mathSubnode(selectNum, minNum) / mathNode(selectNum - minNum);
return result;
} | java | public static int processMultiple(int selectNum, int minNum) {
int result;
result = mathSubnode(selectNum, minNum) / mathNode(selectNum - minNum);
return result;
} | [
"public",
"static",
"int",
"processMultiple",
"(",
"int",
"selectNum",
",",
"int",
"minNum",
")",
"{",
"int",
"result",
";",
"result",
"=",
"mathSubnode",
"(",
"selectNum",
",",
"minNum",
")",
"/",
"mathNode",
"(",
"selectNum",
"-",
"minNum",
")",
";",
"return",
"result",
";",
"}"
] | 可以用于计算双色球、大乐透注数的方法<br>
比如大乐透35选5可以这样调用processMultiple(7,5); 就是数学中的:C75=7*6/2*1
@param selectNum 选中小球个数
@param minNum 最少要选中多少个小球
@return 注数 | [
"可以用于计算双色球、大乐透注数的方法<br",
">",
"比如大乐透35选5可以这样调用processMultiple",
"(",
"7",
"5",
")",
";",
"就是数学中的:C75",
"=",
"7",
"*",
"6",
"/",
"2",
"*",
"1"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java#L1438-L1442 |
ZieIony/Carbon | carbon/src/main/java/carbon/drawable/ripple/LayerDrawable.java | LayerDrawable.setDrawableByLayerId | public boolean setDrawableByLayerId(int id, Drawable drawable) {
"""
Replaces the {@link Drawable} for the layer with the given id.
@param id The layer ID to search for.
@param drawable The replacement {@link Drawable}.
@return Whether the {@link Drawable} was replaced (could return false if the id was not
found).
"""
final int index = findIndexByLayerId(id);
if (index < 0) {
return false;
}
setDrawable(index, drawable);
return true;
} | java | public boolean setDrawableByLayerId(int id, Drawable drawable) {
final int index = findIndexByLayerId(id);
if (index < 0) {
return false;
}
setDrawable(index, drawable);
return true;
} | [
"public",
"boolean",
"setDrawableByLayerId",
"(",
"int",
"id",
",",
"Drawable",
"drawable",
")",
"{",
"final",
"int",
"index",
"=",
"findIndexByLayerId",
"(",
"id",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"setDrawable",
"(",
"index",
",",
"drawable",
")",
";",
"return",
"true",
";",
"}"
] | Replaces the {@link Drawable} for the layer with the given id.
@param id The layer ID to search for.
@param drawable The replacement {@link Drawable}.
@return Whether the {@link Drawable} was replaced (could return false if the id was not
found). | [
"Replaces",
"the",
"{",
"@link",
"Drawable",
"}",
"for",
"the",
"layer",
"with",
"the",
"given",
"id",
"."
] | train | https://github.com/ZieIony/Carbon/blob/78b0a432bd49edc7a6a13ce111cab274085d1693/carbon/src/main/java/carbon/drawable/ripple/LayerDrawable.java#L483-L491 |
JakeWharton/butterknife | butterknife-runtime/src/main/java/butterknife/ViewCollections.java | ViewCollections.set | @UiThread
public static <T extends View, V> void set(@NonNull T[] array,
@NonNull Property<? super T, V> setter, @Nullable V value) {
"""
Apply the specified {@code value} across the {@code array} of views using the {@code property}.
"""
//noinspection ForLoopReplaceableByForEach
for (int i = 0, count = array.length; i < count; i++) {
setter.set(array[i], value);
}
} | java | @UiThread
public static <T extends View, V> void set(@NonNull T[] array,
@NonNull Property<? super T, V> setter, @Nullable V value) {
//noinspection ForLoopReplaceableByForEach
for (int i = 0, count = array.length; i < count; i++) {
setter.set(array[i], value);
}
} | [
"@",
"UiThread",
"public",
"static",
"<",
"T",
"extends",
"View",
",",
"V",
">",
"void",
"set",
"(",
"@",
"NonNull",
"T",
"[",
"]",
"array",
",",
"@",
"NonNull",
"Property",
"<",
"?",
"super",
"T",
",",
"V",
">",
"setter",
",",
"@",
"Nullable",
"V",
"value",
")",
"{",
"//noinspection ForLoopReplaceableByForEach",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"count",
"=",
"array",
".",
"length",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"setter",
".",
"set",
"(",
"array",
"[",
"i",
"]",
",",
"value",
")",
";",
"}",
"}"
] | Apply the specified {@code value} across the {@code array} of views using the {@code property}. | [
"Apply",
"the",
"specified",
"{"
] | train | https://github.com/JakeWharton/butterknife/blob/0ead8a7b21620effcf78c728089fc16ae9d664c0/butterknife-runtime/src/main/java/butterknife/ViewCollections.java#L106-L113 |
davidcarboni/restolino | src/main/java/com/github/davidcarboni/restolino/api/Router.java | Router.doMethod | void doMethod(HttpServletRequest request, HttpServletResponse response, HttpMethod httpMethod) {
"""
GO!
@param request The request.
@param response The response.
"""
// Locate a request handler:
String requestPath = mapRequestPath(request);
Route route = api.get(requestPath);
try {
if (route != null && route.requestHandlers.containsKey(httpMethod)) {
handleRequest(request, response, route, httpMethod);
} else {
handleNotFound(request, response);
}
} catch (Throwable t) {
// Chances are the exception we've actually caught is the reflection
// one from Method.invoke(...)
Throwable caught = t;
if (InvocationTargetException.class.isAssignableFrom(t.getClass())) {
caught = t.getCause();
}
RequestHandler requestHandler = (route == null ? null : route.requestHandlers.get(httpMethod));
handleError(request, response, requestHandler, caught);
}
} | java | void doMethod(HttpServletRequest request, HttpServletResponse response, HttpMethod httpMethod) {
// Locate a request handler:
String requestPath = mapRequestPath(request);
Route route = api.get(requestPath);
try {
if (route != null && route.requestHandlers.containsKey(httpMethod)) {
handleRequest(request, response, route, httpMethod);
} else {
handleNotFound(request, response);
}
} catch (Throwable t) {
// Chances are the exception we've actually caught is the reflection
// one from Method.invoke(...)
Throwable caught = t;
if (InvocationTargetException.class.isAssignableFrom(t.getClass())) {
caught = t.getCause();
}
RequestHandler requestHandler = (route == null ? null : route.requestHandlers.get(httpMethod));
handleError(request, response, requestHandler, caught);
}
} | [
"void",
"doMethod",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"HttpMethod",
"httpMethod",
")",
"{",
"// Locate a request handler:",
"String",
"requestPath",
"=",
"mapRequestPath",
"(",
"request",
")",
";",
"Route",
"route",
"=",
"api",
".",
"get",
"(",
"requestPath",
")",
";",
"try",
"{",
"if",
"(",
"route",
"!=",
"null",
"&&",
"route",
".",
"requestHandlers",
".",
"containsKey",
"(",
"httpMethod",
")",
")",
"{",
"handleRequest",
"(",
"request",
",",
"response",
",",
"route",
",",
"httpMethod",
")",
";",
"}",
"else",
"{",
"handleNotFound",
"(",
"request",
",",
"response",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// Chances are the exception we've actually caught is the reflection",
"// one from Method.invoke(...)",
"Throwable",
"caught",
"=",
"t",
";",
"if",
"(",
"InvocationTargetException",
".",
"class",
".",
"isAssignableFrom",
"(",
"t",
".",
"getClass",
"(",
")",
")",
")",
"{",
"caught",
"=",
"t",
".",
"getCause",
"(",
")",
";",
"}",
"RequestHandler",
"requestHandler",
"=",
"(",
"route",
"==",
"null",
"?",
"null",
":",
"route",
".",
"requestHandlers",
".",
"get",
"(",
"httpMethod",
")",
")",
";",
"handleError",
"(",
"request",
",",
"response",
",",
"requestHandler",
",",
"caught",
")",
";",
"}",
"}"
] | GO!
@param request The request.
@param response The response. | [
"GO!"
] | train | https://github.com/davidcarboni/restolino/blob/3f84ece1bd016fbb597c624d46fcca5a2580a33d/src/main/java/com/github/davidcarboni/restolino/api/Router.java#L322-L349 |
anotheria/moskito | moskito-extensions/moskito-monitoring-plugin/src/main/java/net/anotheria/moskito/extensions/monitoring/stats/GenericStats.java | GenericStats.getStatValueAsInteger | public int getStatValueAsInteger(T metric, String interval) {
"""
Get value of provided metric for the given interval as int value.
@param metric metric which value we wanna get
@param interval the name of the Interval or <code>null</code> to get the absolute value
@return the current value
"""
if (metric.isRateMetric()) {
return (int)(getStatValueAsDouble(metric, interval));
}
return getMonitoredStatValue(metric).getValueAsInt(interval);
} | java | public int getStatValueAsInteger(T metric, String interval) {
if (metric.isRateMetric()) {
return (int)(getStatValueAsDouble(metric, interval));
}
return getMonitoredStatValue(metric).getValueAsInt(interval);
} | [
"public",
"int",
"getStatValueAsInteger",
"(",
"T",
"metric",
",",
"String",
"interval",
")",
"{",
"if",
"(",
"metric",
".",
"isRateMetric",
"(",
")",
")",
"{",
"return",
"(",
"int",
")",
"(",
"getStatValueAsDouble",
"(",
"metric",
",",
"interval",
")",
")",
";",
"}",
"return",
"getMonitoredStatValue",
"(",
"metric",
")",
".",
"getValueAsInt",
"(",
"interval",
")",
";",
"}"
] | Get value of provided metric for the given interval as int value.
@param metric metric which value we wanna get
@param interval the name of the Interval or <code>null</code> to get the absolute value
@return the current value | [
"Get",
"value",
"of",
"provided",
"metric",
"for",
"the",
"given",
"interval",
"as",
"int",
"value",
"."
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-extensions/moskito-monitoring-plugin/src/main/java/net/anotheria/moskito/extensions/monitoring/stats/GenericStats.java#L178-L183 |
ontop/ontop | core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java | OntologyBuilderImpl.createDataPropertyAssertion | public static DataPropertyAssertion createDataPropertyAssertion(DataPropertyExpression dpe, ObjectConstant o1, ValueConstant o2) throws InconsistentOntologyException {
"""
Creates a data property assertion
<p>
DataPropertyAssertion := 'DataPropertyAssertion' '(' axiomAnnotations
DataPropertyExpression sourceIndividual targetValue ')'
<p>
Implements rule [D4]:
- ignore (return null) if the property is top
- inconsistency if the property is bot
"""
if (dpe.isTop())
return null;
if (dpe.isBottom())
throw new InconsistentOntologyException();
return new DataPropertyAssertionImpl(dpe, o1, o2);
} | java | public static DataPropertyAssertion createDataPropertyAssertion(DataPropertyExpression dpe, ObjectConstant o1, ValueConstant o2) throws InconsistentOntologyException {
if (dpe.isTop())
return null;
if (dpe.isBottom())
throw new InconsistentOntologyException();
return new DataPropertyAssertionImpl(dpe, o1, o2);
} | [
"public",
"static",
"DataPropertyAssertion",
"createDataPropertyAssertion",
"(",
"DataPropertyExpression",
"dpe",
",",
"ObjectConstant",
"o1",
",",
"ValueConstant",
"o2",
")",
"throws",
"InconsistentOntologyException",
"{",
"if",
"(",
"dpe",
".",
"isTop",
"(",
")",
")",
"return",
"null",
";",
"if",
"(",
"dpe",
".",
"isBottom",
"(",
")",
")",
"throw",
"new",
"InconsistentOntologyException",
"(",
")",
";",
"return",
"new",
"DataPropertyAssertionImpl",
"(",
"dpe",
",",
"o1",
",",
"o2",
")",
";",
"}"
] | Creates a data property assertion
<p>
DataPropertyAssertion := 'DataPropertyAssertion' '(' axiomAnnotations
DataPropertyExpression sourceIndividual targetValue ')'
<p>
Implements rule [D4]:
- ignore (return null) if the property is top
- inconsistency if the property is bot | [
"Creates",
"a",
"data",
"property",
"assertion",
"<p",
">",
"DataPropertyAssertion",
":",
"=",
"DataPropertyAssertion",
"(",
"axiomAnnotations",
"DataPropertyExpression",
"sourceIndividual",
"targetValue",
")",
"<p",
">",
"Implements",
"rule",
"[",
"D4",
"]",
":",
"-",
"ignore",
"(",
"return",
"null",
")",
"if",
"the",
"property",
"is",
"top",
"-",
"inconsistency",
"if",
"the",
"property",
"is",
"bot"
] | train | https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java#L480-L487 |
ngageoint/geopackage-java | src/main/java/mil/nga/geopackage/tiles/ImageUtils.java | ImageUtils.compressAndWriteImageToBytes | public static byte[] compressAndWriteImageToBytes(BufferedImage image,
String formatName, float quality) {
"""
Compress and write the image to bytes in the provided format and quality
@param image
buffered image
@param formatName
image format name
@param quality
quality between 0.0 and 1.0
@return compressed image bytes
@since 1.1.2
"""
byte[] bytes = null;
Iterator<ImageWriter> writers = ImageIO
.getImageWritersByFormatName(formatName);
if (writers == null || !writers.hasNext()) {
throw new GeoPackageException(
"No Image Writer to compress format: " + formatName);
}
ImageWriter writer = writers.next();
ImageWriteParam writeParam = writer.getDefaultWriteParam();
writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParam.setCompressionQuality(quality);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageOutputStream ios = null;
try {
ios = ImageIO.createImageOutputStream(baos);
writer.setOutput(ios);
writer.write(null, new IIOImage(image, null, null), writeParam);
writer.dispose();
bytes = baos.toByteArray();
} catch (IOException e) {
throw new GeoPackageException(
"Failed to compress image to format: " + formatName
+ ", with quality: " + quality, e);
} finally {
closeQuietly(ios);
closeQuietly(baos);
}
return bytes;
} | java | public static byte[] compressAndWriteImageToBytes(BufferedImage image,
String formatName, float quality) {
byte[] bytes = null;
Iterator<ImageWriter> writers = ImageIO
.getImageWritersByFormatName(formatName);
if (writers == null || !writers.hasNext()) {
throw new GeoPackageException(
"No Image Writer to compress format: " + formatName);
}
ImageWriter writer = writers.next();
ImageWriteParam writeParam = writer.getDefaultWriteParam();
writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParam.setCompressionQuality(quality);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageOutputStream ios = null;
try {
ios = ImageIO.createImageOutputStream(baos);
writer.setOutput(ios);
writer.write(null, new IIOImage(image, null, null), writeParam);
writer.dispose();
bytes = baos.toByteArray();
} catch (IOException e) {
throw new GeoPackageException(
"Failed to compress image to format: " + formatName
+ ", with quality: " + quality, e);
} finally {
closeQuietly(ios);
closeQuietly(baos);
}
return bytes;
} | [
"public",
"static",
"byte",
"[",
"]",
"compressAndWriteImageToBytes",
"(",
"BufferedImage",
"image",
",",
"String",
"formatName",
",",
"float",
"quality",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"null",
";",
"Iterator",
"<",
"ImageWriter",
">",
"writers",
"=",
"ImageIO",
".",
"getImageWritersByFormatName",
"(",
"formatName",
")",
";",
"if",
"(",
"writers",
"==",
"null",
"||",
"!",
"writers",
".",
"hasNext",
"(",
")",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"No Image Writer to compress format: \"",
"+",
"formatName",
")",
";",
"}",
"ImageWriter",
"writer",
"=",
"writers",
".",
"next",
"(",
")",
";",
"ImageWriteParam",
"writeParam",
"=",
"writer",
".",
"getDefaultWriteParam",
"(",
")",
";",
"writeParam",
".",
"setCompressionMode",
"(",
"ImageWriteParam",
".",
"MODE_EXPLICIT",
")",
";",
"writeParam",
".",
"setCompressionQuality",
"(",
"quality",
")",
";",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ImageOutputStream",
"ios",
"=",
"null",
";",
"try",
"{",
"ios",
"=",
"ImageIO",
".",
"createImageOutputStream",
"(",
"baos",
")",
";",
"writer",
".",
"setOutput",
"(",
"ios",
")",
";",
"writer",
".",
"write",
"(",
"null",
",",
"new",
"IIOImage",
"(",
"image",
",",
"null",
",",
"null",
")",
",",
"writeParam",
")",
";",
"writer",
".",
"dispose",
"(",
")",
";",
"bytes",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"GeoPackageException",
"(",
"\"Failed to compress image to format: \"",
"+",
"formatName",
"+",
"\", with quality: \"",
"+",
"quality",
",",
"e",
")",
";",
"}",
"finally",
"{",
"closeQuietly",
"(",
"ios",
")",
";",
"closeQuietly",
"(",
"baos",
")",
";",
"}",
"return",
"bytes",
";",
"}"
] | Compress and write the image to bytes in the provided format and quality
@param image
buffered image
@param formatName
image format name
@param quality
quality between 0.0 and 1.0
@return compressed image bytes
@since 1.1.2 | [
"Compress",
"and",
"write",
"the",
"image",
"to",
"bytes",
"in",
"the",
"provided",
"format",
"and",
"quality"
] | train | https://github.com/ngageoint/geopackage-java/blob/889bffb5d18330a3f4bd89443acf7959ebe3a376/src/main/java/mil/nga/geopackage/tiles/ImageUtils.java#L200-L236 |
redkale/redkale | src/org/redkale/net/http/HttpRequest.java | HttpRequest.getHeader | public String getHeader(String name, String defaultValue) {
"""
获取指定的header值, 没有返回默认值
@param name header名
@param defaultValue 默认值
@return header值
"""
return header.getValue(name, defaultValue);
} | java | public String getHeader(String name, String defaultValue) {
return header.getValue(name, defaultValue);
} | [
"public",
"String",
"getHeader",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"{",
"return",
"header",
".",
"getValue",
"(",
"name",
",",
"defaultValue",
")",
";",
"}"
] | 获取指定的header值, 没有返回默认值
@param name header名
@param defaultValue 默认值
@return header值 | [
"获取指定的header值",
"没有返回默认值"
] | train | https://github.com/redkale/redkale/blob/ea5169b5c5ea7412fd762331c0c497165832e901/src/org/redkale/net/http/HttpRequest.java#L1016-L1018 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/BootstrapConfig.java | BootstrapConfig.getConfigFile | public File getConfigFile(String relativeServerPath) {
"""
Allocate a file in the server config directory, e.g.
usr/servers/serverName/relativeServerPath
@param relativeServerPath
relative path of file to create in the server directory
@return File object for relative path, or for the server directory itself
if the relative path argument is null
"""
if (relativeServerPath == null)
return configDir;
else
return new File(configDir, relativeServerPath);
} | java | public File getConfigFile(String relativeServerPath) {
if (relativeServerPath == null)
return configDir;
else
return new File(configDir, relativeServerPath);
} | [
"public",
"File",
"getConfigFile",
"(",
"String",
"relativeServerPath",
")",
"{",
"if",
"(",
"relativeServerPath",
"==",
"null",
")",
"return",
"configDir",
";",
"else",
"return",
"new",
"File",
"(",
"configDir",
",",
"relativeServerPath",
")",
";",
"}"
] | Allocate a file in the server config directory, e.g.
usr/servers/serverName/relativeServerPath
@param relativeServerPath
relative path of file to create in the server directory
@return File object for relative path, or for the server directory itself
if the relative path argument is null | [
"Allocate",
"a",
"file",
"in",
"the",
"server",
"config",
"directory",
"e",
".",
"g",
".",
"usr",
"/",
"servers",
"/",
"serverName",
"/",
"relativeServerPath"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/BootstrapConfig.java#L612-L617 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java | CloudTasksClient.renewLease | public final Task renewLease(TaskName name, Timestamp scheduleTime, Duration leaseDuration) {
"""
Renew the current lease of a pull task.
<p>The worker can use this method to extend the lease by a new duration, starting from now. The
new task lease will be returned in the task's
[schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time].
<p>Sample code:
<pre><code>
try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]");
Timestamp scheduleTime = Timestamp.newBuilder().build();
Duration leaseDuration = Duration.newBuilder().build();
Task response = cloudTasksClient.renewLease(name, scheduleTime, leaseDuration);
}
</code></pre>
@param name Required.
<p>The task name. For example:
`projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
@param scheduleTime Required.
<p>The task's current schedule time, available in the
[schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by
[LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or
[RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction
is to ensure that your worker currently holds the lease.
@param leaseDuration Required.
<p>The desired new lease duration, starting from now.
<p>The maximum lease duration is 1 week. `lease_duration` will be truncated to the nearest
second.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
RenewLeaseRequest request =
RenewLeaseRequest.newBuilder()
.setName(name == null ? null : name.toString())
.setScheduleTime(scheduleTime)
.setLeaseDuration(leaseDuration)
.build();
return renewLease(request);
} | java | public final Task renewLease(TaskName name, Timestamp scheduleTime, Duration leaseDuration) {
RenewLeaseRequest request =
RenewLeaseRequest.newBuilder()
.setName(name == null ? null : name.toString())
.setScheduleTime(scheduleTime)
.setLeaseDuration(leaseDuration)
.build();
return renewLease(request);
} | [
"public",
"final",
"Task",
"renewLease",
"(",
"TaskName",
"name",
",",
"Timestamp",
"scheduleTime",
",",
"Duration",
"leaseDuration",
")",
"{",
"RenewLeaseRequest",
"request",
"=",
"RenewLeaseRequest",
".",
"newBuilder",
"(",
")",
".",
"setName",
"(",
"name",
"==",
"null",
"?",
"null",
":",
"name",
".",
"toString",
"(",
")",
")",
".",
"setScheduleTime",
"(",
"scheduleTime",
")",
".",
"setLeaseDuration",
"(",
"leaseDuration",
")",
".",
"build",
"(",
")",
";",
"return",
"renewLease",
"(",
"request",
")",
";",
"}"
] | Renew the current lease of a pull task.
<p>The worker can use this method to extend the lease by a new duration, starting from now. The
new task lease will be returned in the task's
[schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time].
<p>Sample code:
<pre><code>
try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]");
Timestamp scheduleTime = Timestamp.newBuilder().build();
Duration leaseDuration = Duration.newBuilder().build();
Task response = cloudTasksClient.renewLease(name, scheduleTime, leaseDuration);
}
</code></pre>
@param name Required.
<p>The task name. For example:
`projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
@param scheduleTime Required.
<p>The task's current schedule time, available in the
[schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by
[LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or
[RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction
is to ensure that your worker currently holds the lease.
@param leaseDuration Required.
<p>The desired new lease duration, starting from now.
<p>The maximum lease duration is 1 week. `lease_duration` will be truncated to the nearest
second.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Renew",
"the",
"current",
"lease",
"of",
"a",
"pull",
"task",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java#L2357-L2366 |
haraldk/TwelveMonkeys | common/common-io/src/main/java/com/twelvemonkeys/io/ole2/CompoundDocument.java | CompoundDocument.seekToSId | private void seekToSId(final int pSId, final long pStreamSize) throws IOException {
"""
Seeks to the start pos for the given stream Id
@param pSId the stream Id
@param pStreamSize the size of the stream, or -1 for system control streams
@throws IOException if an I/O exception occurs
"""
long pos;
if (isShortStream(pStreamSize)) {
// The short stream is not continuous...
Entry root = getRootEntry();
if (shortStreamSIdChain == null) {
shortStreamSIdChain = getSIdChain(root.startSId, root.streamSize);
}
// System.err.println("pSId: " + pSId);
int shortPerSId = sectorSize / shortSectorSize;
// System.err.println("shortPerSId: " + shortPerSId);
int offset = pSId / shortPerSId;
// System.err.println("offset: " + offset);
int shortOffset = pSId - (offset * shortPerSId);
// System.err.println("shortOffset: " + shortOffset);
// System.err.println("shortStreamSIdChain.offset: " + shortStreamSIdChain.get(offset));
pos = HEADER_SIZE
+ (shortStreamSIdChain.get(offset) * (long) sectorSize)
+ (shortOffset * (long) shortSectorSize);
// System.err.println("pos: " + pos);
}
else {
pos = HEADER_SIZE + pSId * (long) sectorSize;
}
if (input instanceof LittleEndianRandomAccessFile) {
((LittleEndianRandomAccessFile) input).seek(pos);
}
else if (input instanceof ImageInputStream) {
((ImageInputStream) input).seek(pos);
}
else {
((SeekableLittleEndianDataInputStream) input).seek(pos);
}
} | java | private void seekToSId(final int pSId, final long pStreamSize) throws IOException {
long pos;
if (isShortStream(pStreamSize)) {
// The short stream is not continuous...
Entry root = getRootEntry();
if (shortStreamSIdChain == null) {
shortStreamSIdChain = getSIdChain(root.startSId, root.streamSize);
}
// System.err.println("pSId: " + pSId);
int shortPerSId = sectorSize / shortSectorSize;
// System.err.println("shortPerSId: " + shortPerSId);
int offset = pSId / shortPerSId;
// System.err.println("offset: " + offset);
int shortOffset = pSId - (offset * shortPerSId);
// System.err.println("shortOffset: " + shortOffset);
// System.err.println("shortStreamSIdChain.offset: " + shortStreamSIdChain.get(offset));
pos = HEADER_SIZE
+ (shortStreamSIdChain.get(offset) * (long) sectorSize)
+ (shortOffset * (long) shortSectorSize);
// System.err.println("pos: " + pos);
}
else {
pos = HEADER_SIZE + pSId * (long) sectorSize;
}
if (input instanceof LittleEndianRandomAccessFile) {
((LittleEndianRandomAccessFile) input).seek(pos);
}
else if (input instanceof ImageInputStream) {
((ImageInputStream) input).seek(pos);
}
else {
((SeekableLittleEndianDataInputStream) input).seek(pos);
}
} | [
"private",
"void",
"seekToSId",
"(",
"final",
"int",
"pSId",
",",
"final",
"long",
"pStreamSize",
")",
"throws",
"IOException",
"{",
"long",
"pos",
";",
"if",
"(",
"isShortStream",
"(",
"pStreamSize",
")",
")",
"{",
"// The short stream is not continuous...\r",
"Entry",
"root",
"=",
"getRootEntry",
"(",
")",
";",
"if",
"(",
"shortStreamSIdChain",
"==",
"null",
")",
"{",
"shortStreamSIdChain",
"=",
"getSIdChain",
"(",
"root",
".",
"startSId",
",",
"root",
".",
"streamSize",
")",
";",
"}",
"// System.err.println(\"pSId: \" + pSId);\r",
"int",
"shortPerSId",
"=",
"sectorSize",
"/",
"shortSectorSize",
";",
"// System.err.println(\"shortPerSId: \" + shortPerSId);\r",
"int",
"offset",
"=",
"pSId",
"/",
"shortPerSId",
";",
"// System.err.println(\"offset: \" + offset);\r",
"int",
"shortOffset",
"=",
"pSId",
"-",
"(",
"offset",
"*",
"shortPerSId",
")",
";",
"// System.err.println(\"shortOffset: \" + shortOffset);\r",
"// System.err.println(\"shortStreamSIdChain.offset: \" + shortStreamSIdChain.get(offset));\r",
"pos",
"=",
"HEADER_SIZE",
"+",
"(",
"shortStreamSIdChain",
".",
"get",
"(",
"offset",
")",
"*",
"(",
"long",
")",
"sectorSize",
")",
"+",
"(",
"shortOffset",
"*",
"(",
"long",
")",
"shortSectorSize",
")",
";",
"// System.err.println(\"pos: \" + pos);\r",
"}",
"else",
"{",
"pos",
"=",
"HEADER_SIZE",
"+",
"pSId",
"*",
"(",
"long",
")",
"sectorSize",
";",
"}",
"if",
"(",
"input",
"instanceof",
"LittleEndianRandomAccessFile",
")",
"{",
"(",
"(",
"LittleEndianRandomAccessFile",
")",
"input",
")",
".",
"seek",
"(",
"pos",
")",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"ImageInputStream",
")",
"{",
"(",
"(",
"ImageInputStream",
")",
"input",
")",
".",
"seek",
"(",
"pos",
")",
";",
"}",
"else",
"{",
"(",
"(",
"SeekableLittleEndianDataInputStream",
")",
"input",
")",
".",
"seek",
"(",
"pos",
")",
";",
"}",
"}"
] | Seeks to the start pos for the given stream Id
@param pSId the stream Id
@param pStreamSize the size of the stream, or -1 for system control streams
@throws IOException if an I/O exception occurs | [
"Seeks",
"to",
"the",
"start",
"pos",
"for",
"the",
"given",
"stream",
"Id"
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/ole2/CompoundDocument.java#L439-L476 |
maddingo/sojo | src/main/java/net/sf/sojo/common/ObjectUtil.java | ObjectUtil.compareTo | public int compareTo(final Object pvObject1, final Object pvObject2) {
"""
If parameter are <code>java.lang.Comparable</code> than delegate to the <code>compareTo</code> method
of the first parameter object.
<br>
By JavaBean are all properties comparing and add the several compareTo results.
They are one property <code>+1</code> and the second property <code>-1</code>,
then is the complete value <code>0</code>.
@param pvObject1 To comparing first value (must be unequals <code>null</code>).
@param pvObject2 To comparing second value (must be unequals <code>null</code>).
@return a negative integer, zero, or a positive integer as this object is less than,
equal to, or greater than the specified object.
"""
int lvCompareToValue = 0;
if (pvObject1 == null) {
throw new NullPointerException("First arg by compareTo is Null");
}
if (pvObject2 == null) {
throw new NullPointerException("Second arg by compareTo is Null");
}
if (pvObject1 != pvObject2) {
CompareResult[] lvCompareResults = compareIntern(pvObject1, pvObject2, false);
if (lvCompareResults != null) {
for (int i = 0; i < lvCompareResults.length; i++) {
int zw = lvCompareResults[i].getCompareToValue();
lvCompareToValue = lvCompareToValue + zw;
}
}
}
return lvCompareToValue;
} | java | public int compareTo(final Object pvObject1, final Object pvObject2) {
int lvCompareToValue = 0;
if (pvObject1 == null) {
throw new NullPointerException("First arg by compareTo is Null");
}
if (pvObject2 == null) {
throw new NullPointerException("Second arg by compareTo is Null");
}
if (pvObject1 != pvObject2) {
CompareResult[] lvCompareResults = compareIntern(pvObject1, pvObject2, false);
if (lvCompareResults != null) {
for (int i = 0; i < lvCompareResults.length; i++) {
int zw = lvCompareResults[i].getCompareToValue();
lvCompareToValue = lvCompareToValue + zw;
}
}
}
return lvCompareToValue;
} | [
"public",
"int",
"compareTo",
"(",
"final",
"Object",
"pvObject1",
",",
"final",
"Object",
"pvObject2",
")",
"{",
"int",
"lvCompareToValue",
"=",
"0",
";",
"if",
"(",
"pvObject1",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"First arg by compareTo is Null\"",
")",
";",
"}",
"if",
"(",
"pvObject2",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Second arg by compareTo is Null\"",
")",
";",
"}",
"if",
"(",
"pvObject1",
"!=",
"pvObject2",
")",
"{",
"CompareResult",
"[",
"]",
"lvCompareResults",
"=",
"compareIntern",
"(",
"pvObject1",
",",
"pvObject2",
",",
"false",
")",
";",
"if",
"(",
"lvCompareResults",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lvCompareResults",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"zw",
"=",
"lvCompareResults",
"[",
"i",
"]",
".",
"getCompareToValue",
"(",
")",
";",
"lvCompareToValue",
"=",
"lvCompareToValue",
"+",
"zw",
";",
"}",
"}",
"}",
"return",
"lvCompareToValue",
";",
"}"
] | If parameter are <code>java.lang.Comparable</code> than delegate to the <code>compareTo</code> method
of the first parameter object.
<br>
By JavaBean are all properties comparing and add the several compareTo results.
They are one property <code>+1</code> and the second property <code>-1</code>,
then is the complete value <code>0</code>.
@param pvObject1 To comparing first value (must be unequals <code>null</code>).
@param pvObject2 To comparing second value (must be unequals <code>null</code>).
@return a negative integer, zero, or a positive integer as this object is less than,
equal to, or greater than the specified object. | [
"If",
"parameter",
"are",
"<code",
">",
"java",
".",
"lang",
".",
"Comparable<",
"/",
"code",
">",
"than",
"delegate",
"to",
"the",
"<code",
">",
"compareTo<",
"/",
"code",
">",
"method",
"of",
"the",
"first",
"parameter",
"object",
".",
"<br",
">",
"By",
"JavaBean",
"are",
"all",
"properties",
"comparing",
"and",
"add",
"the",
"several",
"compareTo",
"results",
".",
"They",
"are",
"one",
"property",
"<code",
">",
"+",
"1<",
"/",
"code",
">",
"and",
"the",
"second",
"property",
"<code",
">",
"-",
"1<",
"/",
"code",
">",
"then",
"is",
"the",
"complete",
"value",
"<code",
">",
"0<",
"/",
"code",
">",
"."
] | train | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/common/ObjectUtil.java#L284-L303 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/ConstraintsChecker.java | ConstraintsChecker.mergeBasicConstraints | static int mergeBasicConstraints(X509Certificate cert, int maxPathLength) {
"""
Merges the specified maxPathLength with the pathLenConstraint
obtained from the certificate.
@param cert the <code>X509Certificate</code>
@param maxPathLength the previous maximum path length
@return the new maximum path length constraint (-1 means no more
certificates can follow, Integer.MAX_VALUE means path length is
unconstrained)
"""
int pathLenConstraint = cert.getBasicConstraints();
if (!X509CertImpl.isSelfIssued(cert)) {
maxPathLength--;
}
if (pathLenConstraint < maxPathLength) {
maxPathLength = pathLenConstraint;
}
return maxPathLength;
} | java | static int mergeBasicConstraints(X509Certificate cert, int maxPathLength) {
int pathLenConstraint = cert.getBasicConstraints();
if (!X509CertImpl.isSelfIssued(cert)) {
maxPathLength--;
}
if (pathLenConstraint < maxPathLength) {
maxPathLength = pathLenConstraint;
}
return maxPathLength;
} | [
"static",
"int",
"mergeBasicConstraints",
"(",
"X509Certificate",
"cert",
",",
"int",
"maxPathLength",
")",
"{",
"int",
"pathLenConstraint",
"=",
"cert",
".",
"getBasicConstraints",
"(",
")",
";",
"if",
"(",
"!",
"X509CertImpl",
".",
"isSelfIssued",
"(",
"cert",
")",
")",
"{",
"maxPathLength",
"--",
";",
"}",
"if",
"(",
"pathLenConstraint",
"<",
"maxPathLength",
")",
"{",
"maxPathLength",
"=",
"pathLenConstraint",
";",
"}",
"return",
"maxPathLength",
";",
"}"
] | Merges the specified maxPathLength with the pathLenConstraint
obtained from the certificate.
@param cert the <code>X509Certificate</code>
@param maxPathLength the previous maximum path length
@return the new maximum path length constraint (-1 means no more
certificates can follow, Integer.MAX_VALUE means path length is
unconstrained) | [
"Merges",
"the",
"specified",
"maxPathLength",
"with",
"the",
"pathLenConstraint",
"obtained",
"from",
"the",
"certificate",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/ConstraintsChecker.java#L294-L307 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/util/MRAsyncDiskService.java | MRAsyncDiskService.awaitTermination | public synchronized boolean awaitTermination(long milliseconds)
throws InterruptedException {
"""
Wait for the termination of the thread pools.
@param milliseconds The number of milliseconds to wait
@return true if all thread pools are terminated within time limit
@throws InterruptedException
"""
boolean result = asyncDiskService.awaitTermination(milliseconds);
if (result) {
LOG.info("Deleting toBeDeleted directory.");
for (int v = 0; v < volumes.length; v++) {
Path p = new Path(volumes[v], TOBEDELETED);
try {
localFileSystem.delete(p, true);
} catch (IOException e) {
LOG.warn("Cannot cleanup " + p + " " + StringUtils.stringifyException(e));
}
}
}
return result;
} | java | public synchronized boolean awaitTermination(long milliseconds)
throws InterruptedException {
boolean result = asyncDiskService.awaitTermination(milliseconds);
if (result) {
LOG.info("Deleting toBeDeleted directory.");
for (int v = 0; v < volumes.length; v++) {
Path p = new Path(volumes[v], TOBEDELETED);
try {
localFileSystem.delete(p, true);
} catch (IOException e) {
LOG.warn("Cannot cleanup " + p + " " + StringUtils.stringifyException(e));
}
}
}
return result;
} | [
"public",
"synchronized",
"boolean",
"awaitTermination",
"(",
"long",
"milliseconds",
")",
"throws",
"InterruptedException",
"{",
"boolean",
"result",
"=",
"asyncDiskService",
".",
"awaitTermination",
"(",
"milliseconds",
")",
";",
"if",
"(",
"result",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Deleting toBeDeleted directory.\"",
")",
";",
"for",
"(",
"int",
"v",
"=",
"0",
";",
"v",
"<",
"volumes",
".",
"length",
";",
"v",
"++",
")",
"{",
"Path",
"p",
"=",
"new",
"Path",
"(",
"volumes",
"[",
"v",
"]",
",",
"TOBEDELETED",
")",
";",
"try",
"{",
"localFileSystem",
".",
"delete",
"(",
"p",
",",
"true",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Cannot cleanup \"",
"+",
"p",
"+",
"\" \"",
"+",
"StringUtils",
".",
"stringifyException",
"(",
"e",
")",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Wait for the termination of the thread pools.
@param milliseconds The number of milliseconds to wait
@return true if all thread pools are terminated within time limit
@throws InterruptedException | [
"Wait",
"for",
"the",
"termination",
"of",
"the",
"thread",
"pools",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/util/MRAsyncDiskService.java#L157-L172 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/DateField.java | DateField.getSQLFromField | public void getSQLFromField(PreparedStatement statement, int iType, int iParamColumn) throws SQLException {
"""
Move the physical binary data to this SQL parameter row.
@param statement The SQL prepare statement.
@param iType the type of SQL statement.
@param iParamColumn The column in the prepared statement to set the data.
@exception SQLException From SQL calls.
"""
if (this.isNull())
{
if ((!this.isNullable())
|| (iType == DBConstants.SQL_SELECT_TYPE)
|| (DBConstants.FALSE.equals(this.getRecord().getTable().getDatabase().getProperties().get(SQLParams.NULL_TIMESTAMP_SUPPORTED)))) // HACK for Access
{ // Access does not allow you to pass a null for a timestamp (must pass a 0)
java.sql.Timestamp sqlDate = new java.sql.Timestamp(0);
statement.setTimestamp(iParamColumn, sqlDate);
}
else
statement.setNull(iParamColumn, Types.DATE);
}
else
{
java.sql.Date sqlDate = new java.sql.Date((long)this.getValue());
statement.setDate(iParamColumn, sqlDate);
}
} | java | public void getSQLFromField(PreparedStatement statement, int iType, int iParamColumn) throws SQLException
{
if (this.isNull())
{
if ((!this.isNullable())
|| (iType == DBConstants.SQL_SELECT_TYPE)
|| (DBConstants.FALSE.equals(this.getRecord().getTable().getDatabase().getProperties().get(SQLParams.NULL_TIMESTAMP_SUPPORTED)))) // HACK for Access
{ // Access does not allow you to pass a null for a timestamp (must pass a 0)
java.sql.Timestamp sqlDate = new java.sql.Timestamp(0);
statement.setTimestamp(iParamColumn, sqlDate);
}
else
statement.setNull(iParamColumn, Types.DATE);
}
else
{
java.sql.Date sqlDate = new java.sql.Date((long)this.getValue());
statement.setDate(iParamColumn, sqlDate);
}
} | [
"public",
"void",
"getSQLFromField",
"(",
"PreparedStatement",
"statement",
",",
"int",
"iType",
",",
"int",
"iParamColumn",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"this",
".",
"isNull",
"(",
")",
")",
"{",
"if",
"(",
"(",
"!",
"this",
".",
"isNullable",
"(",
")",
")",
"||",
"(",
"iType",
"==",
"DBConstants",
".",
"SQL_SELECT_TYPE",
")",
"||",
"(",
"DBConstants",
".",
"FALSE",
".",
"equals",
"(",
"this",
".",
"getRecord",
"(",
")",
".",
"getTable",
"(",
")",
".",
"getDatabase",
"(",
")",
".",
"getProperties",
"(",
")",
".",
"get",
"(",
"SQLParams",
".",
"NULL_TIMESTAMP_SUPPORTED",
")",
")",
")",
")",
"// HACK for Access",
"{",
"// Access does not allow you to pass a null for a timestamp (must pass a 0)",
"java",
".",
"sql",
".",
"Timestamp",
"sqlDate",
"=",
"new",
"java",
".",
"sql",
".",
"Timestamp",
"(",
"0",
")",
";",
"statement",
".",
"setTimestamp",
"(",
"iParamColumn",
",",
"sqlDate",
")",
";",
"}",
"else",
"statement",
".",
"setNull",
"(",
"iParamColumn",
",",
"Types",
".",
"DATE",
")",
";",
"}",
"else",
"{",
"java",
".",
"sql",
".",
"Date",
"sqlDate",
"=",
"new",
"java",
".",
"sql",
".",
"Date",
"(",
"(",
"long",
")",
"this",
".",
"getValue",
"(",
")",
")",
";",
"statement",
".",
"setDate",
"(",
"iParamColumn",
",",
"sqlDate",
")",
";",
"}",
"}"
] | Move the physical binary data to this SQL parameter row.
@param statement The SQL prepare statement.
@param iType the type of SQL statement.
@param iParamColumn The column in the prepared statement to set the data.
@exception SQLException From SQL calls. | [
"Move",
"the",
"physical",
"binary",
"data",
"to",
"this",
"SQL",
"parameter",
"row",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/DateField.java#L188-L207 |
pf4j/pf4j | pf4j/src/main/java/org/pf4j/util/DirectedGraph.java | DirectedGraph.removeEdge | public void removeEdge(V from, V to) {
"""
Remove an edge from the graph. Nothing happens if no such edge.
@throws {@link IllegalArgumentException} if either vertex doesn't exist.
"""
if (!containsVertex(from)) {
throw new IllegalArgumentException("Nonexistent vertex " + from);
}
if (!containsVertex(to)) {
throw new IllegalArgumentException("Nonexistent vertex " + to);
}
neighbors.get(from).remove(to);
} | java | public void removeEdge(V from, V to) {
if (!containsVertex(from)) {
throw new IllegalArgumentException("Nonexistent vertex " + from);
}
if (!containsVertex(to)) {
throw new IllegalArgumentException("Nonexistent vertex " + to);
}
neighbors.get(from).remove(to);
} | [
"public",
"void",
"removeEdge",
"(",
"V",
"from",
",",
"V",
"to",
")",
"{",
"if",
"(",
"!",
"containsVertex",
"(",
"from",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Nonexistent vertex \"",
"+",
"from",
")",
";",
"}",
"if",
"(",
"!",
"containsVertex",
"(",
"to",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Nonexistent vertex \"",
"+",
"to",
")",
";",
"}",
"neighbors",
".",
"get",
"(",
"from",
")",
".",
"remove",
"(",
"to",
")",
";",
"}"
] | Remove an edge from the graph. Nothing happens if no such edge.
@throws {@link IllegalArgumentException} if either vertex doesn't exist. | [
"Remove",
"an",
"edge",
"from",
"the",
"graph",
".",
"Nothing",
"happens",
"if",
"no",
"such",
"edge",
"."
] | train | https://github.com/pf4j/pf4j/blob/6dd7a6069f0e2fbd842c81e2c8c388918b88ea81/pf4j/src/main/java/org/pf4j/util/DirectedGraph.java#L75-L85 |
wso2/transport-http | components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/common/Util.java | Util.createHTTPCarbonMessage | public static HttpCarbonMessage createHTTPCarbonMessage(HttpMessage httpMessage, ChannelHandlerContext ctx) {
"""
Creates HTTP carbon message.
@param httpMessage HTTP message
@param ctx Channel handler context
@return HttpCarbonMessage
"""
Listener contentListener = new DefaultListener(ctx);
return new HttpCarbonMessage(httpMessage, contentListener);
} | java | public static HttpCarbonMessage createHTTPCarbonMessage(HttpMessage httpMessage, ChannelHandlerContext ctx) {
Listener contentListener = new DefaultListener(ctx);
return new HttpCarbonMessage(httpMessage, contentListener);
} | [
"public",
"static",
"HttpCarbonMessage",
"createHTTPCarbonMessage",
"(",
"HttpMessage",
"httpMessage",
",",
"ChannelHandlerContext",
"ctx",
")",
"{",
"Listener",
"contentListener",
"=",
"new",
"DefaultListener",
"(",
"ctx",
")",
";",
"return",
"new",
"HttpCarbonMessage",
"(",
"httpMessage",
",",
"contentListener",
")",
";",
"}"
] | Creates HTTP carbon message.
@param httpMessage HTTP message
@param ctx Channel handler context
@return HttpCarbonMessage | [
"Creates",
"HTTP",
"carbon",
"message",
"."
] | train | https://github.com/wso2/transport-http/blob/c51aa715b473db6c1b82a7d7b22f6e65f74df4c9/components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/common/Util.java#L672-L675 |
tvesalainen/util | util/src/main/java/org/vesalainen/bean/BeanHelper.java | BeanHelper.getField | public static Field getField(Class cls, String fieldname) throws NoSuchFieldException {
"""
Returns Declared field either from given class or it's super class
@param cls
@param fieldname
@return
@throws NoSuchFieldException
"""
while (true)
{
try
{
return cls.getDeclaredField(fieldname);
}
catch (NoSuchFieldException ex)
{
cls = cls.getSuperclass();
if (Object.class.equals(cls))
{
throw ex;
}
}
catch (SecurityException ex)
{
throw new IllegalArgumentException(ex);
}
}
} | java | public static Field getField(Class cls, String fieldname) throws NoSuchFieldException
{
while (true)
{
try
{
return cls.getDeclaredField(fieldname);
}
catch (NoSuchFieldException ex)
{
cls = cls.getSuperclass();
if (Object.class.equals(cls))
{
throw ex;
}
}
catch (SecurityException ex)
{
throw new IllegalArgumentException(ex);
}
}
} | [
"public",
"static",
"Field",
"getField",
"(",
"Class",
"cls",
",",
"String",
"fieldname",
")",
"throws",
"NoSuchFieldException",
"{",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"return",
"cls",
".",
"getDeclaredField",
"(",
"fieldname",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"ex",
")",
"{",
"cls",
"=",
"cls",
".",
"getSuperclass",
"(",
")",
";",
"if",
"(",
"Object",
".",
"class",
".",
"equals",
"(",
"cls",
")",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"catch",
"(",
"SecurityException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"ex",
")",
";",
"}",
"}",
"}"
] | Returns Declared field either from given class or it's super class
@param cls
@param fieldname
@return
@throws NoSuchFieldException | [
"Returns",
"Declared",
"field",
"either",
"from",
"given",
"class",
"or",
"it",
"s",
"super",
"class"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/bean/BeanHelper.java#L269-L290 |
dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/XPath.java | XPath.evalUnique | @Nullable
public final <T> T evalUnique(final Object object, final Class<T> resultClass)
throws IllegalArgumentException {
"""
Evaluates this {@code XPath} expression on the object supplied, producing as result a
unique object of the type {@code T} specified.
@param object
the object to evaluate this expression on
@param resultClass
the {@code Class} object for the result object
@param <T>
the type of result
@return on success, the unique object of the requested type resulting from the evaluation,
or null if evaluation produced no results; on failure, null is returned if this
{@code XPath} expression is lenient
@throws IllegalArgumentException
if this {@code XPath} expression is not lenient and evaluation fails for the
object supplied
"""
Preconditions.checkNotNull(object);
Preconditions.checkNotNull(resultClass);
try {
return toUnique(doEval(object), resultClass);
} catch (final Exception ex) {
if (isLenient()) {
return null;
}
throw new IllegalArgumentException("Evaluation of XPath failed: " + ex.getMessage()
+ "\nXPath is: " + this.support.string + "\nInput is: " + object
+ "\nExpected result is: " + resultClass.getSimpleName(), ex);
}
} | java | @Nullable
public final <T> T evalUnique(final Object object, final Class<T> resultClass)
throws IllegalArgumentException {
Preconditions.checkNotNull(object);
Preconditions.checkNotNull(resultClass);
try {
return toUnique(doEval(object), resultClass);
} catch (final Exception ex) {
if (isLenient()) {
return null;
}
throw new IllegalArgumentException("Evaluation of XPath failed: " + ex.getMessage()
+ "\nXPath is: " + this.support.string + "\nInput is: " + object
+ "\nExpected result is: " + resultClass.getSimpleName(), ex);
}
} | [
"@",
"Nullable",
"public",
"final",
"<",
"T",
">",
"T",
"evalUnique",
"(",
"final",
"Object",
"object",
",",
"final",
"Class",
"<",
"T",
">",
"resultClass",
")",
"throws",
"IllegalArgumentException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"object",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"resultClass",
")",
";",
"try",
"{",
"return",
"toUnique",
"(",
"doEval",
"(",
"object",
")",
",",
"resultClass",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"ex",
")",
"{",
"if",
"(",
"isLenient",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Evaluation of XPath failed: \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
"+",
"\"\\nXPath is: \"",
"+",
"this",
".",
"support",
".",
"string",
"+",
"\"\\nInput is: \"",
"+",
"object",
"+",
"\"\\nExpected result is: \"",
"+",
"resultClass",
".",
"getSimpleName",
"(",
")",
",",
"ex",
")",
";",
"}",
"}"
] | Evaluates this {@code XPath} expression on the object supplied, producing as result a
unique object of the type {@code T} specified.
@param object
the object to evaluate this expression on
@param resultClass
the {@code Class} object for the result object
@param <T>
the type of result
@return on success, the unique object of the requested type resulting from the evaluation,
or null if evaluation produced no results; on failure, null is returned if this
{@code XPath} expression is lenient
@throws IllegalArgumentException
if this {@code XPath} expression is not lenient and evaluation fails for the
object supplied | [
"Evaluates",
"this",
"{",
"@code",
"XPath",
"}",
"expression",
"on",
"the",
"object",
"supplied",
"producing",
"as",
"result",
"a",
"unique",
"object",
"of",
"the",
"type",
"{",
"@code",
"T",
"}",
"specified",
"."
] | train | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/XPath.java#L953-L971 |
lets-blade/blade | src/main/java/com/blade/kit/EncryptKit.java | EncryptKit.desTemplate | public static byte[] desTemplate(byte[] data, byte[] key, String algorithm, String transformation, boolean isEncrypt) {
"""
DES加密模板
@param data 数据
@param key 秘钥
@param algorithm 加密算法
@param transformation 转变
@param isEncrypt {@code true}: 加密 {@code false}: 解密
@return 密文或者明文,适用于DES,3DES,AES
"""
if (data == null || data.length == 0 || key == null || key.length == 0) return null;
try {
SecretKeySpec keySpec = new SecretKeySpec(key, algorithm);
Cipher cipher = Cipher.getInstance(transformation);
SecureRandom random = new SecureRandom();
cipher.init(isEncrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, keySpec, random);
return cipher.doFinal(data);
} catch (Throwable e) {
e.printStackTrace();
return null;
}
} | java | public static byte[] desTemplate(byte[] data, byte[] key, String algorithm, String transformation, boolean isEncrypt) {
if (data == null || data.length == 0 || key == null || key.length == 0) return null;
try {
SecretKeySpec keySpec = new SecretKeySpec(key, algorithm);
Cipher cipher = Cipher.getInstance(transformation);
SecureRandom random = new SecureRandom();
cipher.init(isEncrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, keySpec, random);
return cipher.doFinal(data);
} catch (Throwable e) {
e.printStackTrace();
return null;
}
} | [
"public",
"static",
"byte",
"[",
"]",
"desTemplate",
"(",
"byte",
"[",
"]",
"data",
",",
"byte",
"[",
"]",
"key",
",",
"String",
"algorithm",
",",
"String",
"transformation",
",",
"boolean",
"isEncrypt",
")",
"{",
"if",
"(",
"data",
"==",
"null",
"||",
"data",
".",
"length",
"==",
"0",
"||",
"key",
"==",
"null",
"||",
"key",
".",
"length",
"==",
"0",
")",
"return",
"null",
";",
"try",
"{",
"SecretKeySpec",
"keySpec",
"=",
"new",
"SecretKeySpec",
"(",
"key",
",",
"algorithm",
")",
";",
"Cipher",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"transformation",
")",
";",
"SecureRandom",
"random",
"=",
"new",
"SecureRandom",
"(",
")",
";",
"cipher",
".",
"init",
"(",
"isEncrypt",
"?",
"Cipher",
".",
"ENCRYPT_MODE",
":",
"Cipher",
".",
"DECRYPT_MODE",
",",
"keySpec",
",",
"random",
")",
";",
"return",
"cipher",
".",
"doFinal",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"null",
";",
"}",
"}"
] | DES加密模板
@param data 数据
@param key 秘钥
@param algorithm 加密算法
@param transformation 转变
@param isEncrypt {@code true}: 加密 {@code false}: 解密
@return 密文或者明文,适用于DES,3DES,AES | [
"DES加密模板"
] | train | https://github.com/lets-blade/blade/blob/60624ee528be12122c49a9ad1713e336b959e59a/src/main/java/com/blade/kit/EncryptKit.java#L682-L694 |
mygreen/excel-cellformatter | src/main/java/com/github/mygreen/cellformatter/ObjectCellFormatter.java | ObjectCellFormatter.formatAsString | public String formatAsString(final String formatPattern, final String value, final Locale locale) {
"""
ロケールを指定して、文字列型をフォーマットし、結果を直接文字列として取得する。
@param formatPattern フォーマットの書式。
@param value フォーマット対象の値。
@param locale ロケール。書式にロケール条件の記述(例. {@code [$-403]})が含まれている場合は、書式のロケールが優先されます。
@return フォーマットした結果の文字列。
"""
return format(formatPattern, value, locale).getText();
} | java | public String formatAsString(final String formatPattern, final String value, final Locale locale) {
return format(formatPattern, value, locale).getText();
} | [
"public",
"String",
"formatAsString",
"(",
"final",
"String",
"formatPattern",
",",
"final",
"String",
"value",
",",
"final",
"Locale",
"locale",
")",
"{",
"return",
"format",
"(",
"formatPattern",
",",
"value",
",",
"locale",
")",
".",
"getText",
"(",
")",
";",
"}"
] | ロケールを指定して、文字列型をフォーマットし、結果を直接文字列として取得する。
@param formatPattern フォーマットの書式。
@param value フォーマット対象の値。
@param locale ロケール。書式にロケール条件の記述(例. {@code [$-403]})が含まれている場合は、書式のロケールが優先されます。
@return フォーマットした結果の文字列。 | [
"ロケールを指定して、文字列型をフォーマットし、結果を直接文字列として取得する。"
] | train | https://github.com/mygreen/excel-cellformatter/blob/e802af273d49889500591e03799c9262cbf29185/src/main/java/com/github/mygreen/cellformatter/ObjectCellFormatter.java#L73-L75 |
alkacon/opencms-core | src/org/opencms/importexport/CmsExport.java | CmsExport.openExportFile | protected Element openExportFile(ExportMode exportMode) throws IOException, SAXException {
"""
Opens the export ZIP file and initializes the internal XML document for the manifest.<p>
@param exportMode the export mode to use.
@return the node in the XML document where all files are appended to
@throws SAXException if something goes wrong processing the manifest.xml
@throws IOException if something goes wrong while closing the export file
"""
// create the export writer
m_exportWriter = new CmsExportHelper(
getExportFileName(),
m_parameters.isExportAsFiles(),
m_parameters.isXmlValidation());
// initialize the dom4j writer object as member variable
setSaxWriter(m_exportWriter.getSaxWriter());
// the node in the XML document where the file entries are appended to
String exportNodeName = getExportNodeName();
// the XML document to write the XMl to
Document doc = DocumentHelper.createDocument();
// add main export node to XML document
Element exportNode = doc.addElement(exportNodeName);
getSaxWriter().writeOpen(exportNode);
// add the info element. it contains all infos for this export
Element info = exportNode.addElement(CmsImportExportManager.N_INFO);
if (!exportMode.equals(ExportMode.REDUCED)) {
info.addElement(CmsImportExportManager.N_CREATOR).addText(
getCms().getRequestContext().getCurrentUser().getName());
info.addElement(CmsImportExportManager.N_OC_VERSION).addText(OpenCms.getSystemInfo().getVersionNumber());
info.addElement(CmsImportExportManager.N_DATE).addText(
CmsDateUtil.getHeaderDate(System.currentTimeMillis()));
}
info.addElement(CmsImportExportManager.N_INFO_PROJECT).addText(
getCms().getRequestContext().getCurrentProject().getName());
info.addElement(CmsImportExportManager.N_VERSION).addText(CmsImportExportManager.EXPORT_VERSION);
// write the XML
digestElement(exportNode, info);
return exportNode;
} | java | protected Element openExportFile(ExportMode exportMode) throws IOException, SAXException {
// create the export writer
m_exportWriter = new CmsExportHelper(
getExportFileName(),
m_parameters.isExportAsFiles(),
m_parameters.isXmlValidation());
// initialize the dom4j writer object as member variable
setSaxWriter(m_exportWriter.getSaxWriter());
// the node in the XML document where the file entries are appended to
String exportNodeName = getExportNodeName();
// the XML document to write the XMl to
Document doc = DocumentHelper.createDocument();
// add main export node to XML document
Element exportNode = doc.addElement(exportNodeName);
getSaxWriter().writeOpen(exportNode);
// add the info element. it contains all infos for this export
Element info = exportNode.addElement(CmsImportExportManager.N_INFO);
if (!exportMode.equals(ExportMode.REDUCED)) {
info.addElement(CmsImportExportManager.N_CREATOR).addText(
getCms().getRequestContext().getCurrentUser().getName());
info.addElement(CmsImportExportManager.N_OC_VERSION).addText(OpenCms.getSystemInfo().getVersionNumber());
info.addElement(CmsImportExportManager.N_DATE).addText(
CmsDateUtil.getHeaderDate(System.currentTimeMillis()));
}
info.addElement(CmsImportExportManager.N_INFO_PROJECT).addText(
getCms().getRequestContext().getCurrentProject().getName());
info.addElement(CmsImportExportManager.N_VERSION).addText(CmsImportExportManager.EXPORT_VERSION);
// write the XML
digestElement(exportNode, info);
return exportNode;
} | [
"protected",
"Element",
"openExportFile",
"(",
"ExportMode",
"exportMode",
")",
"throws",
"IOException",
",",
"SAXException",
"{",
"// create the export writer",
"m_exportWriter",
"=",
"new",
"CmsExportHelper",
"(",
"getExportFileName",
"(",
")",
",",
"m_parameters",
".",
"isExportAsFiles",
"(",
")",
",",
"m_parameters",
".",
"isXmlValidation",
"(",
")",
")",
";",
"// initialize the dom4j writer object as member variable",
"setSaxWriter",
"(",
"m_exportWriter",
".",
"getSaxWriter",
"(",
")",
")",
";",
"// the node in the XML document where the file entries are appended to",
"String",
"exportNodeName",
"=",
"getExportNodeName",
"(",
")",
";",
"// the XML document to write the XMl to",
"Document",
"doc",
"=",
"DocumentHelper",
".",
"createDocument",
"(",
")",
";",
"// add main export node to XML document",
"Element",
"exportNode",
"=",
"doc",
".",
"addElement",
"(",
"exportNodeName",
")",
";",
"getSaxWriter",
"(",
")",
".",
"writeOpen",
"(",
"exportNode",
")",
";",
"// add the info element. it contains all infos for this export",
"Element",
"info",
"=",
"exportNode",
".",
"addElement",
"(",
"CmsImportExportManager",
".",
"N_INFO",
")",
";",
"if",
"(",
"!",
"exportMode",
".",
"equals",
"(",
"ExportMode",
".",
"REDUCED",
")",
")",
"{",
"info",
".",
"addElement",
"(",
"CmsImportExportManager",
".",
"N_CREATOR",
")",
".",
"addText",
"(",
"getCms",
"(",
")",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"info",
".",
"addElement",
"(",
"CmsImportExportManager",
".",
"N_OC_VERSION",
")",
".",
"addText",
"(",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getVersionNumber",
"(",
")",
")",
";",
"info",
".",
"addElement",
"(",
"CmsImportExportManager",
".",
"N_DATE",
")",
".",
"addText",
"(",
"CmsDateUtil",
".",
"getHeaderDate",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
")",
";",
"}",
"info",
".",
"addElement",
"(",
"CmsImportExportManager",
".",
"N_INFO_PROJECT",
")",
".",
"addText",
"(",
"getCms",
"(",
")",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentProject",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"info",
".",
"addElement",
"(",
"CmsImportExportManager",
".",
"N_VERSION",
")",
".",
"addText",
"(",
"CmsImportExportManager",
".",
"EXPORT_VERSION",
")",
";",
"// write the XML",
"digestElement",
"(",
"exportNode",
",",
"info",
")",
";",
"return",
"exportNode",
";",
"}"
] | Opens the export ZIP file and initializes the internal XML document for the manifest.<p>
@param exportMode the export mode to use.
@return the node in the XML document where all files are appended to
@throws SAXException if something goes wrong processing the manifest.xml
@throws IOException if something goes wrong while closing the export file | [
"Opens",
"the",
"export",
"ZIP",
"file",
"and",
"initializes",
"the",
"internal",
"XML",
"document",
"for",
"the",
"manifest",
".",
"<p",
">",
"@param",
"exportMode",
"the",
"export",
"mode",
"to",
"use",
"."
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/importexport/CmsExport.java#L1487-L1522 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/RuleBasedNumberFormat.java | RuleBasedNumberFormat.readObject | private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException {
"""
Reads this object in from a stream.
@param in The stream to read from.
"""
// read the description in from the stream
String description = in.readUTF();
ULocale loc;
try {
loc = (ULocale) in.readObject();
} catch (Exception e) {
loc = ULocale.getDefault(Category.FORMAT);
}
try {
roundingMode = in.readInt();
} catch (Exception ignored) {
}
// build a brand-new RuleBasedNumberFormat from the description,
// then steal its substructure. This object's substructure and
// the temporary RuleBasedNumberFormat drop on the floor and
// get swept up by the garbage collector
RuleBasedNumberFormat temp = new RuleBasedNumberFormat(description, loc);
ruleSets = temp.ruleSets;
ruleSetsMap = temp.ruleSetsMap;
defaultRuleSet = temp.defaultRuleSet;
publicRuleSetNames = temp.publicRuleSetNames;
decimalFormatSymbols = temp.decimalFormatSymbols;
decimalFormat = temp.decimalFormat;
locale = temp.locale;
defaultInfinityRule = temp.defaultInfinityRule;
defaultNaNRule = temp.defaultNaNRule;
} | java | private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException {
// read the description in from the stream
String description = in.readUTF();
ULocale loc;
try {
loc = (ULocale) in.readObject();
} catch (Exception e) {
loc = ULocale.getDefault(Category.FORMAT);
}
try {
roundingMode = in.readInt();
} catch (Exception ignored) {
}
// build a brand-new RuleBasedNumberFormat from the description,
// then steal its substructure. This object's substructure and
// the temporary RuleBasedNumberFormat drop on the floor and
// get swept up by the garbage collector
RuleBasedNumberFormat temp = new RuleBasedNumberFormat(description, loc);
ruleSets = temp.ruleSets;
ruleSetsMap = temp.ruleSetsMap;
defaultRuleSet = temp.defaultRuleSet;
publicRuleSetNames = temp.publicRuleSetNames;
decimalFormatSymbols = temp.decimalFormatSymbols;
decimalFormat = temp.decimalFormat;
locale = temp.locale;
defaultInfinityRule = temp.defaultInfinityRule;
defaultNaNRule = temp.defaultNaNRule;
} | [
"private",
"void",
"readObject",
"(",
"java",
".",
"io",
".",
"ObjectInputStream",
"in",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"// read the description in from the stream",
"String",
"description",
"=",
"in",
".",
"readUTF",
"(",
")",
";",
"ULocale",
"loc",
";",
"try",
"{",
"loc",
"=",
"(",
"ULocale",
")",
"in",
".",
"readObject",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"loc",
"=",
"ULocale",
".",
"getDefault",
"(",
"Category",
".",
"FORMAT",
")",
";",
"}",
"try",
"{",
"roundingMode",
"=",
"in",
".",
"readInt",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ignored",
")",
"{",
"}",
"// build a brand-new RuleBasedNumberFormat from the description,",
"// then steal its substructure. This object's substructure and",
"// the temporary RuleBasedNumberFormat drop on the floor and",
"// get swept up by the garbage collector",
"RuleBasedNumberFormat",
"temp",
"=",
"new",
"RuleBasedNumberFormat",
"(",
"description",
",",
"loc",
")",
";",
"ruleSets",
"=",
"temp",
".",
"ruleSets",
";",
"ruleSetsMap",
"=",
"temp",
".",
"ruleSetsMap",
";",
"defaultRuleSet",
"=",
"temp",
".",
"defaultRuleSet",
";",
"publicRuleSetNames",
"=",
"temp",
".",
"publicRuleSetNames",
";",
"decimalFormatSymbols",
"=",
"temp",
".",
"decimalFormatSymbols",
";",
"decimalFormat",
"=",
"temp",
".",
"decimalFormat",
";",
"locale",
"=",
"temp",
".",
"locale",
";",
"defaultInfinityRule",
"=",
"temp",
".",
"defaultInfinityRule",
";",
"defaultNaNRule",
"=",
"temp",
".",
"defaultNaNRule",
";",
"}"
] | Reads this object in from a stream.
@param in The stream to read from. | [
"Reads",
"this",
"object",
"in",
"from",
"a",
"stream",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/RuleBasedNumberFormat.java#L978-L1009 |
phax/ph-commons | ph-security/src/main/java/com/helger/security/certificate/CertificateHelper.java | CertificateHelper.convertStringToCertficate | @Nullable
public static X509Certificate convertStringToCertficate (@Nullable final String sCertString) throws CertificateException {
"""
Convert the passed String to an X.509 certificate.
@param sCertString
The original text string. May be <code>null</code> or empty. The
String must be ISO-8859-1 encoded for the binary certificate to be
read!
@return <code>null</code> if the passed string is <code>null</code> or
empty
@throws CertificateException
In case the passed string cannot be converted to an X.509
certificate.
@throws IllegalArgumentException
If the input string is e.g. invalid Base64 encoded.
"""
if (StringHelper.hasNoText (sCertString))
{
// No string -> no certificate
return null;
}
final CertificateFactory aCertificateFactory = getX509CertificateFactory ();
// Convert certificate string to an object
try
{
return _str2cert (sCertString, aCertificateFactory);
}
catch (final IllegalArgumentException | CertificateException ex)
{
// In some weird configurations, the result string is a hex encoded
// certificate instead of the string
// -> Try to work around it
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Failed to decode provided X.509 certificate string: " + sCertString);
String sHexDecodedString;
try
{
sHexDecodedString = new String (StringHelper.getHexDecoded (sCertString), CERT_CHARSET);
}
catch (final IllegalArgumentException ex2)
{
// Can happen, when the source string has an odd length (like 3 or 117).
// In this case the original exception is rethrown
throw ex;
}
return _str2cert (sHexDecodedString, aCertificateFactory);
}
} | java | @Nullable
public static X509Certificate convertStringToCertficate (@Nullable final String sCertString) throws CertificateException
{
if (StringHelper.hasNoText (sCertString))
{
// No string -> no certificate
return null;
}
final CertificateFactory aCertificateFactory = getX509CertificateFactory ();
// Convert certificate string to an object
try
{
return _str2cert (sCertString, aCertificateFactory);
}
catch (final IllegalArgumentException | CertificateException ex)
{
// In some weird configurations, the result string is a hex encoded
// certificate instead of the string
// -> Try to work around it
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Failed to decode provided X.509 certificate string: " + sCertString);
String sHexDecodedString;
try
{
sHexDecodedString = new String (StringHelper.getHexDecoded (sCertString), CERT_CHARSET);
}
catch (final IllegalArgumentException ex2)
{
// Can happen, when the source string has an odd length (like 3 or 117).
// In this case the original exception is rethrown
throw ex;
}
return _str2cert (sHexDecodedString, aCertificateFactory);
}
} | [
"@",
"Nullable",
"public",
"static",
"X509Certificate",
"convertStringToCertficate",
"(",
"@",
"Nullable",
"final",
"String",
"sCertString",
")",
"throws",
"CertificateException",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"sCertString",
")",
")",
"{",
"// No string -> no certificate",
"return",
"null",
";",
"}",
"final",
"CertificateFactory",
"aCertificateFactory",
"=",
"getX509CertificateFactory",
"(",
")",
";",
"// Convert certificate string to an object",
"try",
"{",
"return",
"_str2cert",
"(",
"sCertString",
",",
"aCertificateFactory",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"|",
"CertificateException",
"ex",
")",
"{",
"// In some weird configurations, the result string is a hex encoded",
"// certificate instead of the string",
"// -> Try to work around it",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"Failed to decode provided X.509 certificate string: \"",
"+",
"sCertString",
")",
";",
"String",
"sHexDecodedString",
";",
"try",
"{",
"sHexDecodedString",
"=",
"new",
"String",
"(",
"StringHelper",
".",
"getHexDecoded",
"(",
"sCertString",
")",
",",
"CERT_CHARSET",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"ex2",
")",
"{",
"// Can happen, when the source string has an odd length (like 3 or 117).",
"// In this case the original exception is rethrown",
"throw",
"ex",
";",
"}",
"return",
"_str2cert",
"(",
"sHexDecodedString",
",",
"aCertificateFactory",
")",
";",
"}",
"}"
] | Convert the passed String to an X.509 certificate.
@param sCertString
The original text string. May be <code>null</code> or empty. The
String must be ISO-8859-1 encoded for the binary certificate to be
read!
@return <code>null</code> if the passed string is <code>null</code> or
empty
@throws CertificateException
In case the passed string cannot be converted to an X.509
certificate.
@throws IllegalArgumentException
If the input string is e.g. invalid Base64 encoded. | [
"Convert",
"the",
"passed",
"String",
"to",
"an",
"X",
".",
"509",
"certificate",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-security/src/main/java/com/helger/security/certificate/CertificateHelper.java#L246-L284 |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/webapp/resources/OrganizationResource.java | OrganizationResource.getNames | @GET
@Produces( {
"""
Return the list of available organization name.
This method is call via GET <dm_url>/organization/names
@return Response A list of organization name in HTML or JSON
"""MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
@Path(ServerAPI.GET_NAMES)
public Response getNames(){
LOG.info("Got a get organization names request.");
final ListView view = new ListView("Organization Ids list", "Organizations");
final List<String> names = getOrganizationHandler().getOrganizationNames();
view.addAll(names);
return Response.ok(view).build();
} | java | @GET
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
@Path(ServerAPI.GET_NAMES)
public Response getNames(){
LOG.info("Got a get organization names request.");
final ListView view = new ListView("Organization Ids list", "Organizations");
final List<String> names = getOrganizationHandler().getOrganizationNames();
view.addAll(names);
return Response.ok(view).build();
} | [
"@",
"GET",
"@",
"Produces",
"(",
"{",
"MediaType",
".",
"TEXT_HTML",
",",
"MediaType",
".",
"APPLICATION_JSON",
"}",
")",
"@",
"Path",
"(",
"ServerAPI",
".",
"GET_NAMES",
")",
"public",
"Response",
"getNames",
"(",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Got a get organization names request.\"",
")",
";",
"final",
"ListView",
"view",
"=",
"new",
"ListView",
"(",
"\"Organization Ids list\"",
",",
"\"Organizations\"",
")",
";",
"final",
"List",
"<",
"String",
">",
"names",
"=",
"getOrganizationHandler",
"(",
")",
".",
"getOrganizationNames",
"(",
")",
";",
"view",
".",
"addAll",
"(",
"names",
")",
";",
"return",
"Response",
".",
"ok",
"(",
"view",
")",
".",
"build",
"(",
")",
";",
"}"
] | Return the list of available organization name.
This method is call via GET <dm_url>/organization/names
@return Response A list of organization name in HTML or JSON | [
"Return",
"the",
"list",
"of",
"available",
"organization",
"name",
".",
"This",
"method",
"is",
"call",
"via",
"GET",
"<dm_url",
">",
"/",
"organization",
"/",
"names"
] | train | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/resources/OrganizationResource.java#L69-L80 |
Waikato/moa | moa/src/main/java/moa/clusterers/dstream/CharacteristicVector.java | CharacteristicVector.updateGridDensity | public void updateGridDensity(int currTime, double decayFactor, double dl, double dm) {
"""
Implements the update the density of all grids step given at line 2 of
both Fig 3 and Fig 4 of Chen and Tu 2007.
@param currTime the data stream's current internal time
@param decayFactor the value of lambda
@param dl the threshold for sparse grids
@param dm the threshold for dense grids
@param addRecord TRUE if a record has been added to the density grid, FALSE otherwise
"""
// record the last attribute
int lastAtt = this.getAttribute();
// Update the density grid's density
double densityOfG = (Math.pow(decayFactor, (currTime-this.getDensityTimeStamp())) * this.getGridDensity());
this.setGridDensity(densityOfG, currTime);
// Evaluate whether or not the density grid is now SPARSE, DENSE or TRANSITIONAL
if (this.isSparse(dl))
this.attribute = SPARSE;
else if (this.isDense(dm))
this.attribute = DENSE;
else
this.attribute = TRANSITIONAL;
// Evaluate whether or not the density grid attribute has changed and set the attChange flag accordingly
if (this.getAttribute() == lastAtt)
this.attChange = false;
else
this.attChange = true;
} | java | public void updateGridDensity(int currTime, double decayFactor, double dl, double dm)
{
// record the last attribute
int lastAtt = this.getAttribute();
// Update the density grid's density
double densityOfG = (Math.pow(decayFactor, (currTime-this.getDensityTimeStamp())) * this.getGridDensity());
this.setGridDensity(densityOfG, currTime);
// Evaluate whether or not the density grid is now SPARSE, DENSE or TRANSITIONAL
if (this.isSparse(dl))
this.attribute = SPARSE;
else if (this.isDense(dm))
this.attribute = DENSE;
else
this.attribute = TRANSITIONAL;
// Evaluate whether or not the density grid attribute has changed and set the attChange flag accordingly
if (this.getAttribute() == lastAtt)
this.attChange = false;
else
this.attChange = true;
} | [
"public",
"void",
"updateGridDensity",
"(",
"int",
"currTime",
",",
"double",
"decayFactor",
",",
"double",
"dl",
",",
"double",
"dm",
")",
"{",
"// record the last attribute",
"int",
"lastAtt",
"=",
"this",
".",
"getAttribute",
"(",
")",
";",
"// Update the density grid's density",
"double",
"densityOfG",
"=",
"(",
"Math",
".",
"pow",
"(",
"decayFactor",
",",
"(",
"currTime",
"-",
"this",
".",
"getDensityTimeStamp",
"(",
")",
")",
")",
"*",
"this",
".",
"getGridDensity",
"(",
")",
")",
";",
"this",
".",
"setGridDensity",
"(",
"densityOfG",
",",
"currTime",
")",
";",
"// Evaluate whether or not the density grid is now SPARSE, DENSE or TRANSITIONAL",
"if",
"(",
"this",
".",
"isSparse",
"(",
"dl",
")",
")",
"this",
".",
"attribute",
"=",
"SPARSE",
";",
"else",
"if",
"(",
"this",
".",
"isDense",
"(",
"dm",
")",
")",
"this",
".",
"attribute",
"=",
"DENSE",
";",
"else",
"this",
".",
"attribute",
"=",
"TRANSITIONAL",
";",
"// Evaluate whether or not the density grid attribute has changed and set the attChange flag accordingly",
"if",
"(",
"this",
".",
"getAttribute",
"(",
")",
"==",
"lastAtt",
")",
"this",
".",
"attChange",
"=",
"false",
";",
"else",
"this",
".",
"attChange",
"=",
"true",
";",
"}"
] | Implements the update the density of all grids step given at line 2 of
both Fig 3 and Fig 4 of Chen and Tu 2007.
@param currTime the data stream's current internal time
@param decayFactor the value of lambda
@param dl the threshold for sparse grids
@param dm the threshold for dense grids
@param addRecord TRUE if a record has been added to the density grid, FALSE otherwise | [
"Implements",
"the",
"update",
"the",
"density",
"of",
"all",
"grids",
"step",
"given",
"at",
"line",
"2",
"of",
"both",
"Fig",
"3",
"and",
"Fig",
"4",
"of",
"Chen",
"and",
"Tu",
"2007",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/clusterers/dstream/CharacteristicVector.java#L235-L258 |
PistoiaHELM/HELM2NotationToolkit | src/main/java/org/helm/notation2/tools/BuilderMolecule.java | BuilderMolecule.buildMoleculefromCHEM | private static RgroupStructure buildMoleculefromCHEM(final String id, final List<Monomer> validMonomers) throws BuilderMoleculeException, ChemistryException {
"""
method to build a molecule from a chemical component
@param validMonomers all valid monomers of the chemical component
@return Built Molecule
@throws BuilderMoleculeException if the polymer contains more than one
monomer or if the molecule can't be built
@throws ChemistryException if the Chemistry Engine can not be initialized
"""
LOG.info("Build molecule for chemical component");
/* a chemical molecule should only contain one monomer */
if (validMonomers.size() == 1) {
try {
Monomer monomer = validMonomers.get(0);
String input = getInput(monomer);
if (input != null) {
/* Build monomer + Rgroup information! */
List<Attachment> listAttachments = monomer.getAttachmentList();
AttachmentList list = new AttachmentList();
for (Attachment attachment : listAttachments) {
list.add(new org.helm.chemtoolkit.Attachment(attachment.getAlternateId(), attachment.getLabel(), attachment.getCapGroupName(), attachment.getCapGroupSMILES()));
}
AbstractMolecule molecule = Chemistry.getInstance().getManipulator().getMolecule(input, list);
RgroupStructure result = new RgroupStructure();
result.setMolecule(molecule);
result.setRgroupMap(generateRgroupMap(id + ":" + "1", molecule));
return result;
} else {
LOG.error("Chemical molecule should have canonical smiles");
throw new BuilderMoleculeException("Chemical molecule should have canoncial smiles");
}
} catch (NullPointerException ex) {
throw new BuilderMoleculeException("Monomer is not stored in the monomer database");
} catch (IOException | CTKException e) {
LOG.error("Molecule can't be built " + e.getMessage());
throw new BuilderMoleculeException("Molecule can't be built " + e.getMessage());
}
} else {
LOG.error("Chemical molecule should contain exactly one monomer");
throw new BuilderMoleculeException("Chemical molecule should contain exactly one monomer");
}
} | java | private static RgroupStructure buildMoleculefromCHEM(final String id, final List<Monomer> validMonomers) throws BuilderMoleculeException, ChemistryException {
LOG.info("Build molecule for chemical component");
/* a chemical molecule should only contain one monomer */
if (validMonomers.size() == 1) {
try {
Monomer monomer = validMonomers.get(0);
String input = getInput(monomer);
if (input != null) {
/* Build monomer + Rgroup information! */
List<Attachment> listAttachments = monomer.getAttachmentList();
AttachmentList list = new AttachmentList();
for (Attachment attachment : listAttachments) {
list.add(new org.helm.chemtoolkit.Attachment(attachment.getAlternateId(), attachment.getLabel(), attachment.getCapGroupName(), attachment.getCapGroupSMILES()));
}
AbstractMolecule molecule = Chemistry.getInstance().getManipulator().getMolecule(input, list);
RgroupStructure result = new RgroupStructure();
result.setMolecule(molecule);
result.setRgroupMap(generateRgroupMap(id + ":" + "1", molecule));
return result;
} else {
LOG.error("Chemical molecule should have canonical smiles");
throw new BuilderMoleculeException("Chemical molecule should have canoncial smiles");
}
} catch (NullPointerException ex) {
throw new BuilderMoleculeException("Monomer is not stored in the monomer database");
} catch (IOException | CTKException e) {
LOG.error("Molecule can't be built " + e.getMessage());
throw new BuilderMoleculeException("Molecule can't be built " + e.getMessage());
}
} else {
LOG.error("Chemical molecule should contain exactly one monomer");
throw new BuilderMoleculeException("Chemical molecule should contain exactly one monomer");
}
} | [
"private",
"static",
"RgroupStructure",
"buildMoleculefromCHEM",
"(",
"final",
"String",
"id",
",",
"final",
"List",
"<",
"Monomer",
">",
"validMonomers",
")",
"throws",
"BuilderMoleculeException",
",",
"ChemistryException",
"{",
"LOG",
".",
"info",
"(",
"\"Build molecule for chemical component\"",
")",
";",
"/* a chemical molecule should only contain one monomer */",
"if",
"(",
"validMonomers",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"try",
"{",
"Monomer",
"monomer",
"=",
"validMonomers",
".",
"get",
"(",
"0",
")",
";",
"String",
"input",
"=",
"getInput",
"(",
"monomer",
")",
";",
"if",
"(",
"input",
"!=",
"null",
")",
"{",
"/* Build monomer + Rgroup information! */",
"List",
"<",
"Attachment",
">",
"listAttachments",
"=",
"monomer",
".",
"getAttachmentList",
"(",
")",
";",
"AttachmentList",
"list",
"=",
"new",
"AttachmentList",
"(",
")",
";",
"for",
"(",
"Attachment",
"attachment",
":",
"listAttachments",
")",
"{",
"list",
".",
"add",
"(",
"new",
"org",
".",
"helm",
".",
"chemtoolkit",
".",
"Attachment",
"(",
"attachment",
".",
"getAlternateId",
"(",
")",
",",
"attachment",
".",
"getLabel",
"(",
")",
",",
"attachment",
".",
"getCapGroupName",
"(",
")",
",",
"attachment",
".",
"getCapGroupSMILES",
"(",
")",
")",
")",
";",
"}",
"AbstractMolecule",
"molecule",
"=",
"Chemistry",
".",
"getInstance",
"(",
")",
".",
"getManipulator",
"(",
")",
".",
"getMolecule",
"(",
"input",
",",
"list",
")",
";",
"RgroupStructure",
"result",
"=",
"new",
"RgroupStructure",
"(",
")",
";",
"result",
".",
"setMolecule",
"(",
"molecule",
")",
";",
"result",
".",
"setRgroupMap",
"(",
"generateRgroupMap",
"(",
"id",
"+",
"\":\"",
"+",
"\"1\"",
",",
"molecule",
")",
")",
";",
"return",
"result",
";",
"}",
"else",
"{",
"LOG",
".",
"error",
"(",
"\"Chemical molecule should have canonical smiles\"",
")",
";",
"throw",
"new",
"BuilderMoleculeException",
"(",
"\"Chemical molecule should have canoncial smiles\"",
")",
";",
"}",
"}",
"catch",
"(",
"NullPointerException",
"ex",
")",
"{",
"throw",
"new",
"BuilderMoleculeException",
"(",
"\"Monomer is not stored in the monomer database\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"CTKException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Molecule can't be built \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"throw",
"new",
"BuilderMoleculeException",
"(",
"\"Molecule can't be built \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"LOG",
".",
"error",
"(",
"\"Chemical molecule should contain exactly one monomer\"",
")",
";",
"throw",
"new",
"BuilderMoleculeException",
"(",
"\"Chemical molecule should contain exactly one monomer\"",
")",
";",
"}",
"}"
] | method to build a molecule from a chemical component
@param validMonomers all valid monomers of the chemical component
@return Built Molecule
@throws BuilderMoleculeException if the polymer contains more than one
monomer or if the molecule can't be built
@throws ChemistryException if the Chemistry Engine can not be initialized | [
"method",
"to",
"build",
"a",
"molecule",
"from",
"a",
"chemical",
"component"
] | train | https://github.com/PistoiaHELM/HELM2NotationToolkit/blob/ac5bb01fd5b4082134a8ef226bbe2ff0f60fcd38/src/main/java/org/helm/notation2/tools/BuilderMolecule.java#L261-L297 |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java | ClassUtils.collectFields | public static Field[] collectFields(Class<?> c, int inclusiveModifiers, int exclusiveModifiers) {
"""
Produces an array with all the instance fields of the specified class which match the supplied rules
@param c The class specified
@param inclusiveModifiers An int indicating the {@link Modifier}s that may be applied
@param exclusiveModifiers An int indicating the {@link Modifier}s that must be excluded
@return The array of matched Fields
"""
return collectFields(c, inclusiveModifiers, exclusiveModifiers, Object.class);
} | java | public static Field[] collectFields(Class<?> c, int inclusiveModifiers, int exclusiveModifiers) {
return collectFields(c, inclusiveModifiers, exclusiveModifiers, Object.class);
} | [
"public",
"static",
"Field",
"[",
"]",
"collectFields",
"(",
"Class",
"<",
"?",
">",
"c",
",",
"int",
"inclusiveModifiers",
",",
"int",
"exclusiveModifiers",
")",
"{",
"return",
"collectFields",
"(",
"c",
",",
"inclusiveModifiers",
",",
"exclusiveModifiers",
",",
"Object",
".",
"class",
")",
";",
"}"
] | Produces an array with all the instance fields of the specified class which match the supplied rules
@param c The class specified
@param inclusiveModifiers An int indicating the {@link Modifier}s that may be applied
@param exclusiveModifiers An int indicating the {@link Modifier}s that must be excluded
@return The array of matched Fields | [
"Produces",
"an",
"array",
"with",
"all",
"the",
"instance",
"fields",
"of",
"the",
"specified",
"class",
"which",
"match",
"the",
"supplied",
"rules"
] | train | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java#L203-L206 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/math/Fraction.java | Fraction.multiplyBy | public Fraction multiplyBy(final Fraction fraction) {
"""
<p>Multiplies the value of this fraction by another, returning the
result in reduced form.</p>
@param fraction the fraction to multiply by, must not be <code>null</code>
@return a <code>Fraction</code> instance with the resulting values
@throws IllegalArgumentException if the fraction is <code>null</code>
@throws ArithmeticException if the resulting numerator or denominator exceeds
<code>Integer.MAX_VALUE</code>
"""
Validate.isTrue(fraction != null, "The fraction must not be null");
if (numerator == 0 || fraction.numerator == 0) {
return ZERO;
}
// knuth 4.5.1
// make sure we don't overflow unless the result *must* overflow.
final int d1 = greatestCommonDivisor(numerator, fraction.denominator);
final int d2 = greatestCommonDivisor(fraction.numerator, denominator);
return getReducedFraction(mulAndCheck(numerator / d1, fraction.numerator / d2),
mulPosAndCheck(denominator / d2, fraction.denominator / d1));
} | java | public Fraction multiplyBy(final Fraction fraction) {
Validate.isTrue(fraction != null, "The fraction must not be null");
if (numerator == 0 || fraction.numerator == 0) {
return ZERO;
}
// knuth 4.5.1
// make sure we don't overflow unless the result *must* overflow.
final int d1 = greatestCommonDivisor(numerator, fraction.denominator);
final int d2 = greatestCommonDivisor(fraction.numerator, denominator);
return getReducedFraction(mulAndCheck(numerator / d1, fraction.numerator / d2),
mulPosAndCheck(denominator / d2, fraction.denominator / d1));
} | [
"public",
"Fraction",
"multiplyBy",
"(",
"final",
"Fraction",
"fraction",
")",
"{",
"Validate",
".",
"isTrue",
"(",
"fraction",
"!=",
"null",
",",
"\"The fraction must not be null\"",
")",
";",
"if",
"(",
"numerator",
"==",
"0",
"||",
"fraction",
".",
"numerator",
"==",
"0",
")",
"{",
"return",
"ZERO",
";",
"}",
"// knuth 4.5.1",
"// make sure we don't overflow unless the result *must* overflow.",
"final",
"int",
"d1",
"=",
"greatestCommonDivisor",
"(",
"numerator",
",",
"fraction",
".",
"denominator",
")",
";",
"final",
"int",
"d2",
"=",
"greatestCommonDivisor",
"(",
"fraction",
".",
"numerator",
",",
"denominator",
")",
";",
"return",
"getReducedFraction",
"(",
"mulAndCheck",
"(",
"numerator",
"/",
"d1",
",",
"fraction",
".",
"numerator",
"/",
"d2",
")",
",",
"mulPosAndCheck",
"(",
"denominator",
"/",
"d2",
",",
"fraction",
".",
"denominator",
"/",
"d1",
")",
")",
";",
"}"
] | <p>Multiplies the value of this fraction by another, returning the
result in reduced form.</p>
@param fraction the fraction to multiply by, must not be <code>null</code>
@return a <code>Fraction</code> instance with the resulting values
@throws IllegalArgumentException if the fraction is <code>null</code>
@throws ArithmeticException if the resulting numerator or denominator exceeds
<code>Integer.MAX_VALUE</code> | [
"<p",
">",
"Multiplies",
"the",
"value",
"of",
"this",
"fraction",
"by",
"another",
"returning",
"the",
"result",
"in",
"reduced",
"form",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/math/Fraction.java#L783-L794 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/mult/VectorVectorMult_DDRM.java | VectorVectorMult_DDRM.innerProd | public static double innerProd(DMatrixD1 x, DMatrixD1 y ) {
"""
<p>
Computes the inner product of the two vectors. In geometry this is known as the dot product.<br>
<br>
∑<sub>k=1:n</sub> x<sub>k</sub> * y<sub>k</sub><br>
where x and y are vectors with n elements.
</p>
<p>
These functions are often used inside of highly optimized code and therefor sanity checks are
kept to a minimum. It is not recommended that any of these functions be used directly.
</p>
@param x A vector with n elements. Not modified.
@param y A vector with n elements. Not modified.
@return The inner product of the two vectors.
"""
int m = x.getNumElements();
double total = 0;
for( int i = 0; i < m; i++ ) {
total += x.get(i) * y.get(i);
}
return total;
} | java | public static double innerProd(DMatrixD1 x, DMatrixD1 y )
{
int m = x.getNumElements();
double total = 0;
for( int i = 0; i < m; i++ ) {
total += x.get(i) * y.get(i);
}
return total;
} | [
"public",
"static",
"double",
"innerProd",
"(",
"DMatrixD1",
"x",
",",
"DMatrixD1",
"y",
")",
"{",
"int",
"m",
"=",
"x",
".",
"getNumElements",
"(",
")",
";",
"double",
"total",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m",
";",
"i",
"++",
")",
"{",
"total",
"+=",
"x",
".",
"get",
"(",
"i",
")",
"*",
"y",
".",
"get",
"(",
"i",
")",
";",
"}",
"return",
"total",
";",
"}"
] | <p>
Computes the inner product of the two vectors. In geometry this is known as the dot product.<br>
<br>
∑<sub>k=1:n</sub> x<sub>k</sub> * y<sub>k</sub><br>
where x and y are vectors with n elements.
</p>
<p>
These functions are often used inside of highly optimized code and therefor sanity checks are
kept to a minimum. It is not recommended that any of these functions be used directly.
</p>
@param x A vector with n elements. Not modified.
@param y A vector with n elements. Not modified.
@return The inner product of the two vectors. | [
"<p",
">",
"Computes",
"the",
"inner",
"product",
"of",
"the",
"two",
"vectors",
".",
"In",
"geometry",
"this",
"is",
"known",
"as",
"the",
"dot",
"product",
".",
"<br",
">",
"<br",
">",
"&sum",
";",
"<sub",
">",
"k",
"=",
"1",
":",
"n<",
"/",
"sub",
">",
"x<sub",
">",
"k<",
"/",
"sub",
">",
"*",
"y<sub",
">",
"k<",
"/",
"sub",
">",
"<br",
">",
"where",
"x",
"and",
"y",
"are",
"vectors",
"with",
"n",
"elements",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/mult/VectorVectorMult_DDRM.java#L50-L60 |
google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java | ClassFile.getMethod | public MethodDeclaration getMethod(String name, String signature) {
"""
Returns the Procyon method definition for a specified method,
or null if not found.
"""
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.METHOD) {
MethodDeclaration method = (MethodDeclaration) node;
if (method.getName().equals(name) && signature.equals(signature(method))) {
return method;
}
}
}
return null;
} | java | public MethodDeclaration getMethod(String name, String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.METHOD) {
MethodDeclaration method = (MethodDeclaration) node;
if (method.getName().equals(name) && signature.equals(signature(method))) {
return method;
}
}
}
return null;
} | [
"public",
"MethodDeclaration",
"getMethod",
"(",
"String",
"name",
",",
"String",
"signature",
")",
"{",
"for",
"(",
"EntityDeclaration",
"node",
":",
"type",
".",
"getMembers",
"(",
")",
")",
"{",
"if",
"(",
"node",
".",
"getEntityType",
"(",
")",
"==",
"EntityType",
".",
"METHOD",
")",
"{",
"MethodDeclaration",
"method",
"=",
"(",
"MethodDeclaration",
")",
"node",
";",
"if",
"(",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
"&&",
"signature",
".",
"equals",
"(",
"signature",
"(",
"method",
")",
")",
")",
"{",
"return",
"method",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the Procyon method definition for a specified method,
or null if not found. | [
"Returns",
"the",
"Procyon",
"method",
"definition",
"for",
"a",
"specified",
"method",
"or",
"null",
"if",
"not",
"found",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java#L160-L170 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/DiagnosticsInner.java | DiagnosticsInner.executeSiteDetector | public DiagnosticDetectorResponseInner executeSiteDetector(String resourceGroupName, String siteName, String detectorName, String diagnosticCategory, DateTime startTime, DateTime endTime, String timeGrain) {
"""
Execute Detector.
Execute Detector.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param siteName Site Name
@param detectorName Detector Resource Name
@param diagnosticCategory Category Name
@param startTime Start Time
@param endTime End Time
@param timeGrain Time Grain
@throws IllegalArgumentException thrown if parameters fail the validation
@throws DefaultErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DiagnosticDetectorResponseInner object if successful.
"""
return executeSiteDetectorWithServiceResponseAsync(resourceGroupName, siteName, detectorName, diagnosticCategory, startTime, endTime, timeGrain).toBlocking().single().body();
} | java | public DiagnosticDetectorResponseInner executeSiteDetector(String resourceGroupName, String siteName, String detectorName, String diagnosticCategory, DateTime startTime, DateTime endTime, String timeGrain) {
return executeSiteDetectorWithServiceResponseAsync(resourceGroupName, siteName, detectorName, diagnosticCategory, startTime, endTime, timeGrain).toBlocking().single().body();
} | [
"public",
"DiagnosticDetectorResponseInner",
"executeSiteDetector",
"(",
"String",
"resourceGroupName",
",",
"String",
"siteName",
",",
"String",
"detectorName",
",",
"String",
"diagnosticCategory",
",",
"DateTime",
"startTime",
",",
"DateTime",
"endTime",
",",
"String",
"timeGrain",
")",
"{",
"return",
"executeSiteDetectorWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"siteName",
",",
"detectorName",
",",
"diagnosticCategory",
",",
"startTime",
",",
"endTime",
",",
"timeGrain",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Execute Detector.
Execute Detector.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param siteName Site Name
@param detectorName Detector Resource Name
@param diagnosticCategory Category Name
@param startTime Start Time
@param endTime End Time
@param timeGrain Time Grain
@throws IllegalArgumentException thrown if parameters fail the validation
@throws DefaultErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DiagnosticDetectorResponseInner object if successful. | [
"Execute",
"Detector",
".",
"Execute",
"Detector",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/DiagnosticsInner.java#L1237-L1239 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/impl/SparkListenable.java | SparkListenable.setListeners | public void setListeners(StatsStorageRouter statsStorage, TrainingListener... listeners) {
"""
Set the listeners, along with a StatsStorageRouter that the results will be shuffled to (in the
case of any listeners that implement the {@link RoutingIterationListener} interface)
@param statsStorage Stats storage router to place the results into
@param listeners Listeners to set
"""
setListeners(statsStorage, Arrays.asList(listeners));
} | java | public void setListeners(StatsStorageRouter statsStorage, TrainingListener... listeners) {
setListeners(statsStorage, Arrays.asList(listeners));
} | [
"public",
"void",
"setListeners",
"(",
"StatsStorageRouter",
"statsStorage",
",",
"TrainingListener",
"...",
"listeners",
")",
"{",
"setListeners",
"(",
"statsStorage",
",",
"Arrays",
".",
"asList",
"(",
"listeners",
")",
")",
";",
"}"
] | Set the listeners, along with a StatsStorageRouter that the results will be shuffled to (in the
case of any listeners that implement the {@link RoutingIterationListener} interface)
@param statsStorage Stats storage router to place the results into
@param listeners Listeners to set | [
"Set",
"the",
"listeners",
"along",
"with",
"a",
"StatsStorageRouter",
"that",
"the",
"results",
"will",
"be",
"shuffled",
"to",
"(",
"in",
"the",
"case",
"of",
"any",
"listeners",
"that",
"implement",
"the",
"{",
"@link",
"RoutingIterationListener",
"}",
"interface",
")"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/impl/SparkListenable.java#L72-L74 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java | ResourceGroovyMethods.newInputStream | public static BufferedInputStream newInputStream(URL url) throws MalformedURLException, IOException {
"""
Creates a buffered input stream for this URL.
@param url a URL
@return a BufferedInputStream for the URL
@throws MalformedURLException is thrown if the URL is not well formed
@throws IOException if an I/O error occurs while creating the input stream
@since 1.5.2
"""
return new BufferedInputStream(configuredInputStream(null, url));
} | java | public static BufferedInputStream newInputStream(URL url) throws MalformedURLException, IOException {
return new BufferedInputStream(configuredInputStream(null, url));
} | [
"public",
"static",
"BufferedInputStream",
"newInputStream",
"(",
"URL",
"url",
")",
"throws",
"MalformedURLException",
",",
"IOException",
"{",
"return",
"new",
"BufferedInputStream",
"(",
"configuredInputStream",
"(",
"null",
",",
"url",
")",
")",
";",
"}"
] | Creates a buffered input stream for this URL.
@param url a URL
@return a BufferedInputStream for the URL
@throws MalformedURLException is thrown if the URL is not well formed
@throws IOException if an I/O error occurs while creating the input stream
@since 1.5.2 | [
"Creates",
"a",
"buffered",
"input",
"stream",
"for",
"this",
"URL",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L2195-L2197 |
j-easy/easy-random | easy-random-core/src/main/java/org/jeasy/random/EasyRandomParameters.java | EasyRandomParameters.timeRange | public EasyRandomParameters timeRange(final LocalTime min, final LocalTime max) {
"""
Set the time range.
@param min time
@param max time
@return the current {@link EasyRandomParameters} instance for method chaining
"""
if (min.isAfter(max)) {
throw new IllegalArgumentException("Min time should be before max time");
}
setTimeRange(new Range<>(min, max));
return this;
} | java | public EasyRandomParameters timeRange(final LocalTime min, final LocalTime max) {
if (min.isAfter(max)) {
throw new IllegalArgumentException("Min time should be before max time");
}
setTimeRange(new Range<>(min, max));
return this;
} | [
"public",
"EasyRandomParameters",
"timeRange",
"(",
"final",
"LocalTime",
"min",
",",
"final",
"LocalTime",
"max",
")",
"{",
"if",
"(",
"min",
".",
"isAfter",
"(",
"max",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Min time should be before max time\"",
")",
";",
"}",
"setTimeRange",
"(",
"new",
"Range",
"<>",
"(",
"min",
",",
"max",
")",
")",
";",
"return",
"this",
";",
"}"
] | Set the time range.
@param min time
@param max time
@return the current {@link EasyRandomParameters} instance for method chaining | [
"Set",
"the",
"time",
"range",
"."
] | train | https://github.com/j-easy/easy-random/blob/816b0d6a74c7288af111e70ae1b0b57d7fe3b59d/easy-random-core/src/main/java/org/jeasy/random/EasyRandomParameters.java#L470-L476 |
roboconf/roboconf-platform | miscellaneous/roboconf-swagger/src/main/java/net/roboconf/swagger/UpdateSwaggerJson.java | UpdateSwaggerJson.convertToTypes | public void convertToTypes( String serialization, Class<?> clazz, JsonObject newDef ) {
"""
Creates a JSon object from a serialization result.
@param serialization the serialization result
@param clazz the class for which this serialization was made
@param newDef the new definition object to update
"""
convertToTypes( serialization, clazz.getSimpleName(), newDef );
this.processedClasses.add( clazz );
} | java | public void convertToTypes( String serialization, Class<?> clazz, JsonObject newDef ) {
convertToTypes( serialization, clazz.getSimpleName(), newDef );
this.processedClasses.add( clazz );
} | [
"public",
"void",
"convertToTypes",
"(",
"String",
"serialization",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"JsonObject",
"newDef",
")",
"{",
"convertToTypes",
"(",
"serialization",
",",
"clazz",
".",
"getSimpleName",
"(",
")",
",",
"newDef",
")",
";",
"this",
".",
"processedClasses",
".",
"add",
"(",
"clazz",
")",
";",
"}"
] | Creates a JSon object from a serialization result.
@param serialization the serialization result
@param clazz the class for which this serialization was made
@param newDef the new definition object to update | [
"Creates",
"a",
"JSon",
"object",
"from",
"a",
"serialization",
"result",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-swagger/src/main/java/net/roboconf/swagger/UpdateSwaggerJson.java#L295-L298 |
apache/fluo | modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java | CuratorUtil.startAppIdWatcher | public static NodeCache startAppIdWatcher(Environment env) {
"""
Start watching the fluo app uuid. If it changes or goes away then halt the process.
"""
try {
CuratorFramework curator = env.getSharedResources().getCurator();
byte[] uuidBytes = curator.getData().forPath(ZookeeperPath.CONFIG_FLUO_APPLICATION_ID);
if (uuidBytes == null) {
Halt.halt("Fluo Application UUID not found");
throw new RuntimeException(); // make findbugs happy
}
final String uuid = new String(uuidBytes, StandardCharsets.UTF_8);
final NodeCache nodeCache = new NodeCache(curator, ZookeeperPath.CONFIG_FLUO_APPLICATION_ID);
nodeCache.getListenable().addListener(() -> {
ChildData node = nodeCache.getCurrentData();
if (node == null || !uuid.equals(new String(node.getData(), StandardCharsets.UTF_8))) {
Halt.halt("Fluo Application UUID has changed or disappeared");
}
});
nodeCache.start();
return nodeCache;
} catch (Exception e) {
throw new RuntimeException(e);
}
} | java | public static NodeCache startAppIdWatcher(Environment env) {
try {
CuratorFramework curator = env.getSharedResources().getCurator();
byte[] uuidBytes = curator.getData().forPath(ZookeeperPath.CONFIG_FLUO_APPLICATION_ID);
if (uuidBytes == null) {
Halt.halt("Fluo Application UUID not found");
throw new RuntimeException(); // make findbugs happy
}
final String uuid = new String(uuidBytes, StandardCharsets.UTF_8);
final NodeCache nodeCache = new NodeCache(curator, ZookeeperPath.CONFIG_FLUO_APPLICATION_ID);
nodeCache.getListenable().addListener(() -> {
ChildData node = nodeCache.getCurrentData();
if (node == null || !uuid.equals(new String(node.getData(), StandardCharsets.UTF_8))) {
Halt.halt("Fluo Application UUID has changed or disappeared");
}
});
nodeCache.start();
return nodeCache;
} catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"NodeCache",
"startAppIdWatcher",
"(",
"Environment",
"env",
")",
"{",
"try",
"{",
"CuratorFramework",
"curator",
"=",
"env",
".",
"getSharedResources",
"(",
")",
".",
"getCurator",
"(",
")",
";",
"byte",
"[",
"]",
"uuidBytes",
"=",
"curator",
".",
"getData",
"(",
")",
".",
"forPath",
"(",
"ZookeeperPath",
".",
"CONFIG_FLUO_APPLICATION_ID",
")",
";",
"if",
"(",
"uuidBytes",
"==",
"null",
")",
"{",
"Halt",
".",
"halt",
"(",
"\"Fluo Application UUID not found\"",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"// make findbugs happy",
"}",
"final",
"String",
"uuid",
"=",
"new",
"String",
"(",
"uuidBytes",
",",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"final",
"NodeCache",
"nodeCache",
"=",
"new",
"NodeCache",
"(",
"curator",
",",
"ZookeeperPath",
".",
"CONFIG_FLUO_APPLICATION_ID",
")",
";",
"nodeCache",
".",
"getListenable",
"(",
")",
".",
"addListener",
"(",
"(",
")",
"->",
"{",
"ChildData",
"node",
"=",
"nodeCache",
".",
"getCurrentData",
"(",
")",
";",
"if",
"(",
"node",
"==",
"null",
"||",
"!",
"uuid",
".",
"equals",
"(",
"new",
"String",
"(",
"node",
".",
"getData",
"(",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
")",
"{",
"Halt",
".",
"halt",
"(",
"\"Fluo Application UUID has changed or disappeared\"",
")",
";",
"}",
"}",
")",
";",
"nodeCache",
".",
"start",
"(",
")",
";",
"return",
"nodeCache",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Start watching the fluo app uuid. If it changes or goes away then halt the process. | [
"Start",
"watching",
"the",
"fluo",
"app",
"uuid",
".",
"If",
"it",
"changes",
"or",
"goes",
"away",
"then",
"halt",
"the",
"process",
"."
] | train | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java#L182-L206 |
RestComm/sip-servlets | containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipNamingContextListener.java | SipNamingContextListener.removeSipFactory | public static void removeSipFactory(Context envCtx, String appName, SipFactory sipFactory) {
"""
Removes the sip factory binding from the jndi mapping
@param appName the application name subcontext
@param sipFactory the sip factory to remove
"""
if(envCtx != null) {
try {
javax.naming.Context sipContext = (javax.naming.Context)envCtx.lookup(SIP_SUBCONTEXT + "/" + appName);
sipContext.unbind(SIP_FACTORY_JNDI_NAME);
} catch (NamingException e) {
logger.error(sm.getString("naming.unbindFailed", e));
}
}
} | java | public static void removeSipFactory(Context envCtx, String appName, SipFactory sipFactory) {
if(envCtx != null) {
try {
javax.naming.Context sipContext = (javax.naming.Context)envCtx.lookup(SIP_SUBCONTEXT + "/" + appName);
sipContext.unbind(SIP_FACTORY_JNDI_NAME);
} catch (NamingException e) {
logger.error(sm.getString("naming.unbindFailed", e));
}
}
} | [
"public",
"static",
"void",
"removeSipFactory",
"(",
"Context",
"envCtx",
",",
"String",
"appName",
",",
"SipFactory",
"sipFactory",
")",
"{",
"if",
"(",
"envCtx",
"!=",
"null",
")",
"{",
"try",
"{",
"javax",
".",
"naming",
".",
"Context",
"sipContext",
"=",
"(",
"javax",
".",
"naming",
".",
"Context",
")",
"envCtx",
".",
"lookup",
"(",
"SIP_SUBCONTEXT",
"+",
"\"/\"",
"+",
"appName",
")",
";",
"sipContext",
".",
"unbind",
"(",
"SIP_FACTORY_JNDI_NAME",
")",
";",
"}",
"catch",
"(",
"NamingException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"sm",
".",
"getString",
"(",
"\"naming.unbindFailed\"",
",",
"e",
")",
")",
";",
"}",
"}",
"}"
] | Removes the sip factory binding from the jndi mapping
@param appName the application name subcontext
@param sipFactory the sip factory to remove | [
"Removes",
"the",
"sip",
"factory",
"binding",
"from",
"the",
"jndi",
"mapping"
] | train | https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipNamingContextListener.java#L295-L304 |
salesforce/Argus | ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/dto/AuditDto.java | AuditDto.transformToDto | public static List<AuditDto> transformToDto(List<Audit> audits) {
"""
Converts a list of audit entities to DTOs.
@param audits The list of audit entities to convert.
@return The list of DTO objects.
@throws WebApplicationException If an error occurs.
"""
if (audits == null) {
throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
}
List<AuditDto> result = new ArrayList<AuditDto>();
for (Audit audit : audits) {
result.add(transformToDto(audit));
}
return result;
} | java | public static List<AuditDto> transformToDto(List<Audit> audits) {
if (audits == null) {
throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
}
List<AuditDto> result = new ArrayList<AuditDto>();
for (Audit audit : audits) {
result.add(transformToDto(audit));
}
return result;
} | [
"public",
"static",
"List",
"<",
"AuditDto",
">",
"transformToDto",
"(",
"List",
"<",
"Audit",
">",
"audits",
")",
"{",
"if",
"(",
"audits",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"Null entity object cannot be converted to Dto object.\"",
",",
"Status",
".",
"INTERNAL_SERVER_ERROR",
")",
";",
"}",
"List",
"<",
"AuditDto",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"AuditDto",
">",
"(",
")",
";",
"for",
"(",
"Audit",
"audit",
":",
"audits",
")",
"{",
"result",
".",
"add",
"(",
"transformToDto",
"(",
"audit",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Converts a list of audit entities to DTOs.
@param audits The list of audit entities to convert.
@return The list of DTO objects.
@throws WebApplicationException If an error occurs. | [
"Converts",
"a",
"list",
"of",
"audit",
"entities",
"to",
"DTOs",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/dto/AuditDto.java#L102-L114 |
icode/ameba | src/main/java/ameba/mvc/template/internal/TemplateModelProcessor.java | TemplateModelProcessor.processModel | private ResourceModel processModel(final ResourceModel resourceModel, final boolean subResourceModel) {
"""
Enhance {@link org.glassfish.jersey.server.model.RuntimeResource runtime resources} of given
{@link org.glassfish.jersey.server.model.ResourceModel resource model} with methods obtained with
{@link #getEnhancingMethods(org.glassfish.jersey.server.model.RuntimeResource)}.
@param resourceModel resource model to enhance runtime resources of.
@param subResourceModel determines whether the resource model represents sub-resource.
@return enhanced resource model.
"""
ResourceModel.Builder newModelBuilder = processTemplateAnnotatedInvocables(resourceModel, subResourceModel);
for (RuntimeResource resource : resourceModel.getRuntimeResourceModel().getRuntimeResources()) {
ModelProcessorUtil.enhanceResource(resource, newModelBuilder, getEnhancingMethods(resource), false);
}
return newModelBuilder.build();
} | java | private ResourceModel processModel(final ResourceModel resourceModel, final boolean subResourceModel) {
ResourceModel.Builder newModelBuilder = processTemplateAnnotatedInvocables(resourceModel, subResourceModel);
for (RuntimeResource resource : resourceModel.getRuntimeResourceModel().getRuntimeResources()) {
ModelProcessorUtil.enhanceResource(resource, newModelBuilder, getEnhancingMethods(resource), false);
}
return newModelBuilder.build();
} | [
"private",
"ResourceModel",
"processModel",
"(",
"final",
"ResourceModel",
"resourceModel",
",",
"final",
"boolean",
"subResourceModel",
")",
"{",
"ResourceModel",
".",
"Builder",
"newModelBuilder",
"=",
"processTemplateAnnotatedInvocables",
"(",
"resourceModel",
",",
"subResourceModel",
")",
";",
"for",
"(",
"RuntimeResource",
"resource",
":",
"resourceModel",
".",
"getRuntimeResourceModel",
"(",
")",
".",
"getRuntimeResources",
"(",
")",
")",
"{",
"ModelProcessorUtil",
".",
"enhanceResource",
"(",
"resource",
",",
"newModelBuilder",
",",
"getEnhancingMethods",
"(",
"resource",
")",
",",
"false",
")",
";",
"}",
"return",
"newModelBuilder",
".",
"build",
"(",
")",
";",
"}"
] | Enhance {@link org.glassfish.jersey.server.model.RuntimeResource runtime resources} of given
{@link org.glassfish.jersey.server.model.ResourceModel resource model} with methods obtained with
{@link #getEnhancingMethods(org.glassfish.jersey.server.model.RuntimeResource)}.
@param resourceModel resource model to enhance runtime resources of.
@param subResourceModel determines whether the resource model represents sub-resource.
@return enhanced resource model. | [
"Enhance",
"{",
"@link",
"org",
".",
"glassfish",
".",
"jersey",
".",
"server",
".",
"model",
".",
"RuntimeResource",
"runtime",
"resources",
"}",
"of",
"given",
"{",
"@link",
"org",
".",
"glassfish",
".",
"jersey",
".",
"server",
".",
"model",
".",
"ResourceModel",
"resource",
"model",
"}",
"with",
"methods",
"obtained",
"with",
"{",
"@link",
"#getEnhancingMethods",
"(",
"org",
".",
"glassfish",
".",
"jersey",
".",
"server",
".",
"model",
".",
"RuntimeResource",
")",
"}",
"."
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/mvc/template/internal/TemplateModelProcessor.java#L96-L104 |
alkacon/opencms-core | src/org/opencms/db/CmsSelectQuery.java | CmsSelectQuery.addColumn | public void addColumn(String column) {
"""
Adds an expression which should be added as a column in the result set.<p>
@param column the expression which should be added as a column
"""
m_columns.add(new CmsSimpleQueryFragment(column, Collections.<Object> emptyList()));
} | java | public void addColumn(String column) {
m_columns.add(new CmsSimpleQueryFragment(column, Collections.<Object> emptyList()));
} | [
"public",
"void",
"addColumn",
"(",
"String",
"column",
")",
"{",
"m_columns",
".",
"add",
"(",
"new",
"CmsSimpleQueryFragment",
"(",
"column",
",",
"Collections",
".",
"<",
"Object",
">",
"emptyList",
"(",
")",
")",
")",
";",
"}"
] | Adds an expression which should be added as a column in the result set.<p>
@param column the expression which should be added as a column | [
"Adds",
"an",
"expression",
"which",
"should",
"be",
"added",
"as",
"a",
"column",
"in",
"the",
"result",
"set",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSelectQuery.java#L141-L144 |
dashorst/wicket-stuff-markup-validator | jing/src/main/java/com/thaiopensource/validate/nvdl/SchemaImpl.java | SchemaImpl.getModeAttribute | private Mode getModeAttribute(Attributes attributes, String localName) {
"""
Get the mode specified by an attribute from no namespace.
@param attributes The attributes.
@param localName The attribute name.
@return The mode refered by the licanName attribute.
"""
return lookupCreateMode(attributes.getValue("", localName));
} | java | private Mode getModeAttribute(Attributes attributes, String localName) {
return lookupCreateMode(attributes.getValue("", localName));
} | [
"private",
"Mode",
"getModeAttribute",
"(",
"Attributes",
"attributes",
",",
"String",
"localName",
")",
"{",
"return",
"lookupCreateMode",
"(",
"attributes",
".",
"getValue",
"(",
"\"\"",
",",
"localName",
")",
")",
";",
"}"
] | Get the mode specified by an attribute from no namespace.
@param attributes The attributes.
@param localName The attribute name.
@return The mode refered by the licanName attribute. | [
"Get",
"the",
"mode",
"specified",
"by",
"an",
"attribute",
"from",
"no",
"namespace",
"."
] | train | https://github.com/dashorst/wicket-stuff-markup-validator/blob/9e529a4dc8bfdbbe4c794f3132ef400a006560a1/jing/src/main/java/com/thaiopensource/validate/nvdl/SchemaImpl.java#L1233-L1235 |
Omertron/api-thetvdb | src/main/java/com/omertron/thetvdbapi/TheTVDBApi.java | TheTVDBApi.getEpisode | public Episode getEpisode(String seriesId, int seasonNbr, int episodeNbr, String language) throws TvDbException {
"""
Get a specific episode's information
@param seriesId
@param seasonNbr
@param episodeNbr
@param language
@return
@throws com.omertron.thetvdbapi.TvDbException
"""
return getTVEpisode(seriesId, seasonNbr, episodeNbr, language, "/default/");
} | java | public Episode getEpisode(String seriesId, int seasonNbr, int episodeNbr, String language) throws TvDbException {
return getTVEpisode(seriesId, seasonNbr, episodeNbr, language, "/default/");
} | [
"public",
"Episode",
"getEpisode",
"(",
"String",
"seriesId",
",",
"int",
"seasonNbr",
",",
"int",
"episodeNbr",
",",
"String",
"language",
")",
"throws",
"TvDbException",
"{",
"return",
"getTVEpisode",
"(",
"seriesId",
",",
"seasonNbr",
",",
"episodeNbr",
",",
"language",
",",
"\"/default/\"",
")",
";",
"}"
] | Get a specific episode's information
@param seriesId
@param seasonNbr
@param episodeNbr
@param language
@return
@throws com.omertron.thetvdbapi.TvDbException | [
"Get",
"a",
"specific",
"episode",
"s",
"information"
] | train | https://github.com/Omertron/api-thetvdb/blob/2ff9f9580e76043f19d2fc3234d87e16a95fa485/src/main/java/com/omertron/thetvdbapi/TheTVDBApi.java#L179-L181 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/AppServiceCertificateOrdersInner.java | AppServiceCertificateOrdersInner.createOrUpdate | public AppServiceCertificateOrderInner createOrUpdate(String resourceGroupName, String certificateOrderName, AppServiceCertificateOrderInner certificateDistinguishedName) {
"""
Create or update a certificate purchase order.
Create or update a certificate purchase order.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param certificateOrderName Name of the certificate order.
@param certificateDistinguishedName Distinguished name to to use for the certificate order.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws DefaultErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AppServiceCertificateOrderInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, certificateOrderName, certificateDistinguishedName).toBlocking().last().body();
} | java | public AppServiceCertificateOrderInner createOrUpdate(String resourceGroupName, String certificateOrderName, AppServiceCertificateOrderInner certificateDistinguishedName) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, certificateOrderName, certificateDistinguishedName).toBlocking().last().body();
} | [
"public",
"AppServiceCertificateOrderInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"certificateOrderName",
",",
"AppServiceCertificateOrderInner",
"certificateDistinguishedName",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"certificateOrderName",
",",
"certificateDistinguishedName",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Create or update a certificate purchase order.
Create or update a certificate purchase order.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param certificateOrderName Name of the certificate order.
@param certificateDistinguishedName Distinguished name to to use for the certificate order.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws DefaultErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AppServiceCertificateOrderInner object if successful. | [
"Create",
"or",
"update",
"a",
"certificate",
"purchase",
"order",
".",
"Create",
"or",
"update",
"a",
"certificate",
"purchase",
"order",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/AppServiceCertificateOrdersInner.java#L594-L596 |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java | HttpHeaders.setDate | @Deprecated
public static void setDate(HttpMessage message, Date value) {
"""
@deprecated Use {@link #set(CharSequence, Object)} instead.
Sets the {@code "Date"} header.
"""
message.headers().set(HttpHeaderNames.DATE, value);
} | java | @Deprecated
public static void setDate(HttpMessage message, Date value) {
message.headers().set(HttpHeaderNames.DATE, value);
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"setDate",
"(",
"HttpMessage",
"message",
",",
"Date",
"value",
")",
"{",
"message",
".",
"headers",
"(",
")",
".",
"set",
"(",
"HttpHeaderNames",
".",
"DATE",
",",
"value",
")",
";",
"}"
] | @deprecated Use {@link #set(CharSequence, Object)} instead.
Sets the {@code "Date"} header. | [
"@deprecated",
"Use",
"{",
"@link",
"#set",
"(",
"CharSequence",
"Object",
")",
"}",
"instead",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java#L1069-L1072 |
ocelotds/ocelot | ocelot-processor/src/main/java/org/ocelotds/frameworks/angularjs/FunctionWriter.java | FunctionWriter.writeDependencies | void writeDependencies(Writer writer, String deco, String... dependencies) throws IOException {
"""
dep1, dep2 or if deco = "'" 'dep1', 'dep2'
@param writer
@param deco
@param dependencies
@throws IOException
"""
boolean first = true;
for (String dependency : dependencies) {
if (!first) {
writer.append(COMMA).append(SPACEOPTIONAL);
}
writer.append(deco).append(dependency).append(deco);
first = false;
}
} | java | void writeDependencies(Writer writer, String deco, String... dependencies) throws IOException {
boolean first = true;
for (String dependency : dependencies) {
if (!first) {
writer.append(COMMA).append(SPACEOPTIONAL);
}
writer.append(deco).append(dependency).append(deco);
first = false;
}
} | [
"void",
"writeDependencies",
"(",
"Writer",
"writer",
",",
"String",
"deco",
",",
"String",
"...",
"dependencies",
")",
"throws",
"IOException",
"{",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"String",
"dependency",
":",
"dependencies",
")",
"{",
"if",
"(",
"!",
"first",
")",
"{",
"writer",
".",
"append",
"(",
"COMMA",
")",
".",
"append",
"(",
"SPACEOPTIONAL",
")",
";",
"}",
"writer",
".",
"append",
"(",
"deco",
")",
".",
"append",
"(",
"dependency",
")",
".",
"append",
"(",
"deco",
")",
";",
"first",
"=",
"false",
";",
"}",
"}"
] | dep1, dep2 or if deco = "'" 'dep1', 'dep2'
@param writer
@param deco
@param dependencies
@throws IOException | [
"dep1",
"dep2",
"or",
"if",
"deco",
"=",
"dep1",
"dep2"
] | train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-processor/src/main/java/org/ocelotds/frameworks/angularjs/FunctionWriter.java#L39-L48 |
googleads/googleads-java-lib | examples/admanager_axis/src/main/java/admanager/axis/v201902/reportservice/RunReachReport.java | RunReachReport.runExample | public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
throws IOException, InterruptedException {
"""
Runs the example.
@param adManagerServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.
@throws IOException if unable to write the response to a file.
@throws InterruptedException if the thread is interrupted while waiting for the report to
complete.
"""
// Get the ReportService.
ReportServiceInterface reportService =
adManagerServices.get(session, ReportServiceInterface.class);
// Create report query.
ReportQuery reportQuery = new ReportQuery();
reportQuery.setDimensions(new Dimension[] {Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME});
reportQuery.setColumns(
new Column[] {Column.REACH_FREQUENCY, Column.REACH_AVERAGE_REVENUE, Column.REACH});
// Set the dynamic date range type or a custom start and end date that is
// the beginning of the week (Sunday) to the end of the week (Saturday), or
// the first of the month to the end of the month.
reportQuery.setDateRangeType(DateRangeType.REACH_LIFETIME);
// Create report job.
ReportJob reportJob = new ReportJob();
reportJob.setReportQuery(reportQuery);
// Run report job.
reportJob = reportService.runReportJob(reportJob);
// Create report downloader.
ReportDownloader reportDownloader = new ReportDownloader(reportService, reportJob.getId());
// Wait for the report to be ready.
reportDownloader.waitForReportReady();
// Change to your file location.
File file = File.createTempFile("reach-report-", ".csv.gz");
System.out.printf("Downloading report to %s ...", file.toString());
// Download the report.
ReportDownloadOptions options = new ReportDownloadOptions();
options.setExportFormat(ExportFormat.CSV_DUMP);
options.setUseGzipCompression(true);
URL url = reportDownloader.getDownloadUrl(options);
Resources.asByteSource(url).copyTo(Files.asByteSink(file));
System.out.println("done.");
} | java | public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
throws IOException, InterruptedException {
// Get the ReportService.
ReportServiceInterface reportService =
adManagerServices.get(session, ReportServiceInterface.class);
// Create report query.
ReportQuery reportQuery = new ReportQuery();
reportQuery.setDimensions(new Dimension[] {Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME});
reportQuery.setColumns(
new Column[] {Column.REACH_FREQUENCY, Column.REACH_AVERAGE_REVENUE, Column.REACH});
// Set the dynamic date range type or a custom start and end date that is
// the beginning of the week (Sunday) to the end of the week (Saturday), or
// the first of the month to the end of the month.
reportQuery.setDateRangeType(DateRangeType.REACH_LIFETIME);
// Create report job.
ReportJob reportJob = new ReportJob();
reportJob.setReportQuery(reportQuery);
// Run report job.
reportJob = reportService.runReportJob(reportJob);
// Create report downloader.
ReportDownloader reportDownloader = new ReportDownloader(reportService, reportJob.getId());
// Wait for the report to be ready.
reportDownloader.waitForReportReady();
// Change to your file location.
File file = File.createTempFile("reach-report-", ".csv.gz");
System.out.printf("Downloading report to %s ...", file.toString());
// Download the report.
ReportDownloadOptions options = new ReportDownloadOptions();
options.setExportFormat(ExportFormat.CSV_DUMP);
options.setUseGzipCompression(true);
URL url = reportDownloader.getDownloadUrl(options);
Resources.asByteSource(url).copyTo(Files.asByteSink(file));
System.out.println("done.");
} | [
"public",
"static",
"void",
"runExample",
"(",
"AdManagerServices",
"adManagerServices",
",",
"AdManagerSession",
"session",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"// Get the ReportService.",
"ReportServiceInterface",
"reportService",
"=",
"adManagerServices",
".",
"get",
"(",
"session",
",",
"ReportServiceInterface",
".",
"class",
")",
";",
"// Create report query.",
"ReportQuery",
"reportQuery",
"=",
"new",
"ReportQuery",
"(",
")",
";",
"reportQuery",
".",
"setDimensions",
"(",
"new",
"Dimension",
"[",
"]",
"{",
"Dimension",
".",
"LINE_ITEM_ID",
",",
"Dimension",
".",
"LINE_ITEM_NAME",
"}",
")",
";",
"reportQuery",
".",
"setColumns",
"(",
"new",
"Column",
"[",
"]",
"{",
"Column",
".",
"REACH_FREQUENCY",
",",
"Column",
".",
"REACH_AVERAGE_REVENUE",
",",
"Column",
".",
"REACH",
"}",
")",
";",
"// Set the dynamic date range type or a custom start and end date that is",
"// the beginning of the week (Sunday) to the end of the week (Saturday), or",
"// the first of the month to the end of the month.",
"reportQuery",
".",
"setDateRangeType",
"(",
"DateRangeType",
".",
"REACH_LIFETIME",
")",
";",
"// Create report job.",
"ReportJob",
"reportJob",
"=",
"new",
"ReportJob",
"(",
")",
";",
"reportJob",
".",
"setReportQuery",
"(",
"reportQuery",
")",
";",
"// Run report job.",
"reportJob",
"=",
"reportService",
".",
"runReportJob",
"(",
"reportJob",
")",
";",
"// Create report downloader.",
"ReportDownloader",
"reportDownloader",
"=",
"new",
"ReportDownloader",
"(",
"reportService",
",",
"reportJob",
".",
"getId",
"(",
")",
")",
";",
"// Wait for the report to be ready.",
"reportDownloader",
".",
"waitForReportReady",
"(",
")",
";",
"// Change to your file location.",
"File",
"file",
"=",
"File",
".",
"createTempFile",
"(",
"\"reach-report-\"",
",",
"\".csv.gz\"",
")",
";",
"System",
".",
"out",
".",
"printf",
"(",
"\"Downloading report to %s ...\"",
",",
"file",
".",
"toString",
"(",
")",
")",
";",
"// Download the report.",
"ReportDownloadOptions",
"options",
"=",
"new",
"ReportDownloadOptions",
"(",
")",
";",
"options",
".",
"setExportFormat",
"(",
"ExportFormat",
".",
"CSV_DUMP",
")",
";",
"options",
".",
"setUseGzipCompression",
"(",
"true",
")",
";",
"URL",
"url",
"=",
"reportDownloader",
".",
"getDownloadUrl",
"(",
"options",
")",
";",
"Resources",
".",
"asByteSource",
"(",
"url",
")",
".",
"copyTo",
"(",
"Files",
".",
"asByteSink",
"(",
"file",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"done.\"",
")",
";",
"}"
] | Runs the example.
@param adManagerServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.
@throws IOException if unable to write the response to a file.
@throws InterruptedException if the thread is interrupted while waiting for the report to
complete. | [
"Runs",
"the",
"example",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/examples/admanager_axis/src/main/java/admanager/axis/v201902/reportservice/RunReachReport.java#L64-L107 |
roboconf/roboconf-platform | core/roboconf-messaging-api/src/main/java/net/roboconf/messaging/api/reconfigurables/ReconfigurableClient.java | ReconfigurableClient.switchMessagingType | public void switchMessagingType( String factoryName ) {
"""
Changes the internal messaging client.
@param factoryName the factory name (see {@link MessagingConstants})
"""
// Create a new client
this.logger.fine( "The messaging is requested to switch its type to " + factoryName + "." );
JmxWrapperForMessagingClient newMessagingClient = null;
try {
IMessagingClient rawClient = createMessagingClient( factoryName );
if( rawClient != null ) {
newMessagingClient = new JmxWrapperForMessagingClient( rawClient );
newMessagingClient.setMessageQueue( this.messageProcessor.getMessageQueue());
openConnection( newMessagingClient );
}
} catch( Exception e ) {
this.logger.warning( "An error occurred while creating a new messaging client. " + e.getMessage());
Utils.logException( this.logger, e );
// #594: print a message to be visible in a console
StringBuilder sb = new StringBuilder();
sb.append( "\n\n**** WARNING ****\n" );
sb.append( "Connection failed at " );
sb.append( new SimpleDateFormat( "HH:mm:ss, 'on' EEEE dd (MMMM)" ).format( new Date()));
sb.append( ".\n" );
sb.append( "The messaging configuration may be invalid.\n" );
sb.append( "Or the messaging server may not be started yet.\n\n" );
sb.append( "Consider using the 'roboconf:force-reconnect' command if you forgot to start the messaging server.\n" );
sb.append( "**** WARNING ****\n" );
this.console.println( sb.toString());
}
// Replace the current client
IMessagingClient oldClient;
synchronized( this ) {
// Simple changes
this.messagingType = factoryName;
oldClient = this.messagingClient;
// The messaging client can NEVER be null
if( newMessagingClient != null )
this.messagingClient = newMessagingClient;
else
resetInternalClient();
}
terminateClient( oldClient, "The previous client could not be terminated correctly.", this.logger );
} | java | public void switchMessagingType( String factoryName ) {
// Create a new client
this.logger.fine( "The messaging is requested to switch its type to " + factoryName + "." );
JmxWrapperForMessagingClient newMessagingClient = null;
try {
IMessagingClient rawClient = createMessagingClient( factoryName );
if( rawClient != null ) {
newMessagingClient = new JmxWrapperForMessagingClient( rawClient );
newMessagingClient.setMessageQueue( this.messageProcessor.getMessageQueue());
openConnection( newMessagingClient );
}
} catch( Exception e ) {
this.logger.warning( "An error occurred while creating a new messaging client. " + e.getMessage());
Utils.logException( this.logger, e );
// #594: print a message to be visible in a console
StringBuilder sb = new StringBuilder();
sb.append( "\n\n**** WARNING ****\n" );
sb.append( "Connection failed at " );
sb.append( new SimpleDateFormat( "HH:mm:ss, 'on' EEEE dd (MMMM)" ).format( new Date()));
sb.append( ".\n" );
sb.append( "The messaging configuration may be invalid.\n" );
sb.append( "Or the messaging server may not be started yet.\n\n" );
sb.append( "Consider using the 'roboconf:force-reconnect' command if you forgot to start the messaging server.\n" );
sb.append( "**** WARNING ****\n" );
this.console.println( sb.toString());
}
// Replace the current client
IMessagingClient oldClient;
synchronized( this ) {
// Simple changes
this.messagingType = factoryName;
oldClient = this.messagingClient;
// The messaging client can NEVER be null
if( newMessagingClient != null )
this.messagingClient = newMessagingClient;
else
resetInternalClient();
}
terminateClient( oldClient, "The previous client could not be terminated correctly.", this.logger );
} | [
"public",
"void",
"switchMessagingType",
"(",
"String",
"factoryName",
")",
"{",
"// Create a new client",
"this",
".",
"logger",
".",
"fine",
"(",
"\"The messaging is requested to switch its type to \"",
"+",
"factoryName",
"+",
"\".\"",
")",
";",
"JmxWrapperForMessagingClient",
"newMessagingClient",
"=",
"null",
";",
"try",
"{",
"IMessagingClient",
"rawClient",
"=",
"createMessagingClient",
"(",
"factoryName",
")",
";",
"if",
"(",
"rawClient",
"!=",
"null",
")",
"{",
"newMessagingClient",
"=",
"new",
"JmxWrapperForMessagingClient",
"(",
"rawClient",
")",
";",
"newMessagingClient",
".",
"setMessageQueue",
"(",
"this",
".",
"messageProcessor",
".",
"getMessageQueue",
"(",
")",
")",
";",
"openConnection",
"(",
"newMessagingClient",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"this",
".",
"logger",
".",
"warning",
"(",
"\"An error occurred while creating a new messaging client. \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"Utils",
".",
"logException",
"(",
"this",
".",
"logger",
",",
"e",
")",
";",
"// #594: print a message to be visible in a console",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"\\n\\n**** WARNING ****\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"Connection failed at \"",
")",
";",
"sb",
".",
"append",
"(",
"new",
"SimpleDateFormat",
"(",
"\"HH:mm:ss, 'on' EEEE dd (MMMM)\"",
")",
".",
"format",
"(",
"new",
"Date",
"(",
")",
")",
")",
";",
"sb",
".",
"append",
"(",
"\".\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"The messaging configuration may be invalid.\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"Or the messaging server may not be started yet.\\n\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"Consider using the 'roboconf:force-reconnect' command if you forgot to start the messaging server.\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"**** WARNING ****\\n\"",
")",
";",
"this",
".",
"console",
".",
"println",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"// Replace the current client",
"IMessagingClient",
"oldClient",
";",
"synchronized",
"(",
"this",
")",
"{",
"// Simple changes",
"this",
".",
"messagingType",
"=",
"factoryName",
";",
"oldClient",
"=",
"this",
".",
"messagingClient",
";",
"// The messaging client can NEVER be null",
"if",
"(",
"newMessagingClient",
"!=",
"null",
")",
"this",
".",
"messagingClient",
"=",
"newMessagingClient",
";",
"else",
"resetInternalClient",
"(",
")",
";",
"}",
"terminateClient",
"(",
"oldClient",
",",
"\"The previous client could not be terminated correctly.\"",
",",
"this",
".",
"logger",
")",
";",
"}"
] | Changes the internal messaging client.
@param factoryName the factory name (see {@link MessagingConstants}) | [
"Changes",
"the",
"internal",
"messaging",
"client",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-messaging-api/src/main/java/net/roboconf/messaging/api/reconfigurables/ReconfigurableClient.java#L160-L206 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPFriendlyURLEntryPersistenceImpl.java | CPFriendlyURLEntryPersistenceImpl.removeByUUID_G | @Override
public CPFriendlyURLEntry removeByUUID_G(String uuid, long groupId)
throws NoSuchCPFriendlyURLEntryException {
"""
Removes the cp friendly url entry where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the cp friendly url entry that was removed
"""
CPFriendlyURLEntry cpFriendlyURLEntry = findByUUID_G(uuid, groupId);
return remove(cpFriendlyURLEntry);
} | java | @Override
public CPFriendlyURLEntry removeByUUID_G(String uuid, long groupId)
throws NoSuchCPFriendlyURLEntryException {
CPFriendlyURLEntry cpFriendlyURLEntry = findByUUID_G(uuid, groupId);
return remove(cpFriendlyURLEntry);
} | [
"@",
"Override",
"public",
"CPFriendlyURLEntry",
"removeByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"NoSuchCPFriendlyURLEntryException",
"{",
"CPFriendlyURLEntry",
"cpFriendlyURLEntry",
"=",
"findByUUID_G",
"(",
"uuid",
",",
"groupId",
")",
";",
"return",
"remove",
"(",
"cpFriendlyURLEntry",
")",
";",
"}"
] | Removes the cp friendly url entry where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the cp friendly url entry that was removed | [
"Removes",
"the",
"cp",
"friendly",
"url",
"entry",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPFriendlyURLEntryPersistenceImpl.java#L817-L823 |
jqm4gwt/jqm4gwt | library/src/main/java/com/sksamuel/jqm4gwt/list/JQMList.java | JQMList.addItem | public JQMListItem addItem(String text, JQMPage page) {
"""
Adds a new {@link JQMListItem} that contains the given @param text as the heading element.
<br>
The list item is made linkable to the given page
@param text the text to use as the content of the header element
@param page the page to make the list item link to
"""
return addItem(text, "#" + page.getId());
} | java | public JQMListItem addItem(String text, JQMPage page) {
return addItem(text, "#" + page.getId());
} | [
"public",
"JQMListItem",
"addItem",
"(",
"String",
"text",
",",
"JQMPage",
"page",
")",
"{",
"return",
"addItem",
"(",
"text",
",",
"\"#\"",
"+",
"page",
".",
"getId",
"(",
")",
")",
";",
"}"
] | Adds a new {@link JQMListItem} that contains the given @param text as the heading element.
<br>
The list item is made linkable to the given page
@param text the text to use as the content of the header element
@param page the page to make the list item link to | [
"Adds",
"a",
"new",
"{",
"@link",
"JQMListItem",
"}",
"that",
"contains",
"the",
"given",
"@param",
"text",
"as",
"the",
"heading",
"element",
".",
"<br",
">",
"The",
"list",
"item",
"is",
"made",
"linkable",
"to",
"the",
"given",
"page"
] | train | https://github.com/jqm4gwt/jqm4gwt/blob/cf59958e9ba6d4b70f42507b2c77f10c2465085b/library/src/main/java/com/sksamuel/jqm4gwt/list/JQMList.java#L277-L279 |
wellner/jcarafe | jcarafe-core/src/main/java/cern/colt/list/AbstractIntList.java | AbstractIntList.addAllOfFromTo | public void addAllOfFromTo(AbstractIntList other, int from, int to) {
"""
Appends the part of the specified list between <code>from</code> (inclusive) and <code>to</code> (inclusive) to the receiver.
@param other the list to be added to the receiver.
@param from the index of the first element to be appended (inclusive).
@param to the index of the last element to be appended (inclusive).
@exception IndexOutOfBoundsException index is out of range (<tt>other.size()>0 && (from<0 || from>to || to>=other.size())</tt>).
"""
beforeInsertAllOfFromTo(size,other,from,to);
} | java | public void addAllOfFromTo(AbstractIntList other, int from, int to) {
beforeInsertAllOfFromTo(size,other,from,to);
} | [
"public",
"void",
"addAllOfFromTo",
"(",
"AbstractIntList",
"other",
",",
"int",
"from",
",",
"int",
"to",
")",
"{",
"beforeInsertAllOfFromTo",
"(",
"size",
",",
"other",
",",
"from",
",",
"to",
")",
";",
"}"
] | Appends the part of the specified list between <code>from</code> (inclusive) and <code>to</code> (inclusive) to the receiver.
@param other the list to be added to the receiver.
@param from the index of the first element to be appended (inclusive).
@param to the index of the last element to be appended (inclusive).
@exception IndexOutOfBoundsException index is out of range (<tt>other.size()>0 && (from<0 || from>to || to>=other.size())</tt>). | [
"Appends",
"the",
"part",
"of",
"the",
"specified",
"list",
"between",
"<code",
">",
"from<",
"/",
"code",
">",
"(",
"inclusive",
")",
"and",
"<code",
">",
"to<",
"/",
"code",
">",
"(",
"inclusive",
")",
"to",
"the",
"receiver",
"."
] | train | https://github.com/wellner/jcarafe/blob/ab8b0a83dbf600fe80c27711815c90bd3055b217/jcarafe-core/src/main/java/cern/colt/list/AbstractIntList.java#L53-L55 |
javafxports/javafxmobile-plugin | src/main/java/org/javafxports/jfxmobile/plugin/android/task/ApkBuilder.java | ApkBuilder.addFile | @Override
public void addFile(File file, String archivePath) throws ApkCreationException,
SealedApkException, DuplicateFileException {
"""
Adds a file to the APK at a given path
@param file the file to add
@param archivePath the path of the file inside the APK archive.
@throws ApkCreationException if an error occurred
@throws SealedApkException if the APK is already sealed.
@throws DuplicateFileException if a file conflicts with another already added to the APK
at the same location inside the APK archive.
"""
if (mIsSealed) {
throw new SealedApkException("APK is already sealed");
}
try {
doAddFile(file, archivePath);
} catch (DuplicateFileException e) {
mBuilder.cleanUp();
throw e;
} catch (Exception e) {
mBuilder.cleanUp();
throw new ApkCreationException(e, "Failed to add %s", file);
}
} | java | @Override
public void addFile(File file, String archivePath) throws ApkCreationException,
SealedApkException, DuplicateFileException {
if (mIsSealed) {
throw new SealedApkException("APK is already sealed");
}
try {
doAddFile(file, archivePath);
} catch (DuplicateFileException e) {
mBuilder.cleanUp();
throw e;
} catch (Exception e) {
mBuilder.cleanUp();
throw new ApkCreationException(e, "Failed to add %s", file);
}
} | [
"@",
"Override",
"public",
"void",
"addFile",
"(",
"File",
"file",
",",
"String",
"archivePath",
")",
"throws",
"ApkCreationException",
",",
"SealedApkException",
",",
"DuplicateFileException",
"{",
"if",
"(",
"mIsSealed",
")",
"{",
"throw",
"new",
"SealedApkException",
"(",
"\"APK is already sealed\"",
")",
";",
"}",
"try",
"{",
"doAddFile",
"(",
"file",
",",
"archivePath",
")",
";",
"}",
"catch",
"(",
"DuplicateFileException",
"e",
")",
"{",
"mBuilder",
".",
"cleanUp",
"(",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"mBuilder",
".",
"cleanUp",
"(",
")",
";",
"throw",
"new",
"ApkCreationException",
"(",
"e",
",",
"\"Failed to add %s\"",
",",
"file",
")",
";",
"}",
"}"
] | Adds a file to the APK at a given path
@param file the file to add
@param archivePath the path of the file inside the APK archive.
@throws ApkCreationException if an error occurred
@throws SealedApkException if the APK is already sealed.
@throws DuplicateFileException if a file conflicts with another already added to the APK
at the same location inside the APK archive. | [
"Adds",
"a",
"file",
"to",
"the",
"APK",
"at",
"a",
"given",
"path"
] | train | https://github.com/javafxports/javafxmobile-plugin/blob/a9bef513b7e1bfa85f9a668226e6943c6d9f847f/src/main/java/org/javafxports/jfxmobile/plugin/android/task/ApkBuilder.java#L552-L568 |
xhsun/gw2wrapper | src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java | SynchronousRequest.getAllContinentRegionID | public List<Integer> getAllContinentRegionID(int continentID, int floorID) throws GuildWars2Exception {
"""
For more info on continents API go <a href="https://wiki.guildwars2.com/wiki/API:2/continents">here</a><br/>
Get all continent region ids
@param continentID {@link Continent#id}
@param floorID {@link ContinentFloor#id}
@return list of continent region ids
@throws GuildWars2Exception see {@link ErrorCode} for detail
@see ContinentRegion continent region info
"""
try {
Response<List<Integer>> response = gw2API.getAllContinentRegionIDs(Integer.toString(continentID),
Integer.toString(floorID)).execute();
if (!response.isSuccessful()) throwError(response.code(), response.errorBody());
return response.body();
} catch (IOException e) {
throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage());
}
} | java | public List<Integer> getAllContinentRegionID(int continentID, int floorID) throws GuildWars2Exception {
try {
Response<List<Integer>> response = gw2API.getAllContinentRegionIDs(Integer.toString(continentID),
Integer.toString(floorID)).execute();
if (!response.isSuccessful()) throwError(response.code(), response.errorBody());
return response.body();
} catch (IOException e) {
throw new GuildWars2Exception(ErrorCode.Network, "Network Error: " + e.getMessage());
}
} | [
"public",
"List",
"<",
"Integer",
">",
"getAllContinentRegionID",
"(",
"int",
"continentID",
",",
"int",
"floorID",
")",
"throws",
"GuildWars2Exception",
"{",
"try",
"{",
"Response",
"<",
"List",
"<",
"Integer",
">>",
"response",
"=",
"gw2API",
".",
"getAllContinentRegionIDs",
"(",
"Integer",
".",
"toString",
"(",
"continentID",
")",
",",
"Integer",
".",
"toString",
"(",
"floorID",
")",
")",
".",
"execute",
"(",
")",
";",
"if",
"(",
"!",
"response",
".",
"isSuccessful",
"(",
")",
")",
"throwError",
"(",
"response",
".",
"code",
"(",
")",
",",
"response",
".",
"errorBody",
"(",
")",
")",
";",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"GuildWars2Exception",
"(",
"ErrorCode",
".",
"Network",
",",
"\"Network Error: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | For more info on continents API go <a href="https://wiki.guildwars2.com/wiki/API:2/continents">here</a><br/>
Get all continent region ids
@param continentID {@link Continent#id}
@param floorID {@link ContinentFloor#id}
@return list of continent region ids
@throws GuildWars2Exception see {@link ErrorCode} for detail
@see ContinentRegion continent region info | [
"For",
"more",
"info",
"on",
"continents",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"continents",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Get",
"all",
"continent",
"region",
"ids"
] | train | https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/SynchronousRequest.java#L1433-L1442 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.listClosedListsWithServiceResponseAsync | public Observable<ServiceResponse<List<ClosedListEntityExtractor>>> listClosedListsWithServiceResponseAsync(UUID appId, String versionId, ListClosedListsOptionalParameter listClosedListsOptionalParameter) {
"""
Gets information about the closedlist models.
@param appId The application ID.
@param versionId The version ID.
@param listClosedListsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ClosedListEntityExtractor> object
"""
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
final Integer skip = listClosedListsOptionalParameter != null ? listClosedListsOptionalParameter.skip() : null;
final Integer take = listClosedListsOptionalParameter != null ? listClosedListsOptionalParameter.take() : null;
return listClosedListsWithServiceResponseAsync(appId, versionId, skip, take);
} | java | public Observable<ServiceResponse<List<ClosedListEntityExtractor>>> listClosedListsWithServiceResponseAsync(UUID appId, String versionId, ListClosedListsOptionalParameter listClosedListsOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
final Integer skip = listClosedListsOptionalParameter != null ? listClosedListsOptionalParameter.skip() : null;
final Integer take = listClosedListsOptionalParameter != null ? listClosedListsOptionalParameter.take() : null;
return listClosedListsWithServiceResponseAsync(appId, versionId, skip, take);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"List",
"<",
"ClosedListEntityExtractor",
">",
">",
">",
"listClosedListsWithServiceResponseAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"ListClosedListsOptionalParameter",
"listClosedListsOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"endpoint",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.endpoint() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"appId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter appId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"versionId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter versionId is required and cannot be null.\"",
")",
";",
"}",
"final",
"Integer",
"skip",
"=",
"listClosedListsOptionalParameter",
"!=",
"null",
"?",
"listClosedListsOptionalParameter",
".",
"skip",
"(",
")",
":",
"null",
";",
"final",
"Integer",
"take",
"=",
"listClosedListsOptionalParameter",
"!=",
"null",
"?",
"listClosedListsOptionalParameter",
".",
"take",
"(",
")",
":",
"null",
";",
"return",
"listClosedListsWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"skip",
",",
"take",
")",
";",
"}"
] | Gets information about the closedlist models.
@param appId The application ID.
@param versionId The version ID.
@param listClosedListsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ClosedListEntityExtractor> object | [
"Gets",
"information",
"about",
"the",
"closedlist",
"models",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L1866-L1880 |
ineunetOS/knife-commons | knife-commons-utils/src/main/java/com/ineunet/knife/util/StringUtils.java | StringUtils.abbreviateMiddle | public static String abbreviateMiddle(String str, String middle, int length) {
"""
<p>Abbreviates a String to the length passed, replacing the middle characters with the supplied
replacement String.</p>
<p>This abbreviation only occurs if the following criteria is met:
<ul>
<li>Neither the String for abbreviation nor the replacement String are null or empty </li>
<li>The length to truncate to is less than the length of the supplied String</li>
<li>The length to truncate to is greater than 0</li>
<li>The abbreviated String will have enough room for the length supplied replacement String
and the first and last characters of the supplied String for abbreviation</li>
</ul>
Otherwise, the returned String will be the same as the supplied String for abbreviation.
</p>
<pre>
StringUtils.abbreviateMiddle(null, null, 0) = null
StringUtils.abbreviateMiddle("abc", null, 0) = "abc"
StringUtils.abbreviateMiddle("abc", ".", 0) = "abc"
StringUtils.abbreviateMiddle("abc", ".", 3) = "abc"
StringUtils.abbreviateMiddle("abcdef", ".", 4) = "ab.f"
</pre>
@param str the String to abbreviate, may be null
@param middle the String to replace the middle characters with, may be null
@param length the length to abbreviate <code>str</code> to.
@return the abbreviated String if the above criteria is met, or the original String supplied for abbreviation.
@since 2.5
"""
if (isEmpty(str) || isEmpty(middle)) {
return str;
}
if (length >= str.length() || length < (middle.length()+2)) {
return str;
}
int targetSting = length-middle.length();
int startOffset = targetSting/2+targetSting%2;
int endOffset = str.length()-targetSting/2;
StringBuilder builder = new StringBuilder(length);
builder.append(str.substring(0,startOffset));
builder.append(middle);
builder.append(str.substring(endOffset));
return builder.toString();
} | java | public static String abbreviateMiddle(String str, String middle, int length) {
if (isEmpty(str) || isEmpty(middle)) {
return str;
}
if (length >= str.length() || length < (middle.length()+2)) {
return str;
}
int targetSting = length-middle.length();
int startOffset = targetSting/2+targetSting%2;
int endOffset = str.length()-targetSting/2;
StringBuilder builder = new StringBuilder(length);
builder.append(str.substring(0,startOffset));
builder.append(middle);
builder.append(str.substring(endOffset));
return builder.toString();
} | [
"public",
"static",
"String",
"abbreviateMiddle",
"(",
"String",
"str",
",",
"String",
"middle",
",",
"int",
"length",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"str",
")",
"||",
"isEmpty",
"(",
"middle",
")",
")",
"{",
"return",
"str",
";",
"}",
"if",
"(",
"length",
">=",
"str",
".",
"length",
"(",
")",
"||",
"length",
"<",
"(",
"middle",
".",
"length",
"(",
")",
"+",
"2",
")",
")",
"{",
"return",
"str",
";",
"}",
"int",
"targetSting",
"=",
"length",
"-",
"middle",
".",
"length",
"(",
")",
";",
"int",
"startOffset",
"=",
"targetSting",
"/",
"2",
"+",
"targetSting",
"%",
"2",
";",
"int",
"endOffset",
"=",
"str",
".",
"length",
"(",
")",
"-",
"targetSting",
"/",
"2",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"length",
")",
";",
"builder",
".",
"append",
"(",
"str",
".",
"substring",
"(",
"0",
",",
"startOffset",
")",
")",
";",
"builder",
".",
"append",
"(",
"middle",
")",
";",
"builder",
".",
"append",
"(",
"str",
".",
"substring",
"(",
"endOffset",
")",
")",
";",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | <p>Abbreviates a String to the length passed, replacing the middle characters with the supplied
replacement String.</p>
<p>This abbreviation only occurs if the following criteria is met:
<ul>
<li>Neither the String for abbreviation nor the replacement String are null or empty </li>
<li>The length to truncate to is less than the length of the supplied String</li>
<li>The length to truncate to is greater than 0</li>
<li>The abbreviated String will have enough room for the length supplied replacement String
and the first and last characters of the supplied String for abbreviation</li>
</ul>
Otherwise, the returned String will be the same as the supplied String for abbreviation.
</p>
<pre>
StringUtils.abbreviateMiddle(null, null, 0) = null
StringUtils.abbreviateMiddle("abc", null, 0) = "abc"
StringUtils.abbreviateMiddle("abc", ".", 0) = "abc"
StringUtils.abbreviateMiddle("abc", ".", 3) = "abc"
StringUtils.abbreviateMiddle("abcdef", ".", 4) = "ab.f"
</pre>
@param str the String to abbreviate, may be null
@param middle the String to replace the middle characters with, may be null
@param length the length to abbreviate <code>str</code> to.
@return the abbreviated String if the above criteria is met, or the original String supplied for abbreviation.
@since 2.5 | [
"<p",
">",
"Abbreviates",
"a",
"String",
"to",
"the",
"length",
"passed",
"replacing",
"the",
"middle",
"characters",
"with",
"the",
"supplied",
"replacement",
"String",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ineunetOS/knife-commons/blob/eae9e59afa020a00ae8977c10d43ac8ae46ae236/knife-commons-utils/src/main/java/com/ineunet/knife/util/StringUtils.java#L5833-L5852 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/style/StyleUtilities.java | StyleUtilities.readStyle | public static StyledLayerDescriptor readStyle( File file ) throws IOException {
"""
Parse a file and extract the {@link StyledLayerDescriptor}.
@param file the sld file to parse.
@return the styled layer descriptor.
@throws IOException
"""
SLDParser stylereader = new SLDParser(sf, file);
StyledLayerDescriptor sld = stylereader.parseSLD();
return sld;
} | java | public static StyledLayerDescriptor readStyle( File file ) throws IOException {
SLDParser stylereader = new SLDParser(sf, file);
StyledLayerDescriptor sld = stylereader.parseSLD();
return sld;
} | [
"public",
"static",
"StyledLayerDescriptor",
"readStyle",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"SLDParser",
"stylereader",
"=",
"new",
"SLDParser",
"(",
"sf",
",",
"file",
")",
";",
"StyledLayerDescriptor",
"sld",
"=",
"stylereader",
".",
"parseSLD",
"(",
")",
";",
"return",
"sld",
";",
"}"
] | Parse a file and extract the {@link StyledLayerDescriptor}.
@param file the sld file to parse.
@return the styled layer descriptor.
@throws IOException | [
"Parse",
"a",
"file",
"and",
"extract",
"the",
"{",
"@link",
"StyledLayerDescriptor",
"}",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/style/StyleUtilities.java#L245-L249 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.getAt | public static <T> List<T> getAt(T[] array, Range range) {
"""
Support the range subscript operator for an Array
@param array an Array of Objects
@param range a Range
@return a range of a list from the range's from index up to but not
including the range's to value
@since 1.0
"""
List<T> list = Arrays.asList(array);
return getAt(list, range);
} | java | public static <T> List<T> getAt(T[] array, Range range) {
List<T> list = Arrays.asList(array);
return getAt(list, range);
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getAt",
"(",
"T",
"[",
"]",
"array",
",",
"Range",
"range",
")",
"{",
"List",
"<",
"T",
">",
"list",
"=",
"Arrays",
".",
"asList",
"(",
"array",
")",
";",
"return",
"getAt",
"(",
"list",
",",
"range",
")",
";",
"}"
] | Support the range subscript operator for an Array
@param array an Array of Objects
@param range a Range
@return a range of a list from the range's from index up to but not
including the range's to value
@since 1.0 | [
"Support",
"the",
"range",
"subscript",
"operator",
"for",
"an",
"Array"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7784-L7787 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java | ArabicShaping.deshapeNormalize | private int deshapeNormalize(char[] dest, int start, int length) {
"""
/*
Name : deshapeNormalize
Function: Convert the input buffer from FExx Range into 06xx Range
even the lamalef is converted to the special region in the 06xx range.
According to the options the user enters, all seen family characters
followed by a tail character are merged to seen tail family character and
any yeh followed by a hamza character are merged to yehhamza character.
Method returns the number of lamalef chars found.
"""
int lacount = 0;
int yehHamzaComposeEnabled = 0;
int seenComposeEnabled = 0;
yehHamzaComposeEnabled = ((options&YEHHAMZA_MASK) == YEHHAMZA_TWOCELL_NEAR) ? 1 : 0;
seenComposeEnabled = ((options&SEEN_MASK) == SEEN_TWOCELL_NEAR)? 1 : 0;
for (int i = start, e = i + length; i < e; ++i) {
char ch = dest[i];
if( (yehHamzaComposeEnabled == 1) && ((ch == HAMZA06_CHAR) || (ch == HAMZAFE_CHAR))
&& (i < (length - 1)) && isAlefMaksouraChar(dest[i+1] )) {
dest[i] = SPACE_CHAR;
dest[i+1] = YEH_HAMZA_CHAR;
} else if ( (seenComposeEnabled == 1) && (isTailChar(ch)) && (i< (length - 1))
&& (isSeenTailFamilyChar(dest[i+1])==1) ) {
dest[i] = SPACE_CHAR;
}
else if (ch >= '\uFE70' && ch <= '\uFEFC') {
if (isLamAlefChar(ch)) {
++lacount;
}
dest[i] = (char)convertFEto06[ch - '\uFE70'];
}
}
return lacount;
} | java | private int deshapeNormalize(char[] dest, int start, int length) {
int lacount = 0;
int yehHamzaComposeEnabled = 0;
int seenComposeEnabled = 0;
yehHamzaComposeEnabled = ((options&YEHHAMZA_MASK) == YEHHAMZA_TWOCELL_NEAR) ? 1 : 0;
seenComposeEnabled = ((options&SEEN_MASK) == SEEN_TWOCELL_NEAR)? 1 : 0;
for (int i = start, e = i + length; i < e; ++i) {
char ch = dest[i];
if( (yehHamzaComposeEnabled == 1) && ((ch == HAMZA06_CHAR) || (ch == HAMZAFE_CHAR))
&& (i < (length - 1)) && isAlefMaksouraChar(dest[i+1] )) {
dest[i] = SPACE_CHAR;
dest[i+1] = YEH_HAMZA_CHAR;
} else if ( (seenComposeEnabled == 1) && (isTailChar(ch)) && (i< (length - 1))
&& (isSeenTailFamilyChar(dest[i+1])==1) ) {
dest[i] = SPACE_CHAR;
}
else if (ch >= '\uFE70' && ch <= '\uFEFC') {
if (isLamAlefChar(ch)) {
++lacount;
}
dest[i] = (char)convertFEto06[ch - '\uFE70'];
}
}
return lacount;
} | [
"private",
"int",
"deshapeNormalize",
"(",
"char",
"[",
"]",
"dest",
",",
"int",
"start",
",",
"int",
"length",
")",
"{",
"int",
"lacount",
"=",
"0",
";",
"int",
"yehHamzaComposeEnabled",
"=",
"0",
";",
"int",
"seenComposeEnabled",
"=",
"0",
";",
"yehHamzaComposeEnabled",
"=",
"(",
"(",
"options",
"&",
"YEHHAMZA_MASK",
")",
"==",
"YEHHAMZA_TWOCELL_NEAR",
")",
"?",
"1",
":",
"0",
";",
"seenComposeEnabled",
"=",
"(",
"(",
"options",
"&",
"SEEN_MASK",
")",
"==",
"SEEN_TWOCELL_NEAR",
")",
"?",
"1",
":",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"start",
",",
"e",
"=",
"i",
"+",
"length",
";",
"i",
"<",
"e",
";",
"++",
"i",
")",
"{",
"char",
"ch",
"=",
"dest",
"[",
"i",
"]",
";",
"if",
"(",
"(",
"yehHamzaComposeEnabled",
"==",
"1",
")",
"&&",
"(",
"(",
"ch",
"==",
"HAMZA06_CHAR",
")",
"||",
"(",
"ch",
"==",
"HAMZAFE_CHAR",
")",
")",
"&&",
"(",
"i",
"<",
"(",
"length",
"-",
"1",
")",
")",
"&&",
"isAlefMaksouraChar",
"(",
"dest",
"[",
"i",
"+",
"1",
"]",
")",
")",
"{",
"dest",
"[",
"i",
"]",
"=",
"SPACE_CHAR",
";",
"dest",
"[",
"i",
"+",
"1",
"]",
"=",
"YEH_HAMZA_CHAR",
";",
"}",
"else",
"if",
"(",
"(",
"seenComposeEnabled",
"==",
"1",
")",
"&&",
"(",
"isTailChar",
"(",
"ch",
")",
")",
"&&",
"(",
"i",
"<",
"(",
"length",
"-",
"1",
")",
")",
"&&",
"(",
"isSeenTailFamilyChar",
"(",
"dest",
"[",
"i",
"+",
"1",
"]",
")",
"==",
"1",
")",
")",
"{",
"dest",
"[",
"i",
"]",
"=",
"SPACE_CHAR",
";",
"}",
"else",
"if",
"(",
"ch",
">=",
"'",
"'",
"&&",
"ch",
"<=",
"'",
"'",
")",
"{",
"if",
"(",
"isLamAlefChar",
"(",
"ch",
")",
")",
"{",
"++",
"lacount",
";",
"}",
"dest",
"[",
"i",
"]",
"=",
"(",
"char",
")",
"convertFEto06",
"[",
"ch",
"-",
"'",
"'",
"]",
";",
"}",
"}",
"return",
"lacount",
";",
"}"
] | /*
Name : deshapeNormalize
Function: Convert the input buffer from FExx Range into 06xx Range
even the lamalef is converted to the special region in the 06xx range.
According to the options the user enters, all seen family characters
followed by a tail character are merged to seen tail family character and
any yeh followed by a hamza character are merged to yehhamza character.
Method returns the number of lamalef chars found. | [
"/",
"*",
"Name",
":",
"deshapeNormalize",
"Function",
":",
"Convert",
"the",
"input",
"buffer",
"from",
"FExx",
"Range",
"into",
"06xx",
"Range",
"even",
"the",
"lamalef",
"is",
"converted",
"to",
"the",
"special",
"region",
"in",
"the",
"06xx",
"range",
".",
"According",
"to",
"the",
"options",
"the",
"user",
"enters",
"all",
"seen",
"family",
"characters",
"followed",
"by",
"a",
"tail",
"character",
"are",
"merged",
"to",
"seen",
"tail",
"family",
"character",
"and",
"any",
"yeh",
"followed",
"by",
"a",
"hamza",
"character",
"are",
"merged",
"to",
"yehhamza",
"character",
".",
"Method",
"returns",
"the",
"number",
"of",
"lamalef",
"chars",
"found",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java#L1587-L1614 |
Graylog2/graylog2-server | graylog2-server/src/main/java/org/graylog2/search/SearchQueryParser.java | SearchQueryParser.createFieldValue | @VisibleForTesting
FieldValue createFieldValue(SearchQueryField field, String quotedStringValue, boolean negate) {
"""
/* Create a FieldValue for the query field from the string value.
We try to convert the value types according to the data type of the query field.
"""
// Make sure there are no quotes in the value (e.g. `"foo"' --> `foo')
final String value = quotedStringValue.replaceAll(QUOTE_REPLACE_REGEX, "");
final SearchQueryField.Type fieldType = field.getFieldType();
final Pair<String, SearchQueryOperator> pair = extractOperator(value, fieldType == STRING ? DEFAULT_STRING_OPERATOR : DEFAULT_OPERATOR);
switch (fieldType) {
case DATE:
return new FieldValue(parseDate(pair.getLeft()), pair.getRight(), negate);
case STRING:
return new FieldValue(pair.getLeft(), pair.getRight(), negate);
case INT:
return new FieldValue(Integer.parseInt(pair.getLeft()), pair.getRight(), negate);
case LONG:
return new FieldValue(Long.parseLong(pair.getLeft()), pair.getRight(), negate);
default:
throw new IllegalArgumentException("Unhandled field type: " + fieldType.toString());
}
} | java | @VisibleForTesting
FieldValue createFieldValue(SearchQueryField field, String quotedStringValue, boolean negate) {
// Make sure there are no quotes in the value (e.g. `"foo"' --> `foo')
final String value = quotedStringValue.replaceAll(QUOTE_REPLACE_REGEX, "");
final SearchQueryField.Type fieldType = field.getFieldType();
final Pair<String, SearchQueryOperator> pair = extractOperator(value, fieldType == STRING ? DEFAULT_STRING_OPERATOR : DEFAULT_OPERATOR);
switch (fieldType) {
case DATE:
return new FieldValue(parseDate(pair.getLeft()), pair.getRight(), negate);
case STRING:
return new FieldValue(pair.getLeft(), pair.getRight(), negate);
case INT:
return new FieldValue(Integer.parseInt(pair.getLeft()), pair.getRight(), negate);
case LONG:
return new FieldValue(Long.parseLong(pair.getLeft()), pair.getRight(), negate);
default:
throw new IllegalArgumentException("Unhandled field type: " + fieldType.toString());
}
} | [
"@",
"VisibleForTesting",
"FieldValue",
"createFieldValue",
"(",
"SearchQueryField",
"field",
",",
"String",
"quotedStringValue",
",",
"boolean",
"negate",
")",
"{",
"// Make sure there are no quotes in the value (e.g. `\"foo\"' --> `foo')",
"final",
"String",
"value",
"=",
"quotedStringValue",
".",
"replaceAll",
"(",
"QUOTE_REPLACE_REGEX",
",",
"\"\"",
")",
";",
"final",
"SearchQueryField",
".",
"Type",
"fieldType",
"=",
"field",
".",
"getFieldType",
"(",
")",
";",
"final",
"Pair",
"<",
"String",
",",
"SearchQueryOperator",
">",
"pair",
"=",
"extractOperator",
"(",
"value",
",",
"fieldType",
"==",
"STRING",
"?",
"DEFAULT_STRING_OPERATOR",
":",
"DEFAULT_OPERATOR",
")",
";",
"switch",
"(",
"fieldType",
")",
"{",
"case",
"DATE",
":",
"return",
"new",
"FieldValue",
"(",
"parseDate",
"(",
"pair",
".",
"getLeft",
"(",
")",
")",
",",
"pair",
".",
"getRight",
"(",
")",
",",
"negate",
")",
";",
"case",
"STRING",
":",
"return",
"new",
"FieldValue",
"(",
"pair",
".",
"getLeft",
"(",
")",
",",
"pair",
".",
"getRight",
"(",
")",
",",
"negate",
")",
";",
"case",
"INT",
":",
"return",
"new",
"FieldValue",
"(",
"Integer",
".",
"parseInt",
"(",
"pair",
".",
"getLeft",
"(",
")",
")",
",",
"pair",
".",
"getRight",
"(",
")",
",",
"negate",
")",
";",
"case",
"LONG",
":",
"return",
"new",
"FieldValue",
"(",
"Long",
".",
"parseLong",
"(",
"pair",
".",
"getLeft",
"(",
")",
")",
",",
"pair",
".",
"getRight",
"(",
")",
",",
"negate",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unhandled field type: \"",
"+",
"fieldType",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | /* Create a FieldValue for the query field from the string value.
We try to convert the value types according to the data type of the query field. | [
"/",
"*",
"Create",
"a",
"FieldValue",
"for",
"the",
"query",
"field",
"from",
"the",
"string",
"value",
".",
"We",
"try",
"to",
"convert",
"the",
"value",
"types",
"according",
"to",
"the",
"data",
"type",
"of",
"the",
"query",
"field",
"."
] | train | https://github.com/Graylog2/graylog2-server/blob/50b565dcead6e0a372236d5c2f8530dc5726fa9b/graylog2-server/src/main/java/org/graylog2/search/SearchQueryParser.java#L232-L251 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/RuntimeUtil.java | RuntimeUtil.execForStr | public static String execForStr(Charset charset, String... cmds) throws IORuntimeException {
"""
执行系统命令,使用系统默认编码
@param charset 编码
@param cmds 命令列表,每个元素代表一条命令
@return 执行结果
@throws IORuntimeException IO异常
@since 3.1.2
"""
return getResult(exec(cmds), charset);
} | java | public static String execForStr(Charset charset, String... cmds) throws IORuntimeException {
return getResult(exec(cmds), charset);
} | [
"public",
"static",
"String",
"execForStr",
"(",
"Charset",
"charset",
",",
"String",
"...",
"cmds",
")",
"throws",
"IORuntimeException",
"{",
"return",
"getResult",
"(",
"exec",
"(",
"cmds",
")",
",",
"charset",
")",
";",
"}"
] | 执行系统命令,使用系统默认编码
@param charset 编码
@param cmds 命令列表,每个元素代表一条命令
@return 执行结果
@throws IORuntimeException IO异常
@since 3.1.2 | [
"执行系统命令,使用系统默认编码"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/RuntimeUtil.java#L41-L43 |
jglobus/JGlobus | ssl-proxies/src/main/java/org/globus/gsi/trustmanager/IdentityChecker.java | IdentityChecker.invoke | public void invoke(X509Certificate cert, GSIConstants.CertificateType certType) throws CertPathValidatorException {
"""
Method that sets the identity of the certificate path. Also checks if
limited proxy is acceptable.
@throws CertPathValidatorException If limited proxies are not accepted
and the chain has a limited proxy.
"""
if (proxyCertValidator.getIdentityCertificate() == null) {
// check if limited
if (ProxyCertificateUtil.isLimitedProxy(certType)) {
proxyCertValidator.setLimited(true);
if (proxyCertValidator.isRejectLimitedProxy()) {
throw new CertPathValidatorException(
"Limited proxy not accepted");
}
}
// set the identity cert
if (!ProxyCertificateUtil.isImpersonationProxy(certType)) {
proxyCertValidator.setIdentityCert(cert);
}
}
} | java | public void invoke(X509Certificate cert, GSIConstants.CertificateType certType) throws CertPathValidatorException {
if (proxyCertValidator.getIdentityCertificate() == null) {
// check if limited
if (ProxyCertificateUtil.isLimitedProxy(certType)) {
proxyCertValidator.setLimited(true);
if (proxyCertValidator.isRejectLimitedProxy()) {
throw new CertPathValidatorException(
"Limited proxy not accepted");
}
}
// set the identity cert
if (!ProxyCertificateUtil.isImpersonationProxy(certType)) {
proxyCertValidator.setIdentityCert(cert);
}
}
} | [
"public",
"void",
"invoke",
"(",
"X509Certificate",
"cert",
",",
"GSIConstants",
".",
"CertificateType",
"certType",
")",
"throws",
"CertPathValidatorException",
"{",
"if",
"(",
"proxyCertValidator",
".",
"getIdentityCertificate",
"(",
")",
"==",
"null",
")",
"{",
"// check if limited",
"if",
"(",
"ProxyCertificateUtil",
".",
"isLimitedProxy",
"(",
"certType",
")",
")",
"{",
"proxyCertValidator",
".",
"setLimited",
"(",
"true",
")",
";",
"if",
"(",
"proxyCertValidator",
".",
"isRejectLimitedProxy",
"(",
")",
")",
"{",
"throw",
"new",
"CertPathValidatorException",
"(",
"\"Limited proxy not accepted\"",
")",
";",
"}",
"}",
"// set the identity cert",
"if",
"(",
"!",
"ProxyCertificateUtil",
".",
"isImpersonationProxy",
"(",
"certType",
")",
")",
"{",
"proxyCertValidator",
".",
"setIdentityCert",
"(",
"cert",
")",
";",
"}",
"}",
"}"
] | Method that sets the identity of the certificate path. Also checks if
limited proxy is acceptable.
@throws CertPathValidatorException If limited proxies are not accepted
and the chain has a limited proxy. | [
"Method",
"that",
"sets",
"the",
"identity",
"of",
"the",
"certificate",
"path",
".",
"Also",
"checks",
"if",
"limited",
"proxy",
"is",
"acceptable",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/ssl-proxies/src/main/java/org/globus/gsi/trustmanager/IdentityChecker.java#L45-L62 |
facebookarchive/hadoop-20 | src/contrib/namespace-notifier/src/java/org/apache/hadoop/hdfs/notifier/server/ServerDispatcher.java | ServerDispatcher.handleFailedDispatch | @Override
public void handleFailedDispatch(long clientId, long failedTime) {
"""
Called each time a handleNotification or heartbeat Thrift
call fails.
@param clientId the id of the client on which the call failed.
@param failedTime the time at which the call was made. If
this is -1, then nothing will be updated.
"""
ClientData clientData = core.getClientData(clientId);
if (failedTime == -1 || clientData == null)
return;
// We only add it and don't update it because we are interested in
// keeping track of the first moment it failed
if (clientData.markedAsFailedTime == -1) {
clientData.markedAsFailedTime = failedTime;
LOG.info("Marked client " + clientId + " as failed at " + failedTime);
}
clientData.lastSentTime = failedTime;
} | java | @Override
public void handleFailedDispatch(long clientId, long failedTime) {
ClientData clientData = core.getClientData(clientId);
if (failedTime == -1 || clientData == null)
return;
// We only add it and don't update it because we are interested in
// keeping track of the first moment it failed
if (clientData.markedAsFailedTime == -1) {
clientData.markedAsFailedTime = failedTime;
LOG.info("Marked client " + clientId + " as failed at " + failedTime);
}
clientData.lastSentTime = failedTime;
} | [
"@",
"Override",
"public",
"void",
"handleFailedDispatch",
"(",
"long",
"clientId",
",",
"long",
"failedTime",
")",
"{",
"ClientData",
"clientData",
"=",
"core",
".",
"getClientData",
"(",
"clientId",
")",
";",
"if",
"(",
"failedTime",
"==",
"-",
"1",
"||",
"clientData",
"==",
"null",
")",
"return",
";",
"// We only add it and don't update it because we are interested in",
"// keeping track of the first moment it failed",
"if",
"(",
"clientData",
".",
"markedAsFailedTime",
"==",
"-",
"1",
")",
"{",
"clientData",
".",
"markedAsFailedTime",
"=",
"failedTime",
";",
"LOG",
".",
"info",
"(",
"\"Marked client \"",
"+",
"clientId",
"+",
"\" as failed at \"",
"+",
"failedTime",
")",
";",
"}",
"clientData",
".",
"lastSentTime",
"=",
"failedTime",
";",
"}"
] | Called each time a handleNotification or heartbeat Thrift
call fails.
@param clientId the id of the client on which the call failed.
@param failedTime the time at which the call was made. If
this is -1, then nothing will be updated. | [
"Called",
"each",
"time",
"a",
"handleNotification",
"or",
"heartbeat",
"Thrift",
"call",
"fails",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/namespace-notifier/src/java/org/apache/hadoop/hdfs/notifier/server/ServerDispatcher.java#L390-L404 |
dbracewell/mango | src/main/java/com/davidbracewell/string/StringUtils.java | StringUtils.safeEquals | public static boolean safeEquals(String s1, String s2, boolean caseSensitive) {
"""
Safe equals.
@param s1 the s 1
@param s2 the s 2
@param caseSensitive the case sensitive
@return the boolean
"""
if (s1 == s2) {
return true;
} else if (s1 == null || s2 == null) {
return false;
} else if (caseSensitive) {
return s1.equals(s2);
}
return s1.equalsIgnoreCase(s2);
} | java | public static boolean safeEquals(String s1, String s2, boolean caseSensitive) {
if (s1 == s2) {
return true;
} else if (s1 == null || s2 == null) {
return false;
} else if (caseSensitive) {
return s1.equals(s2);
}
return s1.equalsIgnoreCase(s2);
} | [
"public",
"static",
"boolean",
"safeEquals",
"(",
"String",
"s1",
",",
"String",
"s2",
",",
"boolean",
"caseSensitive",
")",
"{",
"if",
"(",
"s1",
"==",
"s2",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"s1",
"==",
"null",
"||",
"s2",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"caseSensitive",
")",
"{",
"return",
"s1",
".",
"equals",
"(",
"s2",
")",
";",
"}",
"return",
"s1",
".",
"equalsIgnoreCase",
"(",
"s2",
")",
";",
"}"
] | Safe equals.
@param s1 the s 1
@param s2 the s 2
@param caseSensitive the case sensitive
@return the boolean | [
"Safe",
"equals",
"."
] | train | https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/string/StringUtils.java#L487-L496 |
Azure/azure-sdk-for-java | logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountAssembliesInner.java | IntegrationAccountAssembliesInner.createOrUpdateAsync | public Observable<AssemblyDefinitionInner> createOrUpdateAsync(String resourceGroupName, String integrationAccountName, String assemblyArtifactName, AssemblyDefinitionInner assemblyArtifact) {
"""
Create or update an assembly for an integration account.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@param assemblyArtifactName The assembly artifact name.
@param assemblyArtifact The assembly artifact.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AssemblyDefinitionInner object
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, integrationAccountName, assemblyArtifactName, assemblyArtifact).map(new Func1<ServiceResponse<AssemblyDefinitionInner>, AssemblyDefinitionInner>() {
@Override
public AssemblyDefinitionInner call(ServiceResponse<AssemblyDefinitionInner> response) {
return response.body();
}
});
} | java | public Observable<AssemblyDefinitionInner> createOrUpdateAsync(String resourceGroupName, String integrationAccountName, String assemblyArtifactName, AssemblyDefinitionInner assemblyArtifact) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, integrationAccountName, assemblyArtifactName, assemblyArtifact).map(new Func1<ServiceResponse<AssemblyDefinitionInner>, AssemblyDefinitionInner>() {
@Override
public AssemblyDefinitionInner call(ServiceResponse<AssemblyDefinitionInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"AssemblyDefinitionInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"integrationAccountName",
",",
"String",
"assemblyArtifactName",
",",
"AssemblyDefinitionInner",
"assemblyArtifact",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"integrationAccountName",
",",
"assemblyArtifactName",
",",
"assemblyArtifact",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"AssemblyDefinitionInner",
">",
",",
"AssemblyDefinitionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"AssemblyDefinitionInner",
"call",
"(",
"ServiceResponse",
"<",
"AssemblyDefinitionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create or update an assembly for an integration account.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@param assemblyArtifactName The assembly artifact name.
@param assemblyArtifact The assembly artifact.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AssemblyDefinitionInner object | [
"Create",
"or",
"update",
"an",
"assembly",
"for",
"an",
"integration",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountAssembliesInner.java#L307-L314 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/input/form/CmsForm.java | CmsForm.addField | public void addField(String fieldGroup, I_CmsFormField formField, String initialValue) {
"""
Adds a form field to the form and sets its initial value.<p>
@param fieldGroup the form field group key
@param formField the form field which should be added
@param initialValue the initial value of the form field, or null if the field shouldn't have an initial value
"""
if (initialValue != null) {
formField.getWidget().setFormValueAsString(initialValue);
}
addField(fieldGroup, formField);
} | java | public void addField(String fieldGroup, I_CmsFormField formField, String initialValue) {
if (initialValue != null) {
formField.getWidget().setFormValueAsString(initialValue);
}
addField(fieldGroup, formField);
} | [
"public",
"void",
"addField",
"(",
"String",
"fieldGroup",
",",
"I_CmsFormField",
"formField",
",",
"String",
"initialValue",
")",
"{",
"if",
"(",
"initialValue",
"!=",
"null",
")",
"{",
"formField",
".",
"getWidget",
"(",
")",
".",
"setFormValueAsString",
"(",
"initialValue",
")",
";",
"}",
"addField",
"(",
"fieldGroup",
",",
"formField",
")",
";",
"}"
] | Adds a form field to the form and sets its initial value.<p>
@param fieldGroup the form field group key
@param formField the form field which should be added
@param initialValue the initial value of the form field, or null if the field shouldn't have an initial value | [
"Adds",
"a",
"form",
"field",
"to",
"the",
"form",
"and",
"sets",
"its",
"initial",
"value",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/form/CmsForm.java#L158-L164 |
b3dgs/lionengine | lionengine-network/src/main/java/com/b3dgs/lionengine/network/ServerImpl.java | ServerImpl.checkValidity | private static boolean checkValidity(ClientSocket client, byte from, StateConnection expected) {
"""
Check if the client is in a valid state.
@param client The client to test.
@param from The client id.
@param expected The expected client state.
@return <code>true</code> if valid, <code>false</code> else.
"""
return from >= 0 && client.getState() == expected;
} | java | private static boolean checkValidity(ClientSocket client, byte from, StateConnection expected)
{
return from >= 0 && client.getState() == expected;
} | [
"private",
"static",
"boolean",
"checkValidity",
"(",
"ClientSocket",
"client",
",",
"byte",
"from",
",",
"StateConnection",
"expected",
")",
"{",
"return",
"from",
">=",
"0",
"&&",
"client",
".",
"getState",
"(",
")",
"==",
"expected",
";",
"}"
] | Check if the client is in a valid state.
@param client The client to test.
@param from The client id.
@param expected The expected client state.
@return <code>true</code> if valid, <code>false</code> else. | [
"Check",
"if",
"the",
"client",
"is",
"in",
"a",
"valid",
"state",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-network/src/main/java/com/b3dgs/lionengine/network/ServerImpl.java#L73-L76 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-job/src/main/java/org/xwiki/job/script/ProgressScripService.java | ProgressScripService.startStep | public void startStep(String translationKey, String message, Object... arguments) {
"""
Close current step if any and move to next one.
@param translationKey the key used to find the translation of the step message
@param message the default message associated to the step
@param arguments the arguments to insert in the step message
"""
this.progress.startStep(this, new Message(translationKey, message, arguments));
} | java | public void startStep(String translationKey, String message, Object... arguments)
{
this.progress.startStep(this, new Message(translationKey, message, arguments));
} | [
"public",
"void",
"startStep",
"(",
"String",
"translationKey",
",",
"String",
"message",
",",
"Object",
"...",
"arguments",
")",
"{",
"this",
".",
"progress",
".",
"startStep",
"(",
"this",
",",
"new",
"Message",
"(",
"translationKey",
",",
"message",
",",
"arguments",
")",
")",
";",
"}"
] | Close current step if any and move to next one.
@param translationKey the key used to find the translation of the step message
@param message the default message associated to the step
@param arguments the arguments to insert in the step message | [
"Close",
"current",
"step",
"if",
"any",
"and",
"move",
"to",
"next",
"one",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-job/src/main/java/org/xwiki/job/script/ProgressScripService.java#L96-L99 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.findIndexValues | public static <T> List<Number> findIndexValues(Iterable<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure condition) {
"""
Iterates over the elements of an Iterable and returns
the index values of the items that match the condition specified in the closure.
@param self an Iterable
@param condition the matching condition
@return a list of numbers corresponding to the index values of all matched objects
@since 2.5.0
"""
return findIndexValues(self, 0, condition);
} | java | public static <T> List<Number> findIndexValues(Iterable<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure condition) {
return findIndexValues(self, 0, condition);
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"Number",
">",
"findIndexValues",
"(",
"Iterable",
"<",
"T",
">",
"self",
",",
"@",
"ClosureParams",
"(",
"FirstParam",
".",
"FirstGenericType",
".",
"class",
")",
"Closure",
"condition",
")",
"{",
"return",
"findIndexValues",
"(",
"self",
",",
"0",
",",
"condition",
")",
";",
"}"
] | Iterates over the elements of an Iterable and returns
the index values of the items that match the condition specified in the closure.
@param self an Iterable
@param condition the matching condition
@return a list of numbers corresponding to the index values of all matched objects
@since 2.5.0 | [
"Iterates",
"over",
"the",
"elements",
"of",
"an",
"Iterable",
"and",
"returns",
"the",
"index",
"values",
"of",
"the",
"items",
"that",
"match",
"the",
"condition",
"specified",
"in",
"the",
"closure",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L17013-L17015 |
cdk/cdk | base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/CompatibilityMatrix.java | CompatibilityMatrix.resetRows | void resetRows(int i, int marking) {
"""
Reset all values marked with (marking) from row i onwards.
@param i row index
@param marking the marking to reset (should be negative)
"""
for (int j = (i * mCols); j < data.length; j++)
if (data[j] == marking) data[j] = 1;
} | java | void resetRows(int i, int marking) {
for (int j = (i * mCols); j < data.length; j++)
if (data[j] == marking) data[j] = 1;
} | [
"void",
"resetRows",
"(",
"int",
"i",
",",
"int",
"marking",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"(",
"i",
"*",
"mCols",
")",
";",
"j",
"<",
"data",
".",
"length",
";",
"j",
"++",
")",
"if",
"(",
"data",
"[",
"j",
"]",
"==",
"marking",
")",
"data",
"[",
"j",
"]",
"=",
"1",
";",
"}"
] | Reset all values marked with (marking) from row i onwards.
@param i row index
@param marking the marking to reset (should be negative) | [
"Reset",
"all",
"values",
"marked",
"with",
"(",
"marking",
")",
"from",
"row",
"i",
"onwards",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/CompatibilityMatrix.java#L119-L122 |
aws/aws-sdk-java | aws-java-sdk-iam/src/main/java/com/amazonaws/services/identitymanagement/model/GetContextKeysForPrincipalPolicyRequest.java | GetContextKeysForPrincipalPolicyRequest.getPolicyInputList | public java.util.List<String> getPolicyInputList() {
"""
<p>
An optional list of additional policies for which you want the list of context keys that are referenced.
</p>
<p>
The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a string of
characters consisting of the following:
</p>
<ul>
<li>
<p>
Any printable ASCII character ranging from the space character ( ) through the end of the ASCII character range
</p>
</li>
<li>
<p>
The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)
</p>
</li>
<li>
<p>
The special characters tab ( ), line feed ( ), and carriage return ( )
</p>
</li>
</ul>
@return An optional list of additional policies for which you want the list of context keys that are
referenced.</p>
<p>
The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a
string of characters consisting of the following:
</p>
<ul>
<li>
<p>
Any printable ASCII character ranging from the space character ( ) through the end of the ASCII character
range
</p>
</li>
<li>
<p>
The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)
</p>
</li>
<li>
<p>
The special characters tab ( ), line feed ( ), and carriage return ( )
</p>
</li>
"""
if (policyInputList == null) {
policyInputList = new com.amazonaws.internal.SdkInternalList<String>();
}
return policyInputList;
} | java | public java.util.List<String> getPolicyInputList() {
if (policyInputList == null) {
policyInputList = new com.amazonaws.internal.SdkInternalList<String>();
}
return policyInputList;
} | [
"public",
"java",
".",
"util",
".",
"List",
"<",
"String",
">",
"getPolicyInputList",
"(",
")",
"{",
"if",
"(",
"policyInputList",
"==",
"null",
")",
"{",
"policyInputList",
"=",
"new",
"com",
".",
"amazonaws",
".",
"internal",
".",
"SdkInternalList",
"<",
"String",
">",
"(",
")",
";",
"}",
"return",
"policyInputList",
";",
"}"
] | <p>
An optional list of additional policies for which you want the list of context keys that are referenced.
</p>
<p>
The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a string of
characters consisting of the following:
</p>
<ul>
<li>
<p>
Any printable ASCII character ranging from the space character ( ) through the end of the ASCII character range
</p>
</li>
<li>
<p>
The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)
</p>
</li>
<li>
<p>
The special characters tab ( ), line feed ( ), and carriage return ( )
</p>
</li>
</ul>
@return An optional list of additional policies for which you want the list of context keys that are
referenced.</p>
<p>
The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a
string of characters consisting of the following:
</p>
<ul>
<li>
<p>
Any printable ASCII character ranging from the space character ( ) through the end of the ASCII character
range
</p>
</li>
<li>
<p>
The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)
</p>
</li>
<li>
<p>
The special characters tab ( ), line feed ( ), and carriage return ( )
</p>
</li> | [
"<p",
">",
"An",
"optional",
"list",
"of",
"additional",
"policies",
"for",
"which",
"you",
"want",
"the",
"list",
"of",
"context",
"keys",
"that",
"are",
"referenced",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"<a",
"href",
"=",
"http",
":",
"//",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"regex",
">",
"regex",
"pattern<",
"/",
"a",
">",
"used",
"to",
"validate",
"this",
"parameter",
"is",
"a",
"string",
"of",
"characters",
"consisting",
"of",
"the",
"following",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"<p",
">",
"Any",
"printable",
"ASCII",
"character",
"ranging",
"from",
"the",
"space",
"character",
"(",
")",
"through",
"the",
"end",
"of",
"the",
"ASCII",
"character",
"range",
"<",
"/",
"p",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<p",
">",
"The",
"printable",
"characters",
"in",
"the",
"Basic",
"Latin",
"and",
"Latin",
"-",
"1",
"Supplement",
"character",
"set",
"(",
"through",
"\\",
"u00FF",
")",
"<",
"/",
"p",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<p",
">",
"The",
"special",
"characters",
"tab",
"(",
")",
"line",
"feed",
"(",
")",
"and",
"carriage",
"return",
"(",
")",
"<",
"/",
"p",
">",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-iam/src/main/java/com/amazonaws/services/identitymanagement/model/GetContextKeysForPrincipalPolicyRequest.java#L216-L221 |
actorapp/actor-platform | actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/util/images/ops/ImageLoading.java | ImageLoading.loadBitmapOptimized | public static Bitmap loadBitmapOptimized(Uri uri, Context context, int limit) throws ImageLoadException {
"""
Loading bitmap with optimized loaded size less than specific pixels count
@param uri content uri for bitmap
@param context Application Context
@param limit maximum pixels size
@return loaded bitmap (always not null)
@throws ImageLoadException if it is unable to load file
"""
return loadBitmapOptimized(new UriSource(uri, context) {
}, limit);
} | java | public static Bitmap loadBitmapOptimized(Uri uri, Context context, int limit) throws ImageLoadException {
return loadBitmapOptimized(new UriSource(uri, context) {
}, limit);
} | [
"public",
"static",
"Bitmap",
"loadBitmapOptimized",
"(",
"Uri",
"uri",
",",
"Context",
"context",
",",
"int",
"limit",
")",
"throws",
"ImageLoadException",
"{",
"return",
"loadBitmapOptimized",
"(",
"new",
"UriSource",
"(",
"uri",
",",
"context",
")",
"{",
"}",
",",
"limit",
")",
";",
"}"
] | Loading bitmap with optimized loaded size less than specific pixels count
@param uri content uri for bitmap
@param context Application Context
@param limit maximum pixels size
@return loaded bitmap (always not null)
@throws ImageLoadException if it is unable to load file | [
"Loading",
"bitmap",
"with",
"optimized",
"loaded",
"size",
"less",
"than",
"specific",
"pixels",
"count"
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/util/images/ops/ImageLoading.java#L144-L147 |
j256/ormlite-core | src/main/java/com/j256/ormlite/stmt/QueryBuilder.java | QueryBuilder.orderByRaw | public QueryBuilder<T, ID> orderByRaw(String rawSql) {
"""
Add raw SQL "ORDER BY" clause to the SQL query statement.
@param rawSql
The raw SQL order by clause. This should not include the "ORDER BY".
"""
addOrderBy(new OrderBy(rawSql, (ArgumentHolder[]) null));
return this;
} | java | public QueryBuilder<T, ID> orderByRaw(String rawSql) {
addOrderBy(new OrderBy(rawSql, (ArgumentHolder[]) null));
return this;
} | [
"public",
"QueryBuilder",
"<",
"T",
",",
"ID",
">",
"orderByRaw",
"(",
"String",
"rawSql",
")",
"{",
"addOrderBy",
"(",
"new",
"OrderBy",
"(",
"rawSql",
",",
"(",
"ArgumentHolder",
"[",
"]",
")",
"null",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add raw SQL "ORDER BY" clause to the SQL query statement.
@param rawSql
The raw SQL order by clause. This should not include the "ORDER BY". | [
"Add",
"raw",
"SQL",
"ORDER",
"BY",
"clause",
"to",
"the",
"SQL",
"query",
"statement",
"."
] | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/QueryBuilder.java#L190-L193 |
voldemort/voldemort | contrib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/HadoopStoreBuilderUtils.java | HadoopStoreBuilderUtils.readFileContents | public static String readFileContents(FileSystem fs, Path path, int bufferSize)
throws IOException {
"""
Given a filesystem, path and buffer-size, read the file contents and
presents it as a string
@param fs Underlying filesystem
@param path The file to read
@param bufferSize The buffer size to use for reading
@return The contents of the file as a string
@throws IOException
"""
if(bufferSize <= 0)
return new String();
FSDataInputStream input = fs.open(path);
byte[] buffer = new byte[bufferSize];
ByteArrayOutputStream stream = new ByteArrayOutputStream();
while(true) {
int read = input.read(buffer);
if(read < 0) {
break;
} else {
buffer = ByteUtils.copy(buffer, 0, read);
}
stream.write(buffer);
}
return new String(stream.toByteArray());
} | java | public static String readFileContents(FileSystem fs, Path path, int bufferSize)
throws IOException {
if(bufferSize <= 0)
return new String();
FSDataInputStream input = fs.open(path);
byte[] buffer = new byte[bufferSize];
ByteArrayOutputStream stream = new ByteArrayOutputStream();
while(true) {
int read = input.read(buffer);
if(read < 0) {
break;
} else {
buffer = ByteUtils.copy(buffer, 0, read);
}
stream.write(buffer);
}
return new String(stream.toByteArray());
} | [
"public",
"static",
"String",
"readFileContents",
"(",
"FileSystem",
"fs",
",",
"Path",
"path",
",",
"int",
"bufferSize",
")",
"throws",
"IOException",
"{",
"if",
"(",
"bufferSize",
"<=",
"0",
")",
"return",
"new",
"String",
"(",
")",
";",
"FSDataInputStream",
"input",
"=",
"fs",
".",
"open",
"(",
"path",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"bufferSize",
"]",
";",
"ByteArrayOutputStream",
"stream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"int",
"read",
"=",
"input",
".",
"read",
"(",
"buffer",
")",
";",
"if",
"(",
"read",
"<",
"0",
")",
"{",
"break",
";",
"}",
"else",
"{",
"buffer",
"=",
"ByteUtils",
".",
"copy",
"(",
"buffer",
",",
"0",
",",
"read",
")",
";",
"}",
"stream",
".",
"write",
"(",
"buffer",
")",
";",
"}",
"return",
"new",
"String",
"(",
"stream",
".",
"toByteArray",
"(",
")",
")",
";",
"}"
] | Given a filesystem, path and buffer-size, read the file contents and
presents it as a string
@param fs Underlying filesystem
@param path The file to read
@param bufferSize The buffer size to use for reading
@return The contents of the file as a string
@throws IOException | [
"Given",
"a",
"filesystem",
"path",
"and",
"buffer",
"-",
"size",
"read",
"the",
"file",
"contents",
"and",
"presents",
"it",
"as",
"a",
"string"
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/HadoopStoreBuilderUtils.java#L52-L73 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.updatePatternAnyEntityRoleWithServiceResponseAsync | public Observable<ServiceResponse<OperationStatus>> updatePatternAnyEntityRoleWithServiceResponseAsync(UUID appId, String versionId, UUID entityId, UUID roleId, UpdatePatternAnyEntityRoleOptionalParameter updatePatternAnyEntityRoleOptionalParameter) {
"""
Update an entity role for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity ID.
@param roleId The entity role ID.
@param updatePatternAnyEntityRoleOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object
"""
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
if (entityId == null) {
throw new IllegalArgumentException("Parameter entityId is required and cannot be null.");
}
if (roleId == null) {
throw new IllegalArgumentException("Parameter roleId is required and cannot be null.");
}
final String name = updatePatternAnyEntityRoleOptionalParameter != null ? updatePatternAnyEntityRoleOptionalParameter.name() : null;
return updatePatternAnyEntityRoleWithServiceResponseAsync(appId, versionId, entityId, roleId, name);
} | java | public Observable<ServiceResponse<OperationStatus>> updatePatternAnyEntityRoleWithServiceResponseAsync(UUID appId, String versionId, UUID entityId, UUID roleId, UpdatePatternAnyEntityRoleOptionalParameter updatePatternAnyEntityRoleOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
if (entityId == null) {
throw new IllegalArgumentException("Parameter entityId is required and cannot be null.");
}
if (roleId == null) {
throw new IllegalArgumentException("Parameter roleId is required and cannot be null.");
}
final String name = updatePatternAnyEntityRoleOptionalParameter != null ? updatePatternAnyEntityRoleOptionalParameter.name() : null;
return updatePatternAnyEntityRoleWithServiceResponseAsync(appId, versionId, entityId, roleId, name);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"OperationStatus",
">",
">",
"updatePatternAnyEntityRoleWithServiceResponseAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
",",
"UUID",
"roleId",
",",
"UpdatePatternAnyEntityRoleOptionalParameter",
"updatePatternAnyEntityRoleOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"endpoint",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.endpoint() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"appId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter appId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"versionId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter versionId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"entityId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter entityId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"roleId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter roleId is required and cannot be null.\"",
")",
";",
"}",
"final",
"String",
"name",
"=",
"updatePatternAnyEntityRoleOptionalParameter",
"!=",
"null",
"?",
"updatePatternAnyEntityRoleOptionalParameter",
".",
"name",
"(",
")",
":",
"null",
";",
"return",
"updatePatternAnyEntityRoleWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"entityId",
",",
"roleId",
",",
"name",
")",
";",
"}"
] | Update an entity role for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity ID.
@param roleId The entity role ID.
@param updatePatternAnyEntityRoleOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object | [
"Update",
"an",
"entity",
"role",
"for",
"a",
"given",
"entity",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L12908-L12927 |
Azure/azure-sdk-for-java | authorization/resource-manager/v2015_07_01/src/main/java/com/microsoft/azure/management/authorization/v2015_07_01/implementation/RoleAssignmentsInner.java | RoleAssignmentsInner.deleteAsync | public Observable<RoleAssignmentInner> deleteAsync(String scope, String roleAssignmentName) {
"""
Deletes a role assignment.
@param scope The scope of the role assignment to delete.
@param roleAssignmentName The name of the role assignment to delete.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the RoleAssignmentInner object
"""
return deleteWithServiceResponseAsync(scope, roleAssignmentName).map(new Func1<ServiceResponse<RoleAssignmentInner>, RoleAssignmentInner>() {
@Override
public RoleAssignmentInner call(ServiceResponse<RoleAssignmentInner> response) {
return response.body();
}
});
} | java | public Observable<RoleAssignmentInner> deleteAsync(String scope, String roleAssignmentName) {
return deleteWithServiceResponseAsync(scope, roleAssignmentName).map(new Func1<ServiceResponse<RoleAssignmentInner>, RoleAssignmentInner>() {
@Override
public RoleAssignmentInner call(ServiceResponse<RoleAssignmentInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"RoleAssignmentInner",
">",
"deleteAsync",
"(",
"String",
"scope",
",",
"String",
"roleAssignmentName",
")",
"{",
"return",
"deleteWithServiceResponseAsync",
"(",
"scope",
",",
"roleAssignmentName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"RoleAssignmentInner",
">",
",",
"RoleAssignmentInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"RoleAssignmentInner",
"call",
"(",
"ServiceResponse",
"<",
"RoleAssignmentInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Deletes a role assignment.
@param scope The scope of the role assignment to delete.
@param roleAssignmentName The name of the role assignment to delete.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the RoleAssignmentInner object | [
"Deletes",
"a",
"role",
"assignment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/authorization/resource-manager/v2015_07_01/src/main/java/com/microsoft/azure/management/authorization/v2015_07_01/implementation/RoleAssignmentsInner.java#L683-L690 |
puniverse/capsule | capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java | Jar.addEntries | public Jar addEntries(Path path, ZipInputStream zip, Filter filter) throws IOException {
"""
Adds the contents of the zip/JAR contained in the given byte array to this JAR.
@param path the path within the JAR where the root of the zip will be placed, or {@code null} for the JAR's root
@param zip the contents of the zip/JAR file
@param filter a filter to select particular classes
@return {@code this}
"""
beginWriting();
try (ZipInputStream zis = zip) {
for (ZipEntry entry; (entry = zis.getNextEntry()) != null;) {
final String target = path != null ? path.resolve(entry.getName()).toString() : entry.getName();
if (target.equals(MANIFEST_NAME))
continue;
if (filter == null || filter.filter(target))
addEntryNoClose(jos, target, zis);
}
}
return this;
} | java | public Jar addEntries(Path path, ZipInputStream zip, Filter filter) throws IOException {
beginWriting();
try (ZipInputStream zis = zip) {
for (ZipEntry entry; (entry = zis.getNextEntry()) != null;) {
final String target = path != null ? path.resolve(entry.getName()).toString() : entry.getName();
if (target.equals(MANIFEST_NAME))
continue;
if (filter == null || filter.filter(target))
addEntryNoClose(jos, target, zis);
}
}
return this;
} | [
"public",
"Jar",
"addEntries",
"(",
"Path",
"path",
",",
"ZipInputStream",
"zip",
",",
"Filter",
"filter",
")",
"throws",
"IOException",
"{",
"beginWriting",
"(",
")",
";",
"try",
"(",
"ZipInputStream",
"zis",
"=",
"zip",
")",
"{",
"for",
"(",
"ZipEntry",
"entry",
";",
"(",
"entry",
"=",
"zis",
".",
"getNextEntry",
"(",
")",
")",
"!=",
"null",
";",
")",
"{",
"final",
"String",
"target",
"=",
"path",
"!=",
"null",
"?",
"path",
".",
"resolve",
"(",
"entry",
".",
"getName",
"(",
")",
")",
".",
"toString",
"(",
")",
":",
"entry",
".",
"getName",
"(",
")",
";",
"if",
"(",
"target",
".",
"equals",
"(",
"MANIFEST_NAME",
")",
")",
"continue",
";",
"if",
"(",
"filter",
"==",
"null",
"||",
"filter",
".",
"filter",
"(",
"target",
")",
")",
"addEntryNoClose",
"(",
"jos",
",",
"target",
",",
"zis",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Adds the contents of the zip/JAR contained in the given byte array to this JAR.
@param path the path within the JAR where the root of the zip will be placed, or {@code null} for the JAR's root
@param zip the contents of the zip/JAR file
@param filter a filter to select particular classes
@return {@code this} | [
"Adds",
"the",
"contents",
"of",
"the",
"zip",
"/",
"JAR",
"contained",
"in",
"the",
"given",
"byte",
"array",
"to",
"this",
"JAR",
"."
] | train | https://github.com/puniverse/capsule/blob/291a54e501a32aaf0284707b8c1fbff6a566822b/capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java#L456-L468 |
ngageoint/geopackage-core-java | src/main/java/mil/nga/geopackage/extension/coverage/CoverageDataCore.java | CoverageDataCore.getFloatPixelValue | public float getFloatPixelValue(GriddedTile griddedTile, Double value) {
"""
Get the pixel value of the coverage data value
@param griddedTile
gridded tile
@param value
coverage data value
@return pixel value
"""
double pixel = 0;
if (value == null) {
if (griddedCoverage != null) {
pixel = griddedCoverage.getDataNull();
}
} else {
pixel = valueToPixelValue(griddedTile, value);
}
float pixelValue = (float) pixel;
return pixelValue;
} | java | public float getFloatPixelValue(GriddedTile griddedTile, Double value) {
double pixel = 0;
if (value == null) {
if (griddedCoverage != null) {
pixel = griddedCoverage.getDataNull();
}
} else {
pixel = valueToPixelValue(griddedTile, value);
}
float pixelValue = (float) pixel;
return pixelValue;
} | [
"public",
"float",
"getFloatPixelValue",
"(",
"GriddedTile",
"griddedTile",
",",
"Double",
"value",
")",
"{",
"double",
"pixel",
"=",
"0",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"if",
"(",
"griddedCoverage",
"!=",
"null",
")",
"{",
"pixel",
"=",
"griddedCoverage",
".",
"getDataNull",
"(",
")",
";",
"}",
"}",
"else",
"{",
"pixel",
"=",
"valueToPixelValue",
"(",
"griddedTile",
",",
"value",
")",
";",
"}",
"float",
"pixelValue",
"=",
"(",
"float",
")",
"pixel",
";",
"return",
"pixelValue",
";",
"}"
] | Get the pixel value of the coverage data value
@param griddedTile
gridded tile
@param value
coverage data value
@return pixel value | [
"Get",
"the",
"pixel",
"value",
"of",
"the",
"coverage",
"data",
"value"
] | train | https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/coverage/CoverageDataCore.java#L1666-L1680 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPUtils.java | JBBPUtils.ulong2str | public static String ulong2str(final long ulongValue, final int radix, final char[] charBuffer) {
"""
Convert unsigned long value into string representation with defined radix
base.
@param ulongValue value to be converted in string
@param radix radix base to be used for conversion, must be 2..36
@param charBuffer char buffer to be used for conversion operations, should
be not less than 64 char length, if length is less than 64 or null then new
one will be created
@return converted value as upper case string
@throws IllegalArgumentException for wrong radix base
@since 1.1
"""
if (radix < 2 || radix > 36) {
throw new IllegalArgumentException("Illegal radix [" + radix + ']');
}
if (ulongValue == 0) {
return "0";
} else {
final String result;
if (ulongValue > 0) {
result = Long.toString(ulongValue, radix).toUpperCase(Locale.ENGLISH);
} else {
final char[] buffer = charBuffer == null || charBuffer.length < 64 ? new char[64] : charBuffer;
int pos = buffer.length;
long topPart = ulongValue >>> 32;
long bottomPart = (ulongValue & 0xFFFFFFFFL) + ((topPart % radix) << 32);
topPart /= radix;
while ((bottomPart | topPart) > 0) {
final int val = (int) (bottomPart % radix);
buffer[--pos] = (char) (val < 10 ? '0' + val : 'A' + val - 10);
bottomPart = (bottomPart / radix) + ((topPart % radix) << 32);
topPart /= radix;
}
result = new String(buffer, pos, buffer.length - pos);
}
return result;
}
} | java | public static String ulong2str(final long ulongValue, final int radix, final char[] charBuffer) {
if (radix < 2 || radix > 36) {
throw new IllegalArgumentException("Illegal radix [" + radix + ']');
}
if (ulongValue == 0) {
return "0";
} else {
final String result;
if (ulongValue > 0) {
result = Long.toString(ulongValue, radix).toUpperCase(Locale.ENGLISH);
} else {
final char[] buffer = charBuffer == null || charBuffer.length < 64 ? new char[64] : charBuffer;
int pos = buffer.length;
long topPart = ulongValue >>> 32;
long bottomPart = (ulongValue & 0xFFFFFFFFL) + ((topPart % radix) << 32);
topPart /= radix;
while ((bottomPart | topPart) > 0) {
final int val = (int) (bottomPart % radix);
buffer[--pos] = (char) (val < 10 ? '0' + val : 'A' + val - 10);
bottomPart = (bottomPart / radix) + ((topPart % radix) << 32);
topPart /= radix;
}
result = new String(buffer, pos, buffer.length - pos);
}
return result;
}
} | [
"public",
"static",
"String",
"ulong2str",
"(",
"final",
"long",
"ulongValue",
",",
"final",
"int",
"radix",
",",
"final",
"char",
"[",
"]",
"charBuffer",
")",
"{",
"if",
"(",
"radix",
"<",
"2",
"||",
"radix",
">",
"36",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Illegal radix [\"",
"+",
"radix",
"+",
"'",
"'",
")",
";",
"}",
"if",
"(",
"ulongValue",
"==",
"0",
")",
"{",
"return",
"\"0\"",
";",
"}",
"else",
"{",
"final",
"String",
"result",
";",
"if",
"(",
"ulongValue",
">",
"0",
")",
"{",
"result",
"=",
"Long",
".",
"toString",
"(",
"ulongValue",
",",
"radix",
")",
".",
"toUpperCase",
"(",
"Locale",
".",
"ENGLISH",
")",
";",
"}",
"else",
"{",
"final",
"char",
"[",
"]",
"buffer",
"=",
"charBuffer",
"==",
"null",
"||",
"charBuffer",
".",
"length",
"<",
"64",
"?",
"new",
"char",
"[",
"64",
"]",
":",
"charBuffer",
";",
"int",
"pos",
"=",
"buffer",
".",
"length",
";",
"long",
"topPart",
"=",
"ulongValue",
">>>",
"32",
";",
"long",
"bottomPart",
"=",
"(",
"ulongValue",
"&",
"0xFFFFFFFF",
"L",
")",
"+",
"(",
"(",
"topPart",
"%",
"radix",
")",
"<<",
"32",
")",
";",
"topPart",
"/=",
"radix",
";",
"while",
"(",
"(",
"bottomPart",
"|",
"topPart",
")",
">",
"0",
")",
"{",
"final",
"int",
"val",
"=",
"(",
"int",
")",
"(",
"bottomPart",
"%",
"radix",
")",
";",
"buffer",
"[",
"--",
"pos",
"]",
"=",
"(",
"char",
")",
"(",
"val",
"<",
"10",
"?",
"'",
"'",
"+",
"val",
":",
"'",
"'",
"+",
"val",
"-",
"10",
")",
";",
"bottomPart",
"=",
"(",
"bottomPart",
"/",
"radix",
")",
"+",
"(",
"(",
"topPart",
"%",
"radix",
")",
"<<",
"32",
")",
";",
"topPart",
"/=",
"radix",
";",
"}",
"result",
"=",
"new",
"String",
"(",
"buffer",
",",
"pos",
",",
"buffer",
".",
"length",
"-",
"pos",
")",
";",
"}",
"return",
"result",
";",
"}",
"}"
] | Convert unsigned long value into string representation with defined radix
base.
@param ulongValue value to be converted in string
@param radix radix base to be used for conversion, must be 2..36
@param charBuffer char buffer to be used for conversion operations, should
be not less than 64 char length, if length is less than 64 or null then new
one will be created
@return converted value as upper case string
@throws IllegalArgumentException for wrong radix base
@since 1.1 | [
"Convert",
"unsigned",
"long",
"value",
"into",
"string",
"representation",
"with",
"defined",
"radix",
"base",
"."
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPUtils.java#L773-L800 |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/ContextRouter.java | ContextRouter.getPathEntry | private PathEntry getPathEntry(UriEntry uri) {
"""
get the final key with specified path
paths : return:
/a/b : /a/b
/a/* : /a/
/a/b/c : /a/b/c
/a/b/* : /a/b/
/a/b/ : /a/b/
"""
PathEntry pathEntry = new PathEntry( ContextRouter.MAP_PATH_TYPE, "default");
int length = uri.getLength();
// like /a or /
if ( length < 2) return pathEntry;
String requestUri = uri.getRequestUri();
String last_str = uri.get( length - 1 );
if ( last_str.equals("*") || last_str.equals("") ) {
// StringBuffer buffer = new StringBuffer();
// buffer.append('/');
//
// for(int i = 0; i < length - 1; i++)
// {
// buffer.append(uri.get(i) + "/");
// }
// position of last / charactor
int lastPosition = requestUri.lastIndexOf('/');
pathEntry.type = ContextRouter.MATCH_PATH_TYPE;
pathEntry.key = requestUri.substring(0, lastPosition + 1);
// @TODO maybe we should get parameters to pathEntry
} else {
pathEntry.key = requestUri;
}
return pathEntry;
} | java | private PathEntry getPathEntry(UriEntry uri)
{
PathEntry pathEntry = new PathEntry( ContextRouter.MAP_PATH_TYPE, "default");
int length = uri.getLength();
// like /a or /
if ( length < 2) return pathEntry;
String requestUri = uri.getRequestUri();
String last_str = uri.get( length - 1 );
if ( last_str.equals("*") || last_str.equals("") ) {
// StringBuffer buffer = new StringBuffer();
// buffer.append('/');
//
// for(int i = 0; i < length - 1; i++)
// {
// buffer.append(uri.get(i) + "/");
// }
// position of last / charactor
int lastPosition = requestUri.lastIndexOf('/');
pathEntry.type = ContextRouter.MATCH_PATH_TYPE;
pathEntry.key = requestUri.substring(0, lastPosition + 1);
// @TODO maybe we should get parameters to pathEntry
} else {
pathEntry.key = requestUri;
}
return pathEntry;
} | [
"private",
"PathEntry",
"getPathEntry",
"(",
"UriEntry",
"uri",
")",
"{",
"PathEntry",
"pathEntry",
"=",
"new",
"PathEntry",
"(",
"ContextRouter",
".",
"MAP_PATH_TYPE",
",",
"\"default\"",
")",
";",
"int",
"length",
"=",
"uri",
".",
"getLength",
"(",
")",
";",
"// like /a or /",
"if",
"(",
"length",
"<",
"2",
")",
"return",
"pathEntry",
";",
"String",
"requestUri",
"=",
"uri",
".",
"getRequestUri",
"(",
")",
";",
"String",
"last_str",
"=",
"uri",
".",
"get",
"(",
"length",
"-",
"1",
")",
";",
"if",
"(",
"last_str",
".",
"equals",
"(",
"\"*\"",
")",
"||",
"last_str",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"// StringBuffer buffer = new StringBuffer();",
"// buffer.append('/');",
"// ",
"// for(int i = 0; i < length - 1; i++)",
"// {",
"// buffer.append(uri.get(i) + \"/\");",
"// }",
"// position of last / charactor",
"int",
"lastPosition",
"=",
"requestUri",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"pathEntry",
".",
"type",
"=",
"ContextRouter",
".",
"MATCH_PATH_TYPE",
";",
"pathEntry",
".",
"key",
"=",
"requestUri",
".",
"substring",
"(",
"0",
",",
"lastPosition",
"+",
"1",
")",
";",
"// @TODO maybe we should get parameters to pathEntry",
"}",
"else",
"{",
"pathEntry",
".",
"key",
"=",
"requestUri",
";",
"}",
"return",
"pathEntry",
";",
"}"
] | get the final key with specified path
paths : return:
/a/b : /a/b
/a/* : /a/
/a/b/c : /a/b/c
/a/b/* : /a/b/
/a/b/ : /a/b/ | [
"get",
"the",
"final",
"key",
"with",
"specified",
"path"
] | train | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/ContextRouter.java#L59-L93 |
grpc/grpc-java | alts/src/main/java/io/grpc/alts/AltsChannelBuilder.java | AltsChannelBuilder.forAddress | public static AltsChannelBuilder forAddress(String name, int port) {
"""
"Overrides" the static method in {@link ManagedChannelBuilder}.
"""
return forTarget(GrpcUtil.authorityFromHostAndPort(name, port));
} | java | public static AltsChannelBuilder forAddress(String name, int port) {
return forTarget(GrpcUtil.authorityFromHostAndPort(name, port));
} | [
"public",
"static",
"AltsChannelBuilder",
"forAddress",
"(",
"String",
"name",
",",
"int",
"port",
")",
"{",
"return",
"forTarget",
"(",
"GrpcUtil",
".",
"authorityFromHostAndPort",
"(",
"name",
",",
"port",
")",
")",
";",
"}"
] | "Overrides" the static method in {@link ManagedChannelBuilder}. | [
"Overrides",
"the",
"static",
"method",
"in",
"{"
] | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/AltsChannelBuilder.java#L71-L73 |
hypfvieh/java-utils | src/main/java/com/github/hypfvieh/util/xml/XmlUtil.java | XmlUtil.parseXmlStringWithXsdValidation | public static Document parseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware, ErrorHandler _errorHandler) throws IOException {
"""
Loads XML from string and uses referenced XSD to validate the content.
@param _xmlStr string to validate
@param _namespaceAware take care of namespace
@param _errorHandler e.g. {@link XmlErrorHandlers.XmlErrorHandlerQuiet} or {@link XmlErrorHandlers.XmlErrorHandlerRuntimeException}
@return Document
@throws IOException on error
"""
if (_errorHandler == null) {
_errorHandler = new XmlErrorHandlers.XmlErrorHandlerQuiet();
}
DocumentBuilderFactory dbFac = DocumentBuilderFactory.newInstance();
dbFac.setValidating(true);
dbFac.setNamespaceAware(_namespaceAware);
dbFac.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
try {
DocumentBuilder builder = dbFac.newDocumentBuilder();
builder.setErrorHandler(_errorHandler);
return builder.parse(new ByteArrayInputStream(_xmlStr.getBytes(StandardCharsets.UTF_8)));
} catch (IOException _ex) {
throw _ex;
} catch (Exception _ex) {
throw new IOException("Failed to parse " + StringUtil.abbreviate(_xmlStr, 500), _ex);
}
} | java | public static Document parseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware, ErrorHandler _errorHandler) throws IOException {
if (_errorHandler == null) {
_errorHandler = new XmlErrorHandlers.XmlErrorHandlerQuiet();
}
DocumentBuilderFactory dbFac = DocumentBuilderFactory.newInstance();
dbFac.setValidating(true);
dbFac.setNamespaceAware(_namespaceAware);
dbFac.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
try {
DocumentBuilder builder = dbFac.newDocumentBuilder();
builder.setErrorHandler(_errorHandler);
return builder.parse(new ByteArrayInputStream(_xmlStr.getBytes(StandardCharsets.UTF_8)));
} catch (IOException _ex) {
throw _ex;
} catch (Exception _ex) {
throw new IOException("Failed to parse " + StringUtil.abbreviate(_xmlStr, 500), _ex);
}
} | [
"public",
"static",
"Document",
"parseXmlStringWithXsdValidation",
"(",
"String",
"_xmlStr",
",",
"boolean",
"_namespaceAware",
",",
"ErrorHandler",
"_errorHandler",
")",
"throws",
"IOException",
"{",
"if",
"(",
"_errorHandler",
"==",
"null",
")",
"{",
"_errorHandler",
"=",
"new",
"XmlErrorHandlers",
".",
"XmlErrorHandlerQuiet",
"(",
")",
";",
"}",
"DocumentBuilderFactory",
"dbFac",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"dbFac",
".",
"setValidating",
"(",
"true",
")",
";",
"dbFac",
".",
"setNamespaceAware",
"(",
"_namespaceAware",
")",
";",
"dbFac",
".",
"setAttribute",
"(",
"\"http://java.sun.com/xml/jaxp/properties/schemaLanguage\"",
",",
"\"http://www.w3.org/2001/XMLSchema\"",
")",
";",
"try",
"{",
"DocumentBuilder",
"builder",
"=",
"dbFac",
".",
"newDocumentBuilder",
"(",
")",
";",
"builder",
".",
"setErrorHandler",
"(",
"_errorHandler",
")",
";",
"return",
"builder",
".",
"parse",
"(",
"new",
"ByteArrayInputStream",
"(",
"_xmlStr",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"throw",
"_ex",
";",
"}",
"catch",
"(",
"Exception",
"_ex",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to parse \"",
"+",
"StringUtil",
".",
"abbreviate",
"(",
"_xmlStr",
",",
"500",
")",
",",
"_ex",
")",
";",
"}",
"}"
] | Loads XML from string and uses referenced XSD to validate the content.
@param _xmlStr string to validate
@param _namespaceAware take care of namespace
@param _errorHandler e.g. {@link XmlErrorHandlers.XmlErrorHandlerQuiet} or {@link XmlErrorHandlers.XmlErrorHandlerRuntimeException}
@return Document
@throws IOException on error | [
"Loads",
"XML",
"from",
"string",
"and",
"uses",
"referenced",
"XSD",
"to",
"validate",
"the",
"content",
"."
] | train | https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/xml/XmlUtil.java#L167-L186 |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/util/LayoutUtils.java | LayoutUtils.copyBandElements | public static void copyBandElements(JRDesignBand destBand, JRBand sourceBand) {
"""
Copy bands elements from source to dest band, also makes sure copied elements
are placed below existing ones (Y offset is calculated)
@param destBand
@param sourceBand
"""
int offset = findVerticalOffset(destBand);
if (destBand == null)
throw new DJException("destination band cannot be null");
if (sourceBand == null)
return;
for (JRChild jrChild : sourceBand.getChildren()) {
JRDesignElement element = (JRDesignElement) jrChild;
JRDesignElement dest = null;
try {
if (element instanceof JRDesignGraphicElement) {
Constructor<? extends JRDesignElement> constructor = element.getClass().getConstructor(JRDefaultStyleProvider.class);
JRDesignStyle style = new JRDesignStyle();
dest = constructor.newInstance(style.getDefaultStyleProvider());
} else {
dest = element.getClass().newInstance();
}
BeanUtils.copyProperties(dest, element);
dest.setY(dest.getY() + offset);
} catch (Exception e) {
log.error("Exception copying elements from band to band: " + e.getMessage(), e);
}
destBand.addElement(dest);
}
} | java | public static void copyBandElements(JRDesignBand destBand, JRBand sourceBand) {
int offset = findVerticalOffset(destBand);
if (destBand == null)
throw new DJException("destination band cannot be null");
if (sourceBand == null)
return;
for (JRChild jrChild : sourceBand.getChildren()) {
JRDesignElement element = (JRDesignElement) jrChild;
JRDesignElement dest = null;
try {
if (element instanceof JRDesignGraphicElement) {
Constructor<? extends JRDesignElement> constructor = element.getClass().getConstructor(JRDefaultStyleProvider.class);
JRDesignStyle style = new JRDesignStyle();
dest = constructor.newInstance(style.getDefaultStyleProvider());
} else {
dest = element.getClass().newInstance();
}
BeanUtils.copyProperties(dest, element);
dest.setY(dest.getY() + offset);
} catch (Exception e) {
log.error("Exception copying elements from band to band: " + e.getMessage(), e);
}
destBand.addElement(dest);
}
} | [
"public",
"static",
"void",
"copyBandElements",
"(",
"JRDesignBand",
"destBand",
",",
"JRBand",
"sourceBand",
")",
"{",
"int",
"offset",
"=",
"findVerticalOffset",
"(",
"destBand",
")",
";",
"if",
"(",
"destBand",
"==",
"null",
")",
"throw",
"new",
"DJException",
"(",
"\"destination band cannot be null\"",
")",
";",
"if",
"(",
"sourceBand",
"==",
"null",
")",
"return",
";",
"for",
"(",
"JRChild",
"jrChild",
":",
"sourceBand",
".",
"getChildren",
"(",
")",
")",
"{",
"JRDesignElement",
"element",
"=",
"(",
"JRDesignElement",
")",
"jrChild",
";",
"JRDesignElement",
"dest",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"element",
"instanceof",
"JRDesignGraphicElement",
")",
"{",
"Constructor",
"<",
"?",
"extends",
"JRDesignElement",
">",
"constructor",
"=",
"element",
".",
"getClass",
"(",
")",
".",
"getConstructor",
"(",
"JRDefaultStyleProvider",
".",
"class",
")",
";",
"JRDesignStyle",
"style",
"=",
"new",
"JRDesignStyle",
"(",
")",
";",
"dest",
"=",
"constructor",
".",
"newInstance",
"(",
"style",
".",
"getDefaultStyleProvider",
"(",
")",
")",
";",
"}",
"else",
"{",
"dest",
"=",
"element",
".",
"getClass",
"(",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"BeanUtils",
".",
"copyProperties",
"(",
"dest",
",",
"element",
")",
";",
"dest",
".",
"setY",
"(",
"dest",
".",
"getY",
"(",
")",
"+",
"offset",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Exception copying elements from band to band: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"destBand",
".",
"addElement",
"(",
"dest",
")",
";",
"}",
"}"
] | Copy bands elements from source to dest band, also makes sure copied elements
are placed below existing ones (Y offset is calculated)
@param destBand
@param sourceBand | [
"Copy",
"bands",
"elements",
"from",
"source",
"to",
"dest",
"band",
"also",
"makes",
"sure",
"copied",
"elements",
"are",
"placed",
"below",
"existing",
"ones",
"(",
"Y",
"offset",
"is",
"calculated",
")"
] | train | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/util/LayoutUtils.java#L54-L82 |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/FormatUtilities.java | FormatUtilities.getFormattedDateTime | static public String getFormattedDateTime(long dt, String format, long tolerance) {
"""
Returns the given date formatted using the given format.
@param dt The date to be formatted
@param format The format to use to display the date
@param tolerance The tolerance for the date to be formatted
@return The given date formatted using the given format
"""
return getFormattedDateTime(dt, format, true, tolerance);
} | java | static public String getFormattedDateTime(long dt, String format, long tolerance)
{
return getFormattedDateTime(dt, format, true, tolerance);
} | [
"static",
"public",
"String",
"getFormattedDateTime",
"(",
"long",
"dt",
",",
"String",
"format",
",",
"long",
"tolerance",
")",
"{",
"return",
"getFormattedDateTime",
"(",
"dt",
",",
"format",
",",
"true",
",",
"tolerance",
")",
";",
"}"
] | Returns the given date formatted using the given format.
@param dt The date to be formatted
@param format The format to use to display the date
@param tolerance The tolerance for the date to be formatted
@return The given date formatted using the given format | [
"Returns",
"the",
"given",
"date",
"formatted",
"using",
"the",
"given",
"format",
"."
] | train | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/FormatUtilities.java#L121-L124 |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/HttpConnection.java | HttpConnection.setHttpsInfo | public HttpConnection setHttpsInfo(HostnameVerifier hostnameVerifier, SSLSocketFactory ssf) throws HttpException {
"""
设置https请求参数<br>
有些时候htts请求会出现com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl的实现,此为sun内部api,按照普通http请求处理
@param hostnameVerifier 域名验证器,非https传入null
@param ssf SSLSocketFactory,非https传入null
@return this
@throws HttpException KeyManagementException和NoSuchAlgorithmException异常包装
"""
final HttpURLConnection conn = this.conn;
if (conn instanceof HttpsURLConnection) {
// Https请求
final HttpsURLConnection httpsConn = (HttpsURLConnection) conn;
// 验证域
httpsConn.setHostnameVerifier(null != hostnameVerifier ? hostnameVerifier : new TrustAnyHostnameVerifier());
if (null == ssf) {
try {
if (StrUtil.equalsIgnoreCase("dalvik", System.getProperty("java.vm.name"))) {
// 兼容android低版本SSL连接
ssf = new AndroidSupportSSLFactory();
} else {
ssf = SSLSocketFactoryBuilder.create().build();
}
} catch (KeyManagementException | NoSuchAlgorithmException e) {
throw new HttpException(e);
}
}
httpsConn.setSSLSocketFactory(ssf);
}
return this;
} | java | public HttpConnection setHttpsInfo(HostnameVerifier hostnameVerifier, SSLSocketFactory ssf) throws HttpException {
final HttpURLConnection conn = this.conn;
if (conn instanceof HttpsURLConnection) {
// Https请求
final HttpsURLConnection httpsConn = (HttpsURLConnection) conn;
// 验证域
httpsConn.setHostnameVerifier(null != hostnameVerifier ? hostnameVerifier : new TrustAnyHostnameVerifier());
if (null == ssf) {
try {
if (StrUtil.equalsIgnoreCase("dalvik", System.getProperty("java.vm.name"))) {
// 兼容android低版本SSL连接
ssf = new AndroidSupportSSLFactory();
} else {
ssf = SSLSocketFactoryBuilder.create().build();
}
} catch (KeyManagementException | NoSuchAlgorithmException e) {
throw new HttpException(e);
}
}
httpsConn.setSSLSocketFactory(ssf);
}
return this;
} | [
"public",
"HttpConnection",
"setHttpsInfo",
"(",
"HostnameVerifier",
"hostnameVerifier",
",",
"SSLSocketFactory",
"ssf",
")",
"throws",
"HttpException",
"{",
"final",
"HttpURLConnection",
"conn",
"=",
"this",
".",
"conn",
";",
"if",
"(",
"conn",
"instanceof",
"HttpsURLConnection",
")",
"{",
"// Https请求\r",
"final",
"HttpsURLConnection",
"httpsConn",
"=",
"(",
"HttpsURLConnection",
")",
"conn",
";",
"// 验证域\r",
"httpsConn",
".",
"setHostnameVerifier",
"(",
"null",
"!=",
"hostnameVerifier",
"?",
"hostnameVerifier",
":",
"new",
"TrustAnyHostnameVerifier",
"(",
")",
")",
";",
"if",
"(",
"null",
"==",
"ssf",
")",
"{",
"try",
"{",
"if",
"(",
"StrUtil",
".",
"equalsIgnoreCase",
"(",
"\"dalvik\"",
",",
"System",
".",
"getProperty",
"(",
"\"java.vm.name\"",
")",
")",
")",
"{",
"// 兼容android低版本SSL连接\r",
"ssf",
"=",
"new",
"AndroidSupportSSLFactory",
"(",
")",
";",
"}",
"else",
"{",
"ssf",
"=",
"SSLSocketFactoryBuilder",
".",
"create",
"(",
")",
".",
"build",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"KeyManagementException",
"|",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"HttpException",
"(",
"e",
")",
";",
"}",
"}",
"httpsConn",
".",
"setSSLSocketFactory",
"(",
"ssf",
")",
";",
"}",
"return",
"this",
";",
"}"
] | 设置https请求参数<br>
有些时候htts请求会出现com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl的实现,此为sun内部api,按照普通http请求处理
@param hostnameVerifier 域名验证器,非https传入null
@param ssf SSLSocketFactory,非https传入null
@return this
@throws HttpException KeyManagementException和NoSuchAlgorithmException异常包装 | [
"设置https请求参数<br",
">",
"有些时候htts请求会出现com",
".",
"sun",
".",
"net",
".",
"ssl",
".",
"internal",
".",
"www",
".",
"protocol",
".",
"https",
".",
"HttpsURLConnectionOldImpl的实现,此为sun内部api,按照普通http请求处理"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpConnection.java#L261-L285 |
Jasig/uPortal | uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/groups/ReferenceCompositeGroupService.java | ReferenceCompositeGroupService.getGroupMember | @Override
public IGroupMember getGroupMember(String key, Class type) throws GroupsException {
"""
Returns an <code>IGroupMember</code> representing either a group or a portal entity. If the
parm <code>type</code> is the group type, the <code>IGroupMember</code> is an <code>
IEntityGroup</code> else it is an <code>IEntity</code>.
"""
IGroupMember gm = null;
if (type == ICompositeGroupService.GROUP_ENTITY_TYPE) gm = findGroup(key);
else gm = getEntity(key, type);
return gm;
} | java | @Override
public IGroupMember getGroupMember(String key, Class type) throws GroupsException {
IGroupMember gm = null;
if (type == ICompositeGroupService.GROUP_ENTITY_TYPE) gm = findGroup(key);
else gm = getEntity(key, type);
return gm;
} | [
"@",
"Override",
"public",
"IGroupMember",
"getGroupMember",
"(",
"String",
"key",
",",
"Class",
"type",
")",
"throws",
"GroupsException",
"{",
"IGroupMember",
"gm",
"=",
"null",
";",
"if",
"(",
"type",
"==",
"ICompositeGroupService",
".",
"GROUP_ENTITY_TYPE",
")",
"gm",
"=",
"findGroup",
"(",
"key",
")",
";",
"else",
"gm",
"=",
"getEntity",
"(",
"key",
",",
"type",
")",
";",
"return",
"gm",
";",
"}"
] | Returns an <code>IGroupMember</code> representing either a group or a portal entity. If the
parm <code>type</code> is the group type, the <code>IGroupMember</code> is an <code>
IEntityGroup</code> else it is an <code>IEntity</code>. | [
"Returns",
"an",
"<code",
">",
"IGroupMember<",
"/",
"code",
">",
"representing",
"either",
"a",
"group",
"or",
"a",
"portal",
"entity",
".",
"If",
"the",
"parm",
"<code",
">",
"type<",
"/",
"code",
">",
"is",
"the",
"group",
"type",
"the",
"<code",
">",
"IGroupMember<",
"/",
"code",
">",
"is",
"an",
"<code",
">",
"IEntityGroup<",
"/",
"code",
">",
"else",
"it",
"is",
"an",
"<code",
">",
"IEntity<",
"/",
"code",
">",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/groups/ReferenceCompositeGroupService.java#L135-L141 |
buschmais/extended-objects | impl/src/main/java/com/buschmais/xo/impl/cache/TransactionalCache.java | TransactionalCache.get | public Object get(Id id, Mode mode) {
"""
Lookup an instance in the cache identified by its id.
@param id
The id.
@param mode
The mode.
@return The corresponding instance or <code>null</code> if no instance is
available.
"""
Object value = writeCache.get(id);
if (value == null) {
value = readCache.get(new CacheKey(id));
if (value != null && Mode.WRITE.equals(mode)) {
writeCache.put(id, value);
}
}
return value;
} | java | public Object get(Id id, Mode mode) {
Object value = writeCache.get(id);
if (value == null) {
value = readCache.get(new CacheKey(id));
if (value != null && Mode.WRITE.equals(mode)) {
writeCache.put(id, value);
}
}
return value;
} | [
"public",
"Object",
"get",
"(",
"Id",
"id",
",",
"Mode",
"mode",
")",
"{",
"Object",
"value",
"=",
"writeCache",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"readCache",
".",
"get",
"(",
"new",
"CacheKey",
"(",
"id",
")",
")",
";",
"if",
"(",
"value",
"!=",
"null",
"&&",
"Mode",
".",
"WRITE",
".",
"equals",
"(",
"mode",
")",
")",
"{",
"writeCache",
".",
"put",
"(",
"id",
",",
"value",
")",
";",
"}",
"}",
"return",
"value",
";",
"}"
] | Lookup an instance in the cache identified by its id.
@param id
The id.
@param mode
The mode.
@return The corresponding instance or <code>null</code> if no instance is
available. | [
"Lookup",
"an",
"instance",
"in",
"the",
"cache",
"identified",
"by",
"its",
"id",
"."
] | train | https://github.com/buschmais/extended-objects/blob/186431e81f3d8d26c511cfe1143dee59b03c2e7a/impl/src/main/java/com/buschmais/xo/impl/cache/TransactionalCache.java#L83-L92 |
protobufel/protobuf-el | protobufel/src/main/java/com/github/protobufel/RepeatedFieldBuilder.java | RepeatedFieldBuilder.getMessage | private MType getMessage(final int index, final boolean forBuild) {
"""
Get the message at the specified index. If the message is currently stored as a {@code Builder}
, it is converted to a {@code Message} by calling {@link Message.Builder#buildPartial} on it.
@param index the index of the message to get
@param forBuild this is being called for build so we want to make sure we
SingleFieldBuilder.build to send dirty invalidations
@return the message for the specified index
"""
if (this.builders == null) {
// We don't have any builders -- return the current Message.
// This is the case where no builder was created, so we MUST have a
// Message.
return messages.get(index);
}
final SingleFieldBuilder<MType, BType, IType> builder = builders.get(index);
if (builder == null) {
// We don't have a builder -- return the current message.
// This is the case where no builder was created for the entry at index,
// so we MUST have a message.
return messages.get(index);
} else {
return forBuild ? builder.build() : builder.getMessage();
}
} | java | private MType getMessage(final int index, final boolean forBuild) {
if (this.builders == null) {
// We don't have any builders -- return the current Message.
// This is the case where no builder was created, so we MUST have a
// Message.
return messages.get(index);
}
final SingleFieldBuilder<MType, BType, IType> builder = builders.get(index);
if (builder == null) {
// We don't have a builder -- return the current message.
// This is the case where no builder was created for the entry at index,
// so we MUST have a message.
return messages.get(index);
} else {
return forBuild ? builder.build() : builder.getMessage();
}
} | [
"private",
"MType",
"getMessage",
"(",
"final",
"int",
"index",
",",
"final",
"boolean",
"forBuild",
")",
"{",
"if",
"(",
"this",
".",
"builders",
"==",
"null",
")",
"{",
"// We don't have any builders -- return the current Message.\r",
"// This is the case where no builder was created, so we MUST have a\r",
"// Message.\r",
"return",
"messages",
".",
"get",
"(",
"index",
")",
";",
"}",
"final",
"SingleFieldBuilder",
"<",
"MType",
",",
"BType",
",",
"IType",
">",
"builder",
"=",
"builders",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"builder",
"==",
"null",
")",
"{",
"// We don't have a builder -- return the current message.\r",
"// This is the case where no builder was created for the entry at index,\r",
"// so we MUST have a message.\r",
"return",
"messages",
".",
"get",
"(",
"index",
")",
";",
"}",
"else",
"{",
"return",
"forBuild",
"?",
"builder",
".",
"build",
"(",
")",
":",
"builder",
".",
"getMessage",
"(",
")",
";",
"}",
"}"
] | Get the message at the specified index. If the message is currently stored as a {@code Builder}
, it is converted to a {@code Message} by calling {@link Message.Builder#buildPartial} on it.
@param index the index of the message to get
@param forBuild this is being called for build so we want to make sure we
SingleFieldBuilder.build to send dirty invalidations
@return the message for the specified index | [
"Get",
"the",
"message",
"at",
"the",
"specified",
"index",
".",
"If",
"the",
"message",
"is",
"currently",
"stored",
"as",
"a",
"{",
"@code",
"Builder",
"}",
"it",
"is",
"converted",
"to",
"a",
"{",
"@code",
"Message",
"}",
"by",
"calling",
"{",
"@link",
"Message",
".",
"Builder#buildPartial",
"}",
"on",
"it",
"."
] | train | https://github.com/protobufel/protobuf-el/blob/3a600e2f7a8e74b637f44eee0331ef6e57e7441c/protobufel/src/main/java/com/github/protobufel/RepeatedFieldBuilder.java#L215-L233 |
rundeck/rundeck | examples/example-java-step-plugin/src/main/java/com/dtolabs/rundeck/plugin/example/ExampleNodeStepPlugin.java | ExampleNodeStepPlugin.executeNodeStep | public void executeNodeStep(final PluginStepContext context,
final Map<String, Object> configuration,
final INodeEntry entry) throws NodeStepException {
"""
The {@link #performNodeStep(com.dtolabs.rundeck.plugins.step.PluginStepContext,
com.dtolabs.rundeck.core.common.INodeEntry)} method is invoked when your plugin should perform its logic for the
appropriate node. The {@link PluginStepContext} provides access to the configuration of the plugin, and details
about the step number and context.
<p/>
The {@link INodeEntry} parameter is the node that should be executed on. Your plugin should make use of the
node's attributes (such has "hostname" or any others required by your plugin) to perform the appropriate action.
"""
System.out.println("Example node step executing on node: " + entry.getNodename());
System.out.println("Example step extra config: " + configuration);
System.out.println("Example step num: " + context.getStepNumber());
System.out.println("Example step context: " + context.getStepContext());
if ("true".equals(configuration.get("pancake"))) {
//throw exception indicating the cause of the error
throw new NodeStepException("pancake was true", Reason.PancakeReason, entry.getNodename());
}
} | java | public void executeNodeStep(final PluginStepContext context,
final Map<String, Object> configuration,
final INodeEntry entry) throws NodeStepException {
System.out.println("Example node step executing on node: " + entry.getNodename());
System.out.println("Example step extra config: " + configuration);
System.out.println("Example step num: " + context.getStepNumber());
System.out.println("Example step context: " + context.getStepContext());
if ("true".equals(configuration.get("pancake"))) {
//throw exception indicating the cause of the error
throw new NodeStepException("pancake was true", Reason.PancakeReason, entry.getNodename());
}
} | [
"public",
"void",
"executeNodeStep",
"(",
"final",
"PluginStepContext",
"context",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"configuration",
",",
"final",
"INodeEntry",
"entry",
")",
"throws",
"NodeStepException",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Example node step executing on node: \"",
"+",
"entry",
".",
"getNodename",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Example step extra config: \"",
"+",
"configuration",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Example step num: \"",
"+",
"context",
".",
"getStepNumber",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Example step context: \"",
"+",
"context",
".",
"getStepContext",
"(",
")",
")",
";",
"if",
"(",
"\"true\"",
".",
"equals",
"(",
"configuration",
".",
"get",
"(",
"\"pancake\"",
")",
")",
")",
"{",
"//throw exception indicating the cause of the error",
"throw",
"new",
"NodeStepException",
"(",
"\"pancake was true\"",
",",
"Reason",
".",
"PancakeReason",
",",
"entry",
".",
"getNodename",
"(",
")",
")",
";",
"}",
"}"
] | The {@link #performNodeStep(com.dtolabs.rundeck.plugins.step.PluginStepContext,
com.dtolabs.rundeck.core.common.INodeEntry)} method is invoked when your plugin should perform its logic for the
appropriate node. The {@link PluginStepContext} provides access to the configuration of the plugin, and details
about the step number and context.
<p/>
The {@link INodeEntry} parameter is the node that should be executed on. Your plugin should make use of the
node's attributes (such has "hostname" or any others required by your plugin) to perform the appropriate action. | [
"The",
"{"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/examples/example-java-step-plugin/src/main/java/com/dtolabs/rundeck/plugin/example/ExampleNodeStepPlugin.java#L129-L141 |
OpenTSDB/opentsdb | src/tools/Fsck.java | Fsck.runFullTable | public void runFullTable() throws Exception {
"""
Fetches the max metric ID and splits the data table up amongst threads on
a naive split. By default we execute cores * 2 threads but the user can
specify more or fewer.
@throws Exception If something goes pear shaped.
"""
LOG.info("Starting full table scan");
final long start_time = System.currentTimeMillis() / 1000;
final int workers = options.threads() > 0 ? options.threads() :
Runtime.getRuntime().availableProcessors() * 2;
final List<Scanner> scanners = CliUtils.getDataTableScanners(tsdb, workers);
LOG.info("Spooling up [" + scanners.size() + "] worker threads");
final List<Thread> threads = new ArrayList<Thread>(scanners.size());
int i = 0;
for (final Scanner scanner : scanners) {
final FsckWorker worker = new FsckWorker(scanner, i++, this.options);
worker.setName("Fsck #" + i);
worker.start();
threads.add(worker);
}
final Thread reporter = new ProgressReporter();
reporter.start();
for (final Thread thread : threads) {
thread.join();
LOG.info("Thread [" + thread + "] Finished");
}
reporter.interrupt();
logResults();
final long duration = (System.currentTimeMillis() / 1000) - start_time;
LOG.info("Completed fsck in [" + duration + "] seconds");
} | java | public void runFullTable() throws Exception {
LOG.info("Starting full table scan");
final long start_time = System.currentTimeMillis() / 1000;
final int workers = options.threads() > 0 ? options.threads() :
Runtime.getRuntime().availableProcessors() * 2;
final List<Scanner> scanners = CliUtils.getDataTableScanners(tsdb, workers);
LOG.info("Spooling up [" + scanners.size() + "] worker threads");
final List<Thread> threads = new ArrayList<Thread>(scanners.size());
int i = 0;
for (final Scanner scanner : scanners) {
final FsckWorker worker = new FsckWorker(scanner, i++, this.options);
worker.setName("Fsck #" + i);
worker.start();
threads.add(worker);
}
final Thread reporter = new ProgressReporter();
reporter.start();
for (final Thread thread : threads) {
thread.join();
LOG.info("Thread [" + thread + "] Finished");
}
reporter.interrupt();
logResults();
final long duration = (System.currentTimeMillis() / 1000) - start_time;
LOG.info("Completed fsck in [" + duration + "] seconds");
} | [
"public",
"void",
"runFullTable",
"(",
")",
"throws",
"Exception",
"{",
"LOG",
".",
"info",
"(",
"\"Starting full table scan\"",
")",
";",
"final",
"long",
"start_time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"/",
"1000",
";",
"final",
"int",
"workers",
"=",
"options",
".",
"threads",
"(",
")",
">",
"0",
"?",
"options",
".",
"threads",
"(",
")",
":",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"availableProcessors",
"(",
")",
"*",
"2",
";",
"final",
"List",
"<",
"Scanner",
">",
"scanners",
"=",
"CliUtils",
".",
"getDataTableScanners",
"(",
"tsdb",
",",
"workers",
")",
";",
"LOG",
".",
"info",
"(",
"\"Spooling up [\"",
"+",
"scanners",
".",
"size",
"(",
")",
"+",
"\"] worker threads\"",
")",
";",
"final",
"List",
"<",
"Thread",
">",
"threads",
"=",
"new",
"ArrayList",
"<",
"Thread",
">",
"(",
"scanners",
".",
"size",
"(",
")",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"Scanner",
"scanner",
":",
"scanners",
")",
"{",
"final",
"FsckWorker",
"worker",
"=",
"new",
"FsckWorker",
"(",
"scanner",
",",
"i",
"++",
",",
"this",
".",
"options",
")",
";",
"worker",
".",
"setName",
"(",
"\"Fsck #\"",
"+",
"i",
")",
";",
"worker",
".",
"start",
"(",
")",
";",
"threads",
".",
"add",
"(",
"worker",
")",
";",
"}",
"final",
"Thread",
"reporter",
"=",
"new",
"ProgressReporter",
"(",
")",
";",
"reporter",
".",
"start",
"(",
")",
";",
"for",
"(",
"final",
"Thread",
"thread",
":",
"threads",
")",
"{",
"thread",
".",
"join",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Thread [\"",
"+",
"thread",
"+",
"\"] Finished\"",
")",
";",
"}",
"reporter",
".",
"interrupt",
"(",
")",
";",
"logResults",
"(",
")",
";",
"final",
"long",
"duration",
"=",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"/",
"1000",
")",
"-",
"start_time",
";",
"LOG",
".",
"info",
"(",
"\"Completed fsck in [\"",
"+",
"duration",
"+",
"\"] seconds\"",
")",
";",
"}"
] | Fetches the max metric ID and splits the data table up amongst threads on
a naive split. By default we execute cores * 2 threads but the user can
specify more or fewer.
@throws Exception If something goes pear shaped. | [
"Fetches",
"the",
"max",
"metric",
"ID",
"and",
"splits",
"the",
"data",
"table",
"up",
"amongst",
"threads",
"on",
"a",
"naive",
"split",
".",
"By",
"default",
"we",
"execute",
"cores",
"*",
"2",
"threads",
"but",
"the",
"user",
"can",
"specify",
"more",
"or",
"fewer",
"."
] | train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/Fsck.java#L147-L175 |
pravega/pravega | segmentstore/storage/impl/src/main/java/io/pravega/segmentstore/storage/impl/bookkeeper/WriteQueue.java | WriteQueue.calculateFillRatio | private static double calculateFillRatio(long totalLength, int size) {
"""
Calculates the FillRatio, which is a number between [0, 1] that represents the average fill of each
write with respect to the maximum BookKeeper write allowance.
@param totalLength Total length of the writes.
@param size Total number of writes.
"""
if (size > 0) {
return Math.min(1, (double) totalLength / size / BookKeeperConfig.MAX_APPEND_LENGTH);
} else {
return 0;
}
} | java | private static double calculateFillRatio(long totalLength, int size) {
if (size > 0) {
return Math.min(1, (double) totalLength / size / BookKeeperConfig.MAX_APPEND_LENGTH);
} else {
return 0;
}
} | [
"private",
"static",
"double",
"calculateFillRatio",
"(",
"long",
"totalLength",
",",
"int",
"size",
")",
"{",
"if",
"(",
"size",
">",
"0",
")",
"{",
"return",
"Math",
".",
"min",
"(",
"1",
",",
"(",
"double",
")",
"totalLength",
"/",
"size",
"/",
"BookKeeperConfig",
".",
"MAX_APPEND_LENGTH",
")",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}"
] | Calculates the FillRatio, which is a number between [0, 1] that represents the average fill of each
write with respect to the maximum BookKeeper write allowance.
@param totalLength Total length of the writes.
@param size Total number of writes. | [
"Calculates",
"the",
"FillRatio",
"which",
"is",
"a",
"number",
"between",
"[",
"0",
"1",
"]",
"that",
"represents",
"the",
"average",
"fill",
"of",
"each",
"write",
"with",
"respect",
"to",
"the",
"maximum",
"BookKeeper",
"write",
"allowance",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/storage/impl/src/main/java/io/pravega/segmentstore/storage/impl/bookkeeper/WriteQueue.java#L204-L210 |
QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.addScalarValueColumn | public void addScalarValueColumn(TableDefinition tableDef, String objID, String fieldName, String fieldValue) {
"""
Add the column needed to add or replace the given scalar field belonging to the
object with the given ID in the given table.
@param tableDef {@link TableDefinition} of table that owns object.
@param objID ID of object.
@param fieldName Name of scalar field being added.
@param fieldValue Value being added in string form.
"""
addColumn(SpiderService.objectsStoreName(tableDef),
objID,
fieldName,
SpiderService.scalarValueToBinary(tableDef, fieldName, fieldValue));
} | java | public void addScalarValueColumn(TableDefinition tableDef, String objID, String fieldName, String fieldValue) {
addColumn(SpiderService.objectsStoreName(tableDef),
objID,
fieldName,
SpiderService.scalarValueToBinary(tableDef, fieldName, fieldValue));
} | [
"public",
"void",
"addScalarValueColumn",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"objID",
",",
"String",
"fieldName",
",",
"String",
"fieldValue",
")",
"{",
"addColumn",
"(",
"SpiderService",
".",
"objectsStoreName",
"(",
"tableDef",
")",
",",
"objID",
",",
"fieldName",
",",
"SpiderService",
".",
"scalarValueToBinary",
"(",
"tableDef",
",",
"fieldName",
",",
"fieldValue",
")",
")",
";",
"}"
] | Add the column needed to add or replace the given scalar field belonging to the
object with the given ID in the given table.
@param tableDef {@link TableDefinition} of table that owns object.
@param objID ID of object.
@param fieldName Name of scalar field being added.
@param fieldValue Value being added in string form. | [
"Add",
"the",
"column",
"needed",
"to",
"add",
"or",
"replace",
"the",
"given",
"scalar",
"field",
"belonging",
"to",
"the",
"object",
"with",
"the",
"given",
"ID",
"in",
"the",
"given",
"table",
"."
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L267-L272 |
ArcadiaConsulting/javapns-json-refactor | src/main/java/javapns/notification/PushNotificationManager.java | PushNotificationManager.initializeConnection | public void initializeConnection(AppleNotificationServer server) throws CommunicationException, KeystoreException {
"""
Initialize a connection and create a SSLSocket
@param server The Apple server to connect to.
@throws CommunicationException thrown if a communication error occurs
@throws KeystoreException thrown if there is a problem with your keystore
"""
try {
this.connectionToAppleServer = new ConnectionToNotificationServer(server);
this.socket = connectionToAppleServer.getSSLSocket();
if (heavyDebugMode) {
dumpCertificateChainDescription();
}
logger.debug("Initialized Connection to Host: [" + server.getNotificationServerHost() + "] Port: [" + server.getNotificationServerPort() + "]: " + socket);
} catch (KeystoreException e) {
throw e;
} catch (CommunicationException e) {
throw e;
} catch (Exception e) {
throw new CommunicationException("Error creating connection with Apple server", e);
}
} | java | public void initializeConnection(AppleNotificationServer server) throws CommunicationException, KeystoreException {
try {
this.connectionToAppleServer = new ConnectionToNotificationServer(server);
this.socket = connectionToAppleServer.getSSLSocket();
if (heavyDebugMode) {
dumpCertificateChainDescription();
}
logger.debug("Initialized Connection to Host: [" + server.getNotificationServerHost() + "] Port: [" + server.getNotificationServerPort() + "]: " + socket);
} catch (KeystoreException e) {
throw e;
} catch (CommunicationException e) {
throw e;
} catch (Exception e) {
throw new CommunicationException("Error creating connection with Apple server", e);
}
} | [
"public",
"void",
"initializeConnection",
"(",
"AppleNotificationServer",
"server",
")",
"throws",
"CommunicationException",
",",
"KeystoreException",
"{",
"try",
"{",
"this",
".",
"connectionToAppleServer",
"=",
"new",
"ConnectionToNotificationServer",
"(",
"server",
")",
";",
"this",
".",
"socket",
"=",
"connectionToAppleServer",
".",
"getSSLSocket",
"(",
")",
";",
"if",
"(",
"heavyDebugMode",
")",
"{",
"dumpCertificateChainDescription",
"(",
")",
";",
"}",
"logger",
".",
"debug",
"(",
"\"Initialized Connection to Host: [\"",
"+",
"server",
".",
"getNotificationServerHost",
"(",
")",
"+",
"\"] Port: [\"",
"+",
"server",
".",
"getNotificationServerPort",
"(",
")",
"+",
"\"]: \"",
"+",
"socket",
")",
";",
"}",
"catch",
"(",
"KeystoreException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"CommunicationException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"CommunicationException",
"(",
"\"Error creating connection with Apple server\"",
",",
"e",
")",
";",
"}",
"}"
] | Initialize a connection and create a SSLSocket
@param server The Apple server to connect to.
@throws CommunicationException thrown if a communication error occurs
@throws KeystoreException thrown if there is a problem with your keystore | [
"Initialize",
"a",
"connection",
"and",
"create",
"a",
"SSLSocket"
] | train | https://github.com/ArcadiaConsulting/javapns-json-refactor/blob/293575ceda910b9c74733d2f6b963dff5302d859/src/main/java/javapns/notification/PushNotificationManager.java#L103-L119 |
Impetus/Kundera | src/kundera-hbase/kundera-hbase-v2/src/main/java/com/impetus/client/hbase/query/ResultIterator.java | ResultIterator.setRelationEntities | private E setRelationEntities(Object enhanceEntity, Client client, EntityMetadata m) {
"""
Sets the relation entities.
@param enhanceEntity
the enhance entity
@param client
the client
@param m
the m
@return the e
"""
E result = null;
if (enhanceEntity != null)
{
if (!(enhanceEntity instanceof EnhanceEntity))
{
enhanceEntity = new EnhanceEntity(enhanceEntity, PropertyAccessorHelper.getId(enhanceEntity, m), null);
}
EnhanceEntity ee = (EnhanceEntity) enhanceEntity;
result = (E) client.getReader().recursivelyFindEntities(ee.getEntity(), ee.getRelations(), m,
persistenceDelegator, false, new HashMap<Object, Object>());
}
return result;
} | java | private E setRelationEntities(Object enhanceEntity, Client client, EntityMetadata m)
{
E result = null;
if (enhanceEntity != null)
{
if (!(enhanceEntity instanceof EnhanceEntity))
{
enhanceEntity = new EnhanceEntity(enhanceEntity, PropertyAccessorHelper.getId(enhanceEntity, m), null);
}
EnhanceEntity ee = (EnhanceEntity) enhanceEntity;
result = (E) client.getReader().recursivelyFindEntities(ee.getEntity(), ee.getRelations(), m,
persistenceDelegator, false, new HashMap<Object, Object>());
}
return result;
} | [
"private",
"E",
"setRelationEntities",
"(",
"Object",
"enhanceEntity",
",",
"Client",
"client",
",",
"EntityMetadata",
"m",
")",
"{",
"E",
"result",
"=",
"null",
";",
"if",
"(",
"enhanceEntity",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"enhanceEntity",
"instanceof",
"EnhanceEntity",
")",
")",
"{",
"enhanceEntity",
"=",
"new",
"EnhanceEntity",
"(",
"enhanceEntity",
",",
"PropertyAccessorHelper",
".",
"getId",
"(",
"enhanceEntity",
",",
"m",
")",
",",
"null",
")",
";",
"}",
"EnhanceEntity",
"ee",
"=",
"(",
"EnhanceEntity",
")",
"enhanceEntity",
";",
"result",
"=",
"(",
"E",
")",
"client",
".",
"getReader",
"(",
")",
".",
"recursivelyFindEntities",
"(",
"ee",
".",
"getEntity",
"(",
")",
",",
"ee",
".",
"getRelations",
"(",
")",
",",
"m",
",",
"persistenceDelegator",
",",
"false",
",",
"new",
"HashMap",
"<",
"Object",
",",
"Object",
">",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Sets the relation entities.
@param enhanceEntity
the enhance entity
@param client
the client
@param m
the m
@return the e | [
"Sets",
"the",
"relation",
"entities",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-hbase/kundera-hbase-v2/src/main/java/com/impetus/client/hbase/query/ResultIterator.java#L175-L191 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.