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
|
---|---|---|---|---|---|---|---|---|---|---|
sawano/java-commons | src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java | AbstractValidate.validIndex | public <T extends CharSequence> T validIndex(final T chars, final int index) {
"""
<p>Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception.</p>
<pre>Validate.validIndex(myStr, 2);</pre>
<p>If the character sequence is {@code null}, then the message of the exception is "The validated object is null".</p><p>If the index is invalid, then the message of the exception is
"The validated character sequence index is invalid: " followed by the index.</p>
@param <T>
the character sequence type
@param chars
the character sequence to check, validated not null by this method
@param index
the index to check
@return the validated character sequence (never {@code null} for method chaining)
@throws NullPointerValidationException
if the character sequence is {@code null}
@throws IndexOutOfBoundsException
if the index is invalid
@see #validIndex(CharSequence, int, String, Object...)
"""
return validIndex(chars, index, DEFAULT_VALID_INDEX_CHAR_SEQUENCE_EX_MESSAGE, index);
} | java | public <T extends CharSequence> T validIndex(final T chars, final int index) {
return validIndex(chars, index, DEFAULT_VALID_INDEX_CHAR_SEQUENCE_EX_MESSAGE, index);
} | [
"public",
"<",
"T",
"extends",
"CharSequence",
">",
"T",
"validIndex",
"(",
"final",
"T",
"chars",
",",
"final",
"int",
"index",
")",
"{",
"return",
"validIndex",
"(",
"chars",
",",
"index",
",",
"DEFAULT_VALID_INDEX_CHAR_SEQUENCE_EX_MESSAGE",
",",
"index",
")",
";",
"}"
] | <p>Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception.</p>
<pre>Validate.validIndex(myStr, 2);</pre>
<p>If the character sequence is {@code null}, then the message of the exception is "The validated object is null".</p><p>If the index is invalid, then the message of the exception is
"The validated character sequence index is invalid: " followed by the index.</p>
@param <T>
the character sequence type
@param chars
the character sequence to check, validated not null by this method
@param index
the index to check
@return the validated character sequence (never {@code null} for method chaining)
@throws NullPointerValidationException
if the character sequence is {@code null}
@throws IndexOutOfBoundsException
if the index is invalid
@see #validIndex(CharSequence, int, String, Object...) | [
"<p",
">",
"Validates",
"that",
"the",
"index",
"is",
"within",
"the",
"bounds",
"of",
"the",
"argument",
"character",
"sequence",
";",
"otherwise",
"throwing",
"an",
"exception",
".",
"<",
"/",
"p",
">",
"<pre",
">",
"Validate",
".",
"validIndex",
"(",
"myStr",
"2",
")",
";",
"<",
"/",
"pre",
">",
"<p",
">",
"If",
"the",
"character",
"sequence",
"is",
"{",
"@code",
"null",
"}",
"then",
"the",
"message",
"of",
"the",
"exception",
"is",
""",
";",
"The",
"validated",
"object",
"is",
"null"",
";",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"the",
"index",
"is",
"invalid",
"then",
"the",
"message",
"of",
"the",
"exception",
"is",
""",
";",
"The",
"validated",
"character",
"sequence",
"index",
"is",
"invalid",
":",
""",
";",
"followed",
"by",
"the",
"index",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/sawano/java-commons/blob/6f219c9e8dec4401dbe528d17ae6ec1ef9c0d284/src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java#L1100-L1102 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/string/AbstrStrMatcher.java | AbstrStrMatcher.isEmpty | public boolean isEmpty(String... specialValueAsEmpty) {
"""
Checks if a delegate string is empty ("") or null or special value.
@param specialValueAsEmpty
@return
"""
if (Strings.isNullOrEmpty(delegate.get())) {
return true;
}
if (null == specialValueAsEmpty || specialValueAsEmpty.length < 1) {
return false;
}
if (Gather.from(Arrays.asList(checkNotNull(specialValueAsEmpty))).filter(new Decision<String>(){
@Override public boolean apply(String input) {
return isEqual(input, delegate.get());
}
}).noneNullList().size() > 0) {
return true;
}
return Decisions.isEmpty().apply(delegate.get());
} | java | public boolean isEmpty(String... specialValueAsEmpty) {
if (Strings.isNullOrEmpty(delegate.get())) {
return true;
}
if (null == specialValueAsEmpty || specialValueAsEmpty.length < 1) {
return false;
}
if (Gather.from(Arrays.asList(checkNotNull(specialValueAsEmpty))).filter(new Decision<String>(){
@Override public boolean apply(String input) {
return isEqual(input, delegate.get());
}
}).noneNullList().size() > 0) {
return true;
}
return Decisions.isEmpty().apply(delegate.get());
} | [
"public",
"boolean",
"isEmpty",
"(",
"String",
"...",
"specialValueAsEmpty",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"delegate",
".",
"get",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"null",
"==",
"specialValueAsEmpty",
"||",
"specialValueAsEmpty",
".",
"length",
"<",
"1",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"Gather",
".",
"from",
"(",
"Arrays",
".",
"asList",
"(",
"checkNotNull",
"(",
"specialValueAsEmpty",
")",
")",
")",
".",
"filter",
"(",
"new",
"Decision",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"apply",
"(",
"String",
"input",
")",
"{",
"return",
"isEqual",
"(",
"input",
",",
"delegate",
".",
"get",
"(",
")",
")",
";",
"}",
"}",
")",
".",
"noneNullList",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"Decisions",
".",
"isEmpty",
"(",
")",
".",
"apply",
"(",
"delegate",
".",
"get",
"(",
")",
")",
";",
"}"
] | Checks if a delegate string is empty ("") or null or special value.
@param specialValueAsEmpty
@return | [
"Checks",
"if",
"a",
"delegate",
"string",
"is",
"empty",
"(",
")",
"or",
"null",
"or",
"special",
"value",
"."
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/string/AbstrStrMatcher.java#L242-L260 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.getWarnings | public SQLWarning getWarnings() throws SQLException {
"""
<p>Retrieves the first warning reported by calls on this <code>Connection</code> object. If
there is more than one warning, subsequent warnings will be chained to the first one and can be
retrieved by calling the method
<code>SQLWarning.getNextWarning</code> on the warning that was retrieved previously.</p>
<p>This method may not be called on a closed connection; doing so will cause an
<code>SQLException</code> to be thrown.</p>
<p><B>Note:</B> Subsequent warnings will be chained to this SQLWarning.</p>
@return the first <code>SQLWarning</code> object or <code>null</code> if there are none
@throws SQLException if a database access error occurs or this method is called on a closed
connection
@see SQLWarning
"""
if (warningsCleared || isClosed() || !protocol.hasWarnings()) {
return null;
}
SQLWarning last = null;
SQLWarning first = null;
try (Statement st = this.createStatement()) {
try (ResultSet rs = st.executeQuery("show warnings")) {
// returned result set has 'level', 'code' and 'message' columns, in this order.
while (rs.next()) {
int code = rs.getInt(2);
String message = rs.getString(3);
SQLWarning warning = new SQLWarning(message, ExceptionMapper.mapCodeToSqlState(code),
code);
if (first == null) {
first = warning;
last = warning;
} else {
last.setNextWarning(warning);
last = warning;
}
}
}
}
return first;
} | java | public SQLWarning getWarnings() throws SQLException {
if (warningsCleared || isClosed() || !protocol.hasWarnings()) {
return null;
}
SQLWarning last = null;
SQLWarning first = null;
try (Statement st = this.createStatement()) {
try (ResultSet rs = st.executeQuery("show warnings")) {
// returned result set has 'level', 'code' and 'message' columns, in this order.
while (rs.next()) {
int code = rs.getInt(2);
String message = rs.getString(3);
SQLWarning warning = new SQLWarning(message, ExceptionMapper.mapCodeToSqlState(code),
code);
if (first == null) {
first = warning;
last = warning;
} else {
last.setNextWarning(warning);
last = warning;
}
}
}
}
return first;
} | [
"public",
"SQLWarning",
"getWarnings",
"(",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"warningsCleared",
"||",
"isClosed",
"(",
")",
"||",
"!",
"protocol",
".",
"hasWarnings",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"SQLWarning",
"last",
"=",
"null",
";",
"SQLWarning",
"first",
"=",
"null",
";",
"try",
"(",
"Statement",
"st",
"=",
"this",
".",
"createStatement",
"(",
")",
")",
"{",
"try",
"(",
"ResultSet",
"rs",
"=",
"st",
".",
"executeQuery",
"(",
"\"show warnings\"",
")",
")",
"{",
"// returned result set has 'level', 'code' and 'message' columns, in this order.",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"int",
"code",
"=",
"rs",
".",
"getInt",
"(",
"2",
")",
";",
"String",
"message",
"=",
"rs",
".",
"getString",
"(",
"3",
")",
";",
"SQLWarning",
"warning",
"=",
"new",
"SQLWarning",
"(",
"message",
",",
"ExceptionMapper",
".",
"mapCodeToSqlState",
"(",
"code",
")",
",",
"code",
")",
";",
"if",
"(",
"first",
"==",
"null",
")",
"{",
"first",
"=",
"warning",
";",
"last",
"=",
"warning",
";",
"}",
"else",
"{",
"last",
".",
"setNextWarning",
"(",
"warning",
")",
";",
"last",
"=",
"warning",
";",
"}",
"}",
"}",
"}",
"return",
"first",
";",
"}"
] | <p>Retrieves the first warning reported by calls on this <code>Connection</code> object. If
there is more than one warning, subsequent warnings will be chained to the first one and can be
retrieved by calling the method
<code>SQLWarning.getNextWarning</code> on the warning that was retrieved previously.</p>
<p>This method may not be called on a closed connection; doing so will cause an
<code>SQLException</code> to be thrown.</p>
<p><B>Note:</B> Subsequent warnings will be chained to this SQLWarning.</p>
@return the first <code>SQLWarning</code> object or <code>null</code> if there are none
@throws SQLException if a database access error occurs or this method is called on a closed
connection
@see SQLWarning | [
"<p",
">",
"Retrieves",
"the",
"first",
"warning",
"reported",
"by",
"calls",
"on",
"this",
"<code",
">",
"Connection<",
"/",
"code",
">",
"object",
".",
"If",
"there",
"is",
"more",
"than",
"one",
"warning",
"subsequent",
"warnings",
"will",
"be",
"chained",
"to",
"the",
"first",
"one",
"and",
"can",
"be",
"retrieved",
"by",
"calling",
"the",
"method",
"<code",
">",
"SQLWarning",
".",
"getNextWarning<",
"/",
"code",
">",
"on",
"the",
"warning",
"that",
"was",
"retrieved",
"previously",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"may",
"not",
"be",
"called",
"on",
"a",
"closed",
"connection",
";",
"doing",
"so",
"will",
"cause",
"an",
"<code",
">",
"SQLException<",
"/",
"code",
">",
"to",
"be",
"thrown",
".",
"<",
"/",
"p",
">",
"<p",
">",
"<B",
">",
"Note",
":",
"<",
"/",
"B",
">",
"Subsequent",
"warnings",
"will",
"be",
"chained",
"to",
"this",
"SQLWarning",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L997-L1024 |
liferay/com-liferay-commerce | commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationAttachmentPersistenceImpl.java | CommerceNotificationAttachmentPersistenceImpl.findByUuid | @Override
public List<CommerceNotificationAttachment> findByUuid(String uuid,
int start, int end,
OrderByComparator<CommerceNotificationAttachment> orderByComparator) {
"""
Returns an ordered range of all the commerce notification attachments where uuid = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceNotificationAttachmentModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param uuid the uuid
@param start the lower bound of the range of commerce notification attachments
@param end the upper bound of the range of commerce notification attachments (not inclusive)
@param orderByComparator the comparator to order the results by (optionally <code>null</code>)
@return the ordered range of matching commerce notification attachments
"""
return findByUuid(uuid, start, end, orderByComparator, true);
} | java | @Override
public List<CommerceNotificationAttachment> findByUuid(String uuid,
int start, int end,
OrderByComparator<CommerceNotificationAttachment> orderByComparator) {
return findByUuid(uuid, start, end, orderByComparator, true);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceNotificationAttachment",
">",
"findByUuid",
"(",
"String",
"uuid",
",",
"int",
"start",
",",
"int",
"end",
",",
"OrderByComparator",
"<",
"CommerceNotificationAttachment",
">",
"orderByComparator",
")",
"{",
"return",
"findByUuid",
"(",
"uuid",
",",
"start",
",",
"end",
",",
"orderByComparator",
",",
"true",
")",
";",
"}"
] | Returns an ordered range of all the commerce notification attachments where uuid = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceNotificationAttachmentModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param uuid the uuid
@param start the lower bound of the range of commerce notification attachments
@param end the upper bound of the range of commerce notification attachments (not inclusive)
@param orderByComparator the comparator to order the results by (optionally <code>null</code>)
@return the ordered range of matching commerce notification attachments | [
"Returns",
"an",
"ordered",
"range",
"of",
"all",
"the",
"commerce",
"notification",
"attachments",
"where",
"uuid",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationAttachmentPersistenceImpl.java#L164-L169 |
GeoLatte/geolatte-common-hibernate | src/main/java/org/geolatte/common/automapper/TableRef.java | TableRef.valueOf | public static TableRef valueOf(String[] components) {
"""
Creates an instance from an array of table ref components,
<p/>
<p>The components should be (in order): catalog (optional), schema (optional), table name. if the catalog or schema
component is an empty String, the catalog or schema will be set to <code>null</code>.</p>
@param components the components of the reference.
@return a new instance corresponding to the specified components.
@throws IllegalArgumentException if the parameter is null, or has more than 3 elements.
"""
if (components == null) {
throw new IllegalArgumentException("Null argument not allowed.");
}
switch (components.length) {
case 1:
return new TableRef(null, null, components[0]);
case 2:
return new TableRef(null, components[0], components[1]);
case 3:
return new TableRef(components[0], components[1], components[2]);
default:
throw new IllegalArgumentException("String array has more than 3 elements.");
}
} | java | public static TableRef valueOf(String[] components) {
if (components == null) {
throw new IllegalArgumentException("Null argument not allowed.");
}
switch (components.length) {
case 1:
return new TableRef(null, null, components[0]);
case 2:
return new TableRef(null, components[0], components[1]);
case 3:
return new TableRef(components[0], components[1], components[2]);
default:
throw new IllegalArgumentException("String array has more than 3 elements.");
}
} | [
"public",
"static",
"TableRef",
"valueOf",
"(",
"String",
"[",
"]",
"components",
")",
"{",
"if",
"(",
"components",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Null argument not allowed.\"",
")",
";",
"}",
"switch",
"(",
"components",
".",
"length",
")",
"{",
"case",
"1",
":",
"return",
"new",
"TableRef",
"(",
"null",
",",
"null",
",",
"components",
"[",
"0",
"]",
")",
";",
"case",
"2",
":",
"return",
"new",
"TableRef",
"(",
"null",
",",
"components",
"[",
"0",
"]",
",",
"components",
"[",
"1",
"]",
")",
";",
"case",
"3",
":",
"return",
"new",
"TableRef",
"(",
"components",
"[",
"0",
"]",
",",
"components",
"[",
"1",
"]",
",",
"components",
"[",
"2",
"]",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"String array has more than 3 elements.\"",
")",
";",
"}",
"}"
] | Creates an instance from an array of table ref components,
<p/>
<p>The components should be (in order): catalog (optional), schema (optional), table name. if the catalog or schema
component is an empty String, the catalog or schema will be set to <code>null</code>.</p>
@param components the components of the reference.
@return a new instance corresponding to the specified components.
@throws IllegalArgumentException if the parameter is null, or has more than 3 elements. | [
"Creates",
"an",
"instance",
"from",
"an",
"array",
"of",
"table",
"ref",
"components",
"<p",
"/",
">",
"<p",
">",
"The",
"components",
"should",
"be",
"(",
"in",
"order",
")",
":",
"catalog",
"(",
"optional",
")",
"schema",
"(",
"optional",
")",
"table",
"name",
".",
"if",
"the",
"catalog",
"or",
"schema",
"component",
"is",
"an",
"empty",
"String",
"the",
"catalog",
"or",
"schema",
"will",
"be",
"set",
"to",
"<code",
">",
"null<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/GeoLatte/geolatte-common-hibernate/blob/2e871c70e506df2485d91152fbd0955c94de1d39/src/main/java/org/geolatte/common/automapper/TableRef.java#L95-L109 |
apache/groovy | src/main/groovy/groovy/lang/MetaMethod.java | MetaMethod.doMethodInvoke | public Object doMethodInvoke(Object object, Object[] argumentArray) {
"""
Invokes the method this object represents. This method is not final but it should be overloaded very carefully and only by generated methods
there is no guarantee that it will be called
@param object The object the method is to be called at.
@param argumentArray Arguments for the method invocation.
@return The return value of the invoked method.
"""
argumentArray = coerceArgumentsToClasses(argumentArray);
try {
return invoke(object, argumentArray);
} catch (Exception e) {
throw processDoMethodInvokeException(e, object, argumentArray);
}
} | java | public Object doMethodInvoke(Object object, Object[] argumentArray) {
argumentArray = coerceArgumentsToClasses(argumentArray);
try {
return invoke(object, argumentArray);
} catch (Exception e) {
throw processDoMethodInvokeException(e, object, argumentArray);
}
} | [
"public",
"Object",
"doMethodInvoke",
"(",
"Object",
"object",
",",
"Object",
"[",
"]",
"argumentArray",
")",
"{",
"argumentArray",
"=",
"coerceArgumentsToClasses",
"(",
"argumentArray",
")",
";",
"try",
"{",
"return",
"invoke",
"(",
"object",
",",
"argumentArray",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"processDoMethodInvokeException",
"(",
"e",
",",
"object",
",",
"argumentArray",
")",
";",
"}",
"}"
] | Invokes the method this object represents. This method is not final but it should be overloaded very carefully and only by generated methods
there is no guarantee that it will be called
@param object The object the method is to be called at.
@param argumentArray Arguments for the method invocation.
@return The return value of the invoked method. | [
"Invokes",
"the",
"method",
"this",
"object",
"represents",
".",
"This",
"method",
"is",
"not",
"final",
"but",
"it",
"should",
"be",
"overloaded",
"very",
"carefully",
"and",
"only",
"by",
"generated",
"methods",
"there",
"is",
"no",
"guarantee",
"that",
"it",
"will",
"be",
"called"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/MetaMethod.java#L320-L327 |
jmchilton/galaxy-bootstrap | src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java | DownloadProperties.wgetGithub | public static DownloadProperties wgetGithub(final String branch, final File destination) {
"""
Builds a new DownloadProperties for downloading Galaxy from github using wget.
@param branch The branch to download (e.g. master, dev, release_15.03).
@param destination The destination directory to store Galaxy, null if a directory
should be chosen by default.
@return A DownloadProperties for downloading Galaxy from github using wget.
"""
return new DownloadProperties(new WgetGithubDownloader(branch), destination);
} | java | public static DownloadProperties wgetGithub(final String branch, final File destination) {
return new DownloadProperties(new WgetGithubDownloader(branch), destination);
} | [
"public",
"static",
"DownloadProperties",
"wgetGithub",
"(",
"final",
"String",
"branch",
",",
"final",
"File",
"destination",
")",
"{",
"return",
"new",
"DownloadProperties",
"(",
"new",
"WgetGithubDownloader",
"(",
"branch",
")",
",",
"destination",
")",
";",
"}"
] | Builds a new DownloadProperties for downloading Galaxy from github using wget.
@param branch The branch to download (e.g. master, dev, release_15.03).
@param destination The destination directory to store Galaxy, null if a directory
should be chosen by default.
@return A DownloadProperties for downloading Galaxy from github using wget. | [
"Builds",
"a",
"new",
"DownloadProperties",
"for",
"downloading",
"Galaxy",
"from",
"github",
"using",
"wget",
"."
] | train | https://github.com/jmchilton/galaxy-bootstrap/blob/4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649/src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java#L293-L295 |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newUpdateOpenGraphObjectRequest | public static Request newUpdateOpenGraphObjectRequest(Session session, String id, String title, String imageUrl,
String url, String description, GraphObject objectProperties, Callback callback) {
"""
Creates a new Request configured to update a user owned Open Graph object.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param id
the id of the Open Graph object
@param title
the title of the Open Graph object
@param imageUrl
the link to an image to be associated with the Open Graph object
@param url
the url to be associated with the Open Graph object
@param description
the description to be associated with the object
@param objectProperties
any additional type-specific properties for the Open Graph object
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute
"""
OpenGraphObject openGraphObject = OpenGraphObject.Factory.createForPost(OpenGraphObject.class, null, title,
imageUrl, url, description);
openGraphObject.setId(id);
openGraphObject.setData(objectProperties);
return newUpdateOpenGraphObjectRequest(session, openGraphObject, callback);
} | java | public static Request newUpdateOpenGraphObjectRequest(Session session, String id, String title, String imageUrl,
String url, String description, GraphObject objectProperties, Callback callback) {
OpenGraphObject openGraphObject = OpenGraphObject.Factory.createForPost(OpenGraphObject.class, null, title,
imageUrl, url, description);
openGraphObject.setId(id);
openGraphObject.setData(objectProperties);
return newUpdateOpenGraphObjectRequest(session, openGraphObject, callback);
} | [
"public",
"static",
"Request",
"newUpdateOpenGraphObjectRequest",
"(",
"Session",
"session",
",",
"String",
"id",
",",
"String",
"title",
",",
"String",
"imageUrl",
",",
"String",
"url",
",",
"String",
"description",
",",
"GraphObject",
"objectProperties",
",",
"Callback",
"callback",
")",
"{",
"OpenGraphObject",
"openGraphObject",
"=",
"OpenGraphObject",
".",
"Factory",
".",
"createForPost",
"(",
"OpenGraphObject",
".",
"class",
",",
"null",
",",
"title",
",",
"imageUrl",
",",
"url",
",",
"description",
")",
";",
"openGraphObject",
".",
"setId",
"(",
"id",
")",
";",
"openGraphObject",
".",
"setData",
"(",
"objectProperties",
")",
";",
"return",
"newUpdateOpenGraphObjectRequest",
"(",
"session",
",",
"openGraphObject",
",",
"callback",
")",
";",
"}"
] | Creates a new Request configured to update a user owned Open Graph object.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param id
the id of the Open Graph object
@param title
the title of the Open Graph object
@param imageUrl
the link to an image to be associated with the Open Graph object
@param url
the url to be associated with the Open Graph object
@param description
the description to be associated with the object
@param objectProperties
any additional type-specific properties for the Open Graph object
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"update",
"a",
"user",
"owned",
"Open",
"Graph",
"object",
"."
] | train | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L818-L826 |
alkacon/opencms-core | src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditor.java | CmsMessageBundleEditor.setFilters | void setFilters(Map<Object, Object> filters) {
"""
Sets the provided filters.
@param filters a map "column id -> filter".
"""
for (Object column : filters.keySet()) {
Object filterValue = filters.get(column);
if ((filterValue != null) && !filterValue.toString().isEmpty() && !m_table.isColumnCollapsed(column)) {
m_table.setFilterFieldValue(column, filterValue);
}
}
} | java | void setFilters(Map<Object, Object> filters) {
for (Object column : filters.keySet()) {
Object filterValue = filters.get(column);
if ((filterValue != null) && !filterValue.toString().isEmpty() && !m_table.isColumnCollapsed(column)) {
m_table.setFilterFieldValue(column, filterValue);
}
}
} | [
"void",
"setFilters",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"filters",
")",
"{",
"for",
"(",
"Object",
"column",
":",
"filters",
".",
"keySet",
"(",
")",
")",
"{",
"Object",
"filterValue",
"=",
"filters",
".",
"get",
"(",
"column",
")",
";",
"if",
"(",
"(",
"filterValue",
"!=",
"null",
")",
"&&",
"!",
"filterValue",
".",
"toString",
"(",
")",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"m_table",
".",
"isColumnCollapsed",
"(",
"column",
")",
")",
"{",
"m_table",
".",
"setFilterFieldValue",
"(",
"column",
",",
"filterValue",
")",
";",
"}",
"}",
"}"
] | Sets the provided filters.
@param filters a map "column id -> filter". | [
"Sets",
"the",
"provided",
"filters",
"."
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditor.java#L571-L579 |
aequologica/geppaequo | geppaequo-cmis/src/main/java/net/aequologica/neo/geppaequo/document/impl/ECMHelperImpl.java | ECMHelperImpl.createOrUpdateDocument | @Override
public void createOrUpdateDocument(final Path path, final Serioulizer.Stream stream) throws IOException {
"""
/*
@Override
public void createOrUpdateUTF8Document(final Path path, final String content) throws IOException {
sessionExistsPreCondition(); // throws illegalStateException if no session
log.debug("createOrUpdateDocument | path: {}, content: {}", path, getMax80StringEndingWithEllipsisWhenNeeded(content));
try (final Serioulizer.Stream stream = Serioulizer.createStream(content)) {
createOrUpdateDocument(path, stream);
}
}
"""
sessionExistsPreCondition(); // throws illegalStateException if no session
log.debug("createOrUpdateDocument | path: {}, length: {}, mimetype: {}, stream: {}", path, stream.getLength(), stream.getMimeType(), stream.getInputStream());
// get root folder from CMIS session
Folder rootFolder = this.openCMISSession.getRootFolder();
if (rootFolder == null) {
throw new IOException("No root folder ?!");
}
// get the penultimate element of the path as Folder, create if not exists.
int nameCount = path.getNameCount();
Folder folder = rootFolder;
for (int i = 0; i < nameCount-1; i++) {
folder = getOrCreateFolder(folder, path.getName(i).toString());
}
// get the ultimate element of the path as filename
String fileName = path.getFileName().toString();
// prepare the content to be written
ContentStream contentStream = this.openCMISSession.getObjectFactory().createContentStream(
fileName,
stream.getLength(),
stream.getMimeType(),
stream.getInputStream());
// search for the document, update it when found, and we're done.
ItemIterable<CmisObject> children = folder.getChildren();
if (children.iterator().hasNext()) {
for (CmisObject o : children) {
if (o instanceof Document && o.getName().equals(fileName)) {
((Document)o).setContentStream(contentStream, true);
log.info("Document at path '{}' found and updated!", path.toString());
return;
}
}
}
// at this point, document does not exist
// create new document (requires at least type id, name of the document and some content)
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
properties.put(PropertyIds.NAME, fileName);
folder.createDocument(properties, contentStream, VersioningState.NONE);
log.info("Document at path '{}' created!", path.toString());
} | java | @Override
public void createOrUpdateDocument(final Path path, final Serioulizer.Stream stream) throws IOException {
sessionExistsPreCondition(); // throws illegalStateException if no session
log.debug("createOrUpdateDocument | path: {}, length: {}, mimetype: {}, stream: {}", path, stream.getLength(), stream.getMimeType(), stream.getInputStream());
// get root folder from CMIS session
Folder rootFolder = this.openCMISSession.getRootFolder();
if (rootFolder == null) {
throw new IOException("No root folder ?!");
}
// get the penultimate element of the path as Folder, create if not exists.
int nameCount = path.getNameCount();
Folder folder = rootFolder;
for (int i = 0; i < nameCount-1; i++) {
folder = getOrCreateFolder(folder, path.getName(i).toString());
}
// get the ultimate element of the path as filename
String fileName = path.getFileName().toString();
// prepare the content to be written
ContentStream contentStream = this.openCMISSession.getObjectFactory().createContentStream(
fileName,
stream.getLength(),
stream.getMimeType(),
stream.getInputStream());
// search for the document, update it when found, and we're done.
ItemIterable<CmisObject> children = folder.getChildren();
if (children.iterator().hasNext()) {
for (CmisObject o : children) {
if (o instanceof Document && o.getName().equals(fileName)) {
((Document)o).setContentStream(contentStream, true);
log.info("Document at path '{}' found and updated!", path.toString());
return;
}
}
}
// at this point, document does not exist
// create new document (requires at least type id, name of the document and some content)
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
properties.put(PropertyIds.NAME, fileName);
folder.createDocument(properties, contentStream, VersioningState.NONE);
log.info("Document at path '{}' created!", path.toString());
} | [
"@",
"Override",
"public",
"void",
"createOrUpdateDocument",
"(",
"final",
"Path",
"path",
",",
"final",
"Serioulizer",
".",
"Stream",
"stream",
")",
"throws",
"IOException",
"{",
"sessionExistsPreCondition",
"(",
")",
";",
"// throws illegalStateException if no session",
"log",
".",
"debug",
"(",
"\"createOrUpdateDocument | path: {}, length: {}, mimetype: {}, stream: {}\"",
",",
"path",
",",
"stream",
".",
"getLength",
"(",
")",
",",
"stream",
".",
"getMimeType",
"(",
")",
",",
"stream",
".",
"getInputStream",
"(",
")",
")",
";",
"// get root folder from CMIS session",
"Folder",
"rootFolder",
"=",
"this",
".",
"openCMISSession",
".",
"getRootFolder",
"(",
")",
";",
"if",
"(",
"rootFolder",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"No root folder ?!\"",
")",
";",
"}",
"// get the penultimate element of the path as Folder, create if not exists.",
"int",
"nameCount",
"=",
"path",
".",
"getNameCount",
"(",
")",
";",
"Folder",
"folder",
"=",
"rootFolder",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nameCount",
"-",
"1",
";",
"i",
"++",
")",
"{",
"folder",
"=",
"getOrCreateFolder",
"(",
"folder",
",",
"path",
".",
"getName",
"(",
"i",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"// get the ultimate element of the path as filename",
"String",
"fileName",
"=",
"path",
".",
"getFileName",
"(",
")",
".",
"toString",
"(",
")",
";",
"// prepare the content to be written",
"ContentStream",
"contentStream",
"=",
"this",
".",
"openCMISSession",
".",
"getObjectFactory",
"(",
")",
".",
"createContentStream",
"(",
"fileName",
",",
"stream",
".",
"getLength",
"(",
")",
",",
"stream",
".",
"getMimeType",
"(",
")",
",",
"stream",
".",
"getInputStream",
"(",
")",
")",
";",
"// search for the document, update it when found, and we're done.",
"ItemIterable",
"<",
"CmisObject",
">",
"children",
"=",
"folder",
".",
"getChildren",
"(",
")",
";",
"if",
"(",
"children",
".",
"iterator",
"(",
")",
".",
"hasNext",
"(",
")",
")",
"{",
"for",
"(",
"CmisObject",
"o",
":",
"children",
")",
"{",
"if",
"(",
"o",
"instanceof",
"Document",
"&&",
"o",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"fileName",
")",
")",
"{",
"(",
"(",
"Document",
")",
"o",
")",
".",
"setContentStream",
"(",
"contentStream",
",",
"true",
")",
";",
"log",
".",
"info",
"(",
"\"Document at path '{}' found and updated!\"",
",",
"path",
".",
"toString",
"(",
")",
")",
";",
"return",
";",
"}",
"}",
"}",
"// at this point, document does not exist",
"// create new document (requires at least type id, name of the document and some content)",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"properties",
".",
"put",
"(",
"PropertyIds",
".",
"OBJECT_TYPE_ID",
",",
"\"cmis:document\"",
")",
";",
"properties",
".",
"put",
"(",
"PropertyIds",
".",
"NAME",
",",
"fileName",
")",
";",
"folder",
".",
"createDocument",
"(",
"properties",
",",
"contentStream",
",",
"VersioningState",
".",
"NONE",
")",
";",
"log",
".",
"info",
"(",
"\"Document at path '{}' created!\"",
",",
"path",
".",
"toString",
"(",
")",
")",
";",
"}"
] | /*
@Override
public void createOrUpdateUTF8Document(final Path path, final String content) throws IOException {
sessionExistsPreCondition(); // throws illegalStateException if no session
log.debug("createOrUpdateDocument | path: {}, content: {}", path, getMax80StringEndingWithEllipsisWhenNeeded(content));
try (final Serioulizer.Stream stream = Serioulizer.createStream(content)) {
createOrUpdateDocument(path, stream);
}
} | [
"/",
"*",
"@Override",
"public",
"void",
"createOrUpdateUTF8Document",
"(",
"final",
"Path",
"path",
"final",
"String",
"content",
")",
"throws",
"IOException",
"{"
] | train | https://github.com/aequologica/geppaequo/blob/b72e5f6356535fd045a931f8c544d4a8ea6e35a2/geppaequo-cmis/src/main/java/net/aequologica/neo/geppaequo/document/impl/ECMHelperImpl.java#L87-L135 |
google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java | MapWithProtoValuesSubject.withPartialScopeForValues | public MapWithProtoValuesFluentAssertion<M> withPartialScopeForValues(FieldScope fieldScope) {
"""
Limits the comparison of Protocol buffers to the defined {@link FieldScope}.
<p>This method is additive and has well-defined ordering semantics. If the invoking {@link
ProtoFluentAssertion} is already scoped to a {@link FieldScope} {@code X}, and this method is
invoked with {@link FieldScope} {@code Y}, the resultant {@link ProtoFluentAssertion} is
constrained to the intersection of {@link FieldScope}s {@code X} and {@code Y}.
<p>By default, {@link MapWithProtoValuesFluentAssertion} is constrained to {@link
FieldScopes#all()}, that is, no fields are excluded from comparison.
"""
return usingConfig(config.withPartialScope(checkNotNull(fieldScope, "fieldScope")));
} | java | public MapWithProtoValuesFluentAssertion<M> withPartialScopeForValues(FieldScope fieldScope) {
return usingConfig(config.withPartialScope(checkNotNull(fieldScope, "fieldScope")));
} | [
"public",
"MapWithProtoValuesFluentAssertion",
"<",
"M",
">",
"withPartialScopeForValues",
"(",
"FieldScope",
"fieldScope",
")",
"{",
"return",
"usingConfig",
"(",
"config",
".",
"withPartialScope",
"(",
"checkNotNull",
"(",
"fieldScope",
",",
"\"fieldScope\"",
")",
")",
")",
";",
"}"
] | Limits the comparison of Protocol buffers to the defined {@link FieldScope}.
<p>This method is additive and has well-defined ordering semantics. If the invoking {@link
ProtoFluentAssertion} is already scoped to a {@link FieldScope} {@code X}, and this method is
invoked with {@link FieldScope} {@code Y}, the resultant {@link ProtoFluentAssertion} is
constrained to the intersection of {@link FieldScope}s {@code X} and {@code Y}.
<p>By default, {@link MapWithProtoValuesFluentAssertion} is constrained to {@link
FieldScopes#all()}, that is, no fields are excluded from comparison. | [
"Limits",
"the",
"comparison",
"of",
"Protocol",
"buffers",
"to",
"the",
"defined",
"{",
"@link",
"FieldScope",
"}",
"."
] | train | https://github.com/google/truth/blob/60eceffd2e8c3297655d33ed87d965cf5af51108/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java#L642-L644 |
geomajas/geomajas-project-geometry | core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java | GeometryIndexService.addChildren | public GeometryIndex addChildren(GeometryIndex index, GeometryIndexType type, int... values) {
"""
Given a certain geometry index, add more levels to it (This method will not change the underlying geometry !).
@param index
The index to start out from.
@param type
Add more levels to it, where the deepest level should be of this type.
@param values
A list of integer values that determine the indices on each level in the index.
@return The recursive geometry index resulting from adding the given parameters to the given parent index.
"""
if (index == null) {
return create(type, values);
}
if (getType(index) != GeometryIndexType.TYPE_GEOMETRY) {
throw new IllegalArgumentException("Can only add children to an index of type geometry.");
}
GeometryIndex clone = new GeometryIndex(index);
GeometryIndex deepestChild = clone;
while (deepestChild.hasChild()) {
deepestChild = deepestChild.getChild();
}
deepestChild.setChild(create(type, values));
return clone;
} | java | public GeometryIndex addChildren(GeometryIndex index, GeometryIndexType type, int... values) {
if (index == null) {
return create(type, values);
}
if (getType(index) != GeometryIndexType.TYPE_GEOMETRY) {
throw new IllegalArgumentException("Can only add children to an index of type geometry.");
}
GeometryIndex clone = new GeometryIndex(index);
GeometryIndex deepestChild = clone;
while (deepestChild.hasChild()) {
deepestChild = deepestChild.getChild();
}
deepestChild.setChild(create(type, values));
return clone;
} | [
"public",
"GeometryIndex",
"addChildren",
"(",
"GeometryIndex",
"index",
",",
"GeometryIndexType",
"type",
",",
"int",
"...",
"values",
")",
"{",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"return",
"create",
"(",
"type",
",",
"values",
")",
";",
"}",
"if",
"(",
"getType",
"(",
"index",
")",
"!=",
"GeometryIndexType",
".",
"TYPE_GEOMETRY",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can only add children to an index of type geometry.\"",
")",
";",
"}",
"GeometryIndex",
"clone",
"=",
"new",
"GeometryIndex",
"(",
"index",
")",
";",
"GeometryIndex",
"deepestChild",
"=",
"clone",
";",
"while",
"(",
"deepestChild",
".",
"hasChild",
"(",
")",
")",
"{",
"deepestChild",
"=",
"deepestChild",
".",
"getChild",
"(",
")",
";",
"}",
"deepestChild",
".",
"setChild",
"(",
"create",
"(",
"type",
",",
"values",
")",
")",
";",
"return",
"clone",
";",
"}"
] | Given a certain geometry index, add more levels to it (This method will not change the underlying geometry !).
@param index
The index to start out from.
@param type
Add more levels to it, where the deepest level should be of this type.
@param values
A list of integer values that determine the indices on each level in the index.
@return The recursive geometry index resulting from adding the given parameters to the given parent index. | [
"Given",
"a",
"certain",
"geometry",
"index",
"add",
"more",
"levels",
"to",
"it",
"(",
"This",
"method",
"will",
"not",
"change",
"the",
"underlying",
"geometry",
"!",
")",
"."
] | train | https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L71-L86 |
graphhopper/graphhopper | core/src/main/java/com/graphhopper/routing/subnetwork/SubnetworkStorage.java | SubnetworkStorage.setSubnetwork | public void setSubnetwork(int nodeId, int subnetwork) {
"""
This method sets the subnetwork if of the specified nodeId. Default is 0 and means subnetwork
was too small to be useful to be stored.
"""
if (subnetwork > 127)
throw new IllegalArgumentException("Number of subnetworks is currently limited to 127 but requested " + subnetwork);
byte[] bytes = new byte[1];
bytes[0] = (byte) subnetwork;
da.setBytes(nodeId, bytes, bytes.length);
} | java | public void setSubnetwork(int nodeId, int subnetwork) {
if (subnetwork > 127)
throw new IllegalArgumentException("Number of subnetworks is currently limited to 127 but requested " + subnetwork);
byte[] bytes = new byte[1];
bytes[0] = (byte) subnetwork;
da.setBytes(nodeId, bytes, bytes.length);
} | [
"public",
"void",
"setSubnetwork",
"(",
"int",
"nodeId",
",",
"int",
"subnetwork",
")",
"{",
"if",
"(",
"subnetwork",
">",
"127",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Number of subnetworks is currently limited to 127 but requested \"",
"+",
"subnetwork",
")",
";",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"1",
"]",
";",
"bytes",
"[",
"0",
"]",
"=",
"(",
"byte",
")",
"subnetwork",
";",
"da",
".",
"setBytes",
"(",
"nodeId",
",",
"bytes",
",",
"bytes",
".",
"length",
")",
";",
"}"
] | This method sets the subnetwork if of the specified nodeId. Default is 0 and means subnetwork
was too small to be useful to be stored. | [
"This",
"method",
"sets",
"the",
"subnetwork",
"if",
"of",
"the",
"specified",
"nodeId",
".",
"Default",
"is",
"0",
"and",
"means",
"subnetwork",
"was",
"too",
"small",
"to",
"be",
"useful",
"to",
"be",
"stored",
"."
] | train | https://github.com/graphhopper/graphhopper/blob/c235e306e6e823043cadcc41ead0e685bdebf737/core/src/main/java/com/graphhopper/routing/subnetwork/SubnetworkStorage.java#L54-L61 |
alkacon/opencms-core | src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageHandler.java | CmsContainerpageHandler.openEditorForElement | public void openEditorForElement(final CmsContainerPageElementPanel element, boolean inline, boolean wasNew) {
"""
Opens the edit dialog for the specified element.<p>
@param element the element to edit
@param inline <code>true</code> to open the inline editor for the given element if available
@param wasNew <code>true</code> in case this is a newly created element not previously edited
"""
if (element.isNew()) {
//openEditorForElement will be called again asynchronously when the RPC for creating the element has finished
m_controller.createAndEditNewElement(element, inline);
return;
}
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(element.getNoEditReason())) {
CmsNotification.get().send(
CmsNotification.Type.WARNING,
"should be deactivated: " + element.getNoEditReason());
return;
}
if (CmsDomUtil.hasClass(CmsContainerElement.CLASS_GROUP_CONTAINER_ELEMENT_MARKER, element.getElement())) {
openGroupEditor((CmsGroupContainerElementPanel)element);
} else {
m_controller.setContentEditing(true);
m_controller.disableInlineEditing(element);
m_controller.getContentEditorHandler().openDialog(element, inline, wasNew);
element.removeHighlighting();
}
} | java | public void openEditorForElement(final CmsContainerPageElementPanel element, boolean inline, boolean wasNew) {
if (element.isNew()) {
//openEditorForElement will be called again asynchronously when the RPC for creating the element has finished
m_controller.createAndEditNewElement(element, inline);
return;
}
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(element.getNoEditReason())) {
CmsNotification.get().send(
CmsNotification.Type.WARNING,
"should be deactivated: " + element.getNoEditReason());
return;
}
if (CmsDomUtil.hasClass(CmsContainerElement.CLASS_GROUP_CONTAINER_ELEMENT_MARKER, element.getElement())) {
openGroupEditor((CmsGroupContainerElementPanel)element);
} else {
m_controller.setContentEditing(true);
m_controller.disableInlineEditing(element);
m_controller.getContentEditorHandler().openDialog(element, inline, wasNew);
element.removeHighlighting();
}
} | [
"public",
"void",
"openEditorForElement",
"(",
"final",
"CmsContainerPageElementPanel",
"element",
",",
"boolean",
"inline",
",",
"boolean",
"wasNew",
")",
"{",
"if",
"(",
"element",
".",
"isNew",
"(",
")",
")",
"{",
"//openEditorForElement will be called again asynchronously when the RPC for creating the element has finished",
"m_controller",
".",
"createAndEditNewElement",
"(",
"element",
",",
"inline",
")",
";",
"return",
";",
"}",
"if",
"(",
"CmsStringUtil",
".",
"isNotEmptyOrWhitespaceOnly",
"(",
"element",
".",
"getNoEditReason",
"(",
")",
")",
")",
"{",
"CmsNotification",
".",
"get",
"(",
")",
".",
"send",
"(",
"CmsNotification",
".",
"Type",
".",
"WARNING",
",",
"\"should be deactivated: \"",
"+",
"element",
".",
"getNoEditReason",
"(",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"CmsDomUtil",
".",
"hasClass",
"(",
"CmsContainerElement",
".",
"CLASS_GROUP_CONTAINER_ELEMENT_MARKER",
",",
"element",
".",
"getElement",
"(",
")",
")",
")",
"{",
"openGroupEditor",
"(",
"(",
"CmsGroupContainerElementPanel",
")",
"element",
")",
";",
"}",
"else",
"{",
"m_controller",
".",
"setContentEditing",
"(",
"true",
")",
";",
"m_controller",
".",
"disableInlineEditing",
"(",
"element",
")",
";",
"m_controller",
".",
"getContentEditorHandler",
"(",
")",
".",
"openDialog",
"(",
"element",
",",
"inline",
",",
"wasNew",
")",
";",
"element",
".",
"removeHighlighting",
"(",
")",
";",
"}",
"}"
] | Opens the edit dialog for the specified element.<p>
@param element the element to edit
@param inline <code>true</code> to open the inline editor for the given element if available
@param wasNew <code>true</code> in case this is a newly created element not previously edited | [
"Opens",
"the",
"edit",
"dialog",
"for",
"the",
"specified",
"element",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageHandler.java#L765-L788 |
aspectran/aspectran | web/src/main/java/com/aspectran/web/support/http/HttpStatusSetter.java | HttpStatusSetter.setStatus | public static void setStatus(HttpStatus httpStatus, Translet translet) {
"""
Sets the status code.
@param httpStatus the http status code
@param translet the Translet instance
"""
translet.getResponseAdapter().setStatus(httpStatus.value());
} | java | public static void setStatus(HttpStatus httpStatus, Translet translet) {
translet.getResponseAdapter().setStatus(httpStatus.value());
} | [
"public",
"static",
"void",
"setStatus",
"(",
"HttpStatus",
"httpStatus",
",",
"Translet",
"translet",
")",
"{",
"translet",
".",
"getResponseAdapter",
"(",
")",
".",
"setStatus",
"(",
"httpStatus",
".",
"value",
"(",
")",
")",
";",
"}"
] | Sets the status code.
@param httpStatus the http status code
@param translet the Translet instance | [
"Sets",
"the",
"status",
"code",
"."
] | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/support/http/HttpStatusSetter.java#L31-L33 |
SeaCloudsEU/SeaCloudsPlatform | sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/AgreementRestEntity.java | AgreementRestEntity.getAgreements | @GET
public List<IAgreement> getAgreements(
@QueryParam("consumerId") String consumerId,
@QueryParam("providerId") String providerId,
@QueryParam("templateId") String templateId,
@QueryParam("active") BooleanParam active) {
"""
Gets a the list of available agreements from where we can get metrics,
host information, etc.
<pre>
GET /agreements{?providerId,consumerId,active}
Request:
GET /agreements HTTP/1.1
Response:
HTTP/1.1 200 OK
Content-type: application/xml
{@code
<?xml version="1.0" encoding="UTF-8"?>
<collection href="/agreements">
<items offset="0" total="1">
<wsag:Agreement xmlns:wsag="http://www.ggf.org/namespaces/ws-agreement"
AgreementId="d25eea60-7cfe-11e3-baa7-0800200c9a66">
...
</wsag:Agreement>
</items>
</collection>
}
</pre>
Example:
<li>curl http://localhost:8080/sla-service/agreements</li>
<li>curl http://localhost:8080/sla-service/agreements?consumerId=user-10343</li>
@throws NotFoundException
@throws JAXBException
"""
logger.debug("StartOf getAgreements - REQUEST for /agreements");
AgreementHelperE agreementRestHelper = getAgreementHelper();
List<IAgreement> agreements = agreementRestHelper.getAgreements(
consumerId, providerId, templateId, BooleanParam.getValue(active));
return agreements;
} | java | @GET
public List<IAgreement> getAgreements(
@QueryParam("consumerId") String consumerId,
@QueryParam("providerId") String providerId,
@QueryParam("templateId") String templateId,
@QueryParam("active") BooleanParam active) {
logger.debug("StartOf getAgreements - REQUEST for /agreements");
AgreementHelperE agreementRestHelper = getAgreementHelper();
List<IAgreement> agreements = agreementRestHelper.getAgreements(
consumerId, providerId, templateId, BooleanParam.getValue(active));
return agreements;
} | [
"@",
"GET",
"public",
"List",
"<",
"IAgreement",
">",
"getAgreements",
"(",
"@",
"QueryParam",
"(",
"\"consumerId\"",
")",
"String",
"consumerId",
",",
"@",
"QueryParam",
"(",
"\"providerId\"",
")",
"String",
"providerId",
",",
"@",
"QueryParam",
"(",
"\"templateId\"",
")",
"String",
"templateId",
",",
"@",
"QueryParam",
"(",
"\"active\"",
")",
"BooleanParam",
"active",
")",
"{",
"logger",
".",
"debug",
"(",
"\"StartOf getAgreements - REQUEST for /agreements\"",
")",
";",
"AgreementHelperE",
"agreementRestHelper",
"=",
"getAgreementHelper",
"(",
")",
";",
"List",
"<",
"IAgreement",
">",
"agreements",
"=",
"agreementRestHelper",
".",
"getAgreements",
"(",
"consumerId",
",",
"providerId",
",",
"templateId",
",",
"BooleanParam",
".",
"getValue",
"(",
"active",
")",
")",
";",
"return",
"agreements",
";",
"}"
] | Gets a the list of available agreements from where we can get metrics,
host information, etc.
<pre>
GET /agreements{?providerId,consumerId,active}
Request:
GET /agreements HTTP/1.1
Response:
HTTP/1.1 200 OK
Content-type: application/xml
{@code
<?xml version="1.0" encoding="UTF-8"?>
<collection href="/agreements">
<items offset="0" total="1">
<wsag:Agreement xmlns:wsag="http://www.ggf.org/namespaces/ws-agreement"
AgreementId="d25eea60-7cfe-11e3-baa7-0800200c9a66">
...
</wsag:Agreement>
</items>
</collection>
}
</pre>
Example:
<li>curl http://localhost:8080/sla-service/agreements</li>
<li>curl http://localhost:8080/sla-service/agreements?consumerId=user-10343</li>
@throws NotFoundException
@throws JAXBException | [
"Gets",
"a",
"the",
"list",
"of",
"available",
"agreements",
"from",
"where",
"we",
"can",
"get",
"metrics",
"host",
"information",
"etc",
"."
] | train | https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/AgreementRestEntity.java#L145-L157 |
jeremylong/DependencyCheck | utils/src/main/java/org/owasp/dependencycheck/utils/Checksum.java | Checksum.getSHA1Checksum | public static String getSHA1Checksum(String text) {
"""
Calculates the SHA1 checksum of the specified text.
@param text the text to generate the SHA1 checksum
@return the hex representation of the SHA1
"""
final byte[] data = stringToBytes(text);
return getChecksum(SHA1, data);
} | java | public static String getSHA1Checksum(String text) {
final byte[] data = stringToBytes(text);
return getChecksum(SHA1, data);
} | [
"public",
"static",
"String",
"getSHA1Checksum",
"(",
"String",
"text",
")",
"{",
"final",
"byte",
"[",
"]",
"data",
"=",
"stringToBytes",
"(",
"text",
")",
";",
"return",
"getChecksum",
"(",
"SHA1",
",",
"data",
")",
";",
"}"
] | Calculates the SHA1 checksum of the specified text.
@param text the text to generate the SHA1 checksum
@return the hex representation of the SHA1 | [
"Calculates",
"the",
"SHA1",
"checksum",
"of",
"the",
"specified",
"text",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/Checksum.java#L169-L172 |
UrielCh/ovh-java-sdk | ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java | ApiOvhIpLoadbalancing.serviceName_tcp_frontend_frontendId_DELETE | public void serviceName_tcp_frontend_frontendId_DELETE(String serviceName, Long frontendId) throws IOException {
"""
Delete an TCP frontend
REST: DELETE /ipLoadbalancing/{serviceName}/tcp/frontend/{frontendId}
@param serviceName [required] The internal name of your IP load balancing
@param frontendId [required] Id of your frontend
"""
String qPath = "/ipLoadbalancing/{serviceName}/tcp/frontend/{frontendId}";
StringBuilder sb = path(qPath, serviceName, frontendId);
exec(qPath, "DELETE", sb.toString(), null);
} | java | public void serviceName_tcp_frontend_frontendId_DELETE(String serviceName, Long frontendId) throws IOException {
String qPath = "/ipLoadbalancing/{serviceName}/tcp/frontend/{frontendId}";
StringBuilder sb = path(qPath, serviceName, frontendId);
exec(qPath, "DELETE", sb.toString(), null);
} | [
"public",
"void",
"serviceName_tcp_frontend_frontendId_DELETE",
"(",
"String",
"serviceName",
",",
"Long",
"frontendId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ipLoadbalancing/{serviceName}/tcp/frontend/{frontendId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"frontendId",
")",
";",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] | Delete an TCP frontend
REST: DELETE /ipLoadbalancing/{serviceName}/tcp/frontend/{frontendId}
@param serviceName [required] The internal name of your IP load balancing
@param frontendId [required] Id of your frontend | [
"Delete",
"an",
"TCP",
"frontend"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java#L1460-L1464 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.project_serviceName_alerting_id_PUT | public void project_serviceName_alerting_id_PUT(String serviceName, String id, OvhAlerting body) throws IOException {
"""
Alter this object properties
REST: PUT /cloud/project/{serviceName}/alerting/{id}
@param body [required] New object properties
@param serviceName [required] The project id
@param id [required] Alerting unique UUID
"""
String qPath = "/cloud/project/{serviceName}/alerting/{id}";
StringBuilder sb = path(qPath, serviceName, id);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void project_serviceName_alerting_id_PUT(String serviceName, String id, OvhAlerting body) throws IOException {
String qPath = "/cloud/project/{serviceName}/alerting/{id}";
StringBuilder sb = path(qPath, serviceName, id);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"project_serviceName_alerting_id_PUT",
"(",
"String",
"serviceName",
",",
"String",
"id",
",",
"OvhAlerting",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/project/{serviceName}/alerting/{id}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"id",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /cloud/project/{serviceName}/alerting/{id}
@param body [required] New object properties
@param serviceName [required] The project id
@param id [required] Alerting unique UUID | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L2225-L2229 |
xhsun/gw2wrapper | src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java | AsynchronousRequest.getAllFileInfo | public void getAllFileInfo(String[] ids, Callback<List<Asset>> callback) throws GuildWars2Exception, NullPointerException {
"""
For more info on files API go <a href="https://wiki.guildwars2.com/wiki/API:2/files">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of file id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Asset file info
"""
isParamValid(new ParamChecker(ids));
gw2API.getAllFileInfo(processIds(ids)).enqueue(callback);
} | java | public void getAllFileInfo(String[] ids, Callback<List<Asset>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getAllFileInfo(processIds(ids)).enqueue(callback);
} | [
"public",
"void",
"getAllFileInfo",
"(",
"String",
"[",
"]",
"ids",
",",
"Callback",
"<",
"List",
"<",
"Asset",
">",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ids",
")",
")",
";",
"gw2API",
".",
"getAllFileInfo",
"(",
"processIds",
"(",
"ids",
")",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] | For more info on files API go <a href="https://wiki.guildwars2.com/wiki/API:2/files">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of file id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Asset file info | [
"For",
"more",
"info",
"on",
"files",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"files",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Give",
"user",
"the",
"access",
"to",
"{",
"@link",
"Callback#onResponse",
"(",
"Call",
"Response",
")",
"}",
"and",
"{",
"@link",
"Callback#onFailure",
"(",
"Call",
"Throwable",
")",
"}",
"methods",
"for",
"custom",
"interactions"
] | train | https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L1361-L1364 |
apereo/cas | support/cas-server-support-validation/src/main/java/org/apereo/cas/web/AbstractServiceValidateController.java | AbstractServiceValidateController.initBinder | protected void initBinder(final HttpServletRequest request, final ServletRequestDataBinder binder) {
"""
Initialize the binder with the required fields.
@param request the request
@param binder the binder
"""
if (serviceValidateConfigurationContext.isRenewEnabled()) {
binder.setRequiredFields(CasProtocolConstants.PARAMETER_RENEW);
}
} | java | protected void initBinder(final HttpServletRequest request, final ServletRequestDataBinder binder) {
if (serviceValidateConfigurationContext.isRenewEnabled()) {
binder.setRequiredFields(CasProtocolConstants.PARAMETER_RENEW);
}
} | [
"protected",
"void",
"initBinder",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"ServletRequestDataBinder",
"binder",
")",
"{",
"if",
"(",
"serviceValidateConfigurationContext",
".",
"isRenewEnabled",
"(",
")",
")",
"{",
"binder",
".",
"setRequiredFields",
"(",
"CasProtocolConstants",
".",
"PARAMETER_RENEW",
")",
";",
"}",
"}"
] | Initialize the binder with the required fields.
@param request the request
@param binder the binder | [
"Initialize",
"the",
"binder",
"with",
"the",
"required",
"fields",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-validation/src/main/java/org/apereo/cas/web/AbstractServiceValidateController.java#L109-L113 |
rototor/pdfbox-graphics2d | src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java | PdfBoxGraphics2DFontTextDrawer.mapFont | @SuppressWarnings("WeakerAccess")
protected PDFont mapFont(final Font font, final IFontTextDrawerEnv env) throws IOException, FontFormatException {
"""
Try to map the java.awt.Font to a PDFont.
@param font
the java.awt.Font for which a mapping should be found
@param env
environment of the font mapper
@return the PDFont or null if none can be found.
"""
/*
* If we have any font registering's, we must perform them now
*/
for (final FontEntry fontEntry : fontFiles) {
if (fontEntry.overrideName == null) {
Font javaFont = Font.createFont(Font.TRUETYPE_FONT, fontEntry.file);
fontEntry.overrideName = javaFont.getFontName();
}
if (fontEntry.file.getName().toLowerCase(Locale.US).endsWith(".ttc")) {
TrueTypeCollection collection = new TrueTypeCollection(fontEntry.file);
collection.processAllFonts(new TrueTypeCollection.TrueTypeFontProcessor() {
@Override
public void process(TrueTypeFont ttf) throws IOException {
PDFont pdFont = PDType0Font.load(env.getDocument(), ttf, true);
fontMap.put(fontEntry.overrideName, pdFont);
fontMap.put(pdFont.getName(), pdFont);
}
});
} else {
/*
* We load the font using the file.
*/
PDFont pdFont = PDType0Font.load(env.getDocument(), fontEntry.file);
fontMap.put(fontEntry.overrideName, pdFont);
}
}
fontFiles.clear();
return fontMap.get(font.getFontName());
} | java | @SuppressWarnings("WeakerAccess")
protected PDFont mapFont(final Font font, final IFontTextDrawerEnv env) throws IOException, FontFormatException {
/*
* If we have any font registering's, we must perform them now
*/
for (final FontEntry fontEntry : fontFiles) {
if (fontEntry.overrideName == null) {
Font javaFont = Font.createFont(Font.TRUETYPE_FONT, fontEntry.file);
fontEntry.overrideName = javaFont.getFontName();
}
if (fontEntry.file.getName().toLowerCase(Locale.US).endsWith(".ttc")) {
TrueTypeCollection collection = new TrueTypeCollection(fontEntry.file);
collection.processAllFonts(new TrueTypeCollection.TrueTypeFontProcessor() {
@Override
public void process(TrueTypeFont ttf) throws IOException {
PDFont pdFont = PDType0Font.load(env.getDocument(), ttf, true);
fontMap.put(fontEntry.overrideName, pdFont);
fontMap.put(pdFont.getName(), pdFont);
}
});
} else {
/*
* We load the font using the file.
*/
PDFont pdFont = PDType0Font.load(env.getDocument(), fontEntry.file);
fontMap.put(fontEntry.overrideName, pdFont);
}
}
fontFiles.clear();
return fontMap.get(font.getFontName());
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"protected",
"PDFont",
"mapFont",
"(",
"final",
"Font",
"font",
",",
"final",
"IFontTextDrawerEnv",
"env",
")",
"throws",
"IOException",
",",
"FontFormatException",
"{",
"/*\n\t\t * If we have any font registering's, we must perform them now\n\t\t */",
"for",
"(",
"final",
"FontEntry",
"fontEntry",
":",
"fontFiles",
")",
"{",
"if",
"(",
"fontEntry",
".",
"overrideName",
"==",
"null",
")",
"{",
"Font",
"javaFont",
"=",
"Font",
".",
"createFont",
"(",
"Font",
".",
"TRUETYPE_FONT",
",",
"fontEntry",
".",
"file",
")",
";",
"fontEntry",
".",
"overrideName",
"=",
"javaFont",
".",
"getFontName",
"(",
")",
";",
"}",
"if",
"(",
"fontEntry",
".",
"file",
".",
"getName",
"(",
")",
".",
"toLowerCase",
"(",
"Locale",
".",
"US",
")",
".",
"endsWith",
"(",
"\".ttc\"",
")",
")",
"{",
"TrueTypeCollection",
"collection",
"=",
"new",
"TrueTypeCollection",
"(",
"fontEntry",
".",
"file",
")",
";",
"collection",
".",
"processAllFonts",
"(",
"new",
"TrueTypeCollection",
".",
"TrueTypeFontProcessor",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"process",
"(",
"TrueTypeFont",
"ttf",
")",
"throws",
"IOException",
"{",
"PDFont",
"pdFont",
"=",
"PDType0Font",
".",
"load",
"(",
"env",
".",
"getDocument",
"(",
")",
",",
"ttf",
",",
"true",
")",
";",
"fontMap",
".",
"put",
"(",
"fontEntry",
".",
"overrideName",
",",
"pdFont",
")",
";",
"fontMap",
".",
"put",
"(",
"pdFont",
".",
"getName",
"(",
")",
",",
"pdFont",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"/*\n\t\t\t\t * We load the font using the file.\n\t\t\t\t */",
"PDFont",
"pdFont",
"=",
"PDType0Font",
".",
"load",
"(",
"env",
".",
"getDocument",
"(",
")",
",",
"fontEntry",
".",
"file",
")",
";",
"fontMap",
".",
"put",
"(",
"fontEntry",
".",
"overrideName",
",",
"pdFont",
")",
";",
"}",
"}",
"fontFiles",
".",
"clear",
"(",
")",
";",
"return",
"fontMap",
".",
"get",
"(",
"font",
".",
"getFontName",
"(",
")",
")",
";",
"}"
] | Try to map the java.awt.Font to a PDFont.
@param font
the java.awt.Font for which a mapping should be found
@param env
environment of the font mapper
@return the PDFont or null if none can be found. | [
"Try",
"to",
"map",
"the",
"java",
".",
"awt",
".",
"Font",
"to",
"a",
"PDFont",
"."
] | train | https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java#L408-L439 |
xmlunit/xmlunit | xmlunit-core/src/main/java/org/xmlunit/transform/Transformation.java | Transformation.addOutputProperty | public void addOutputProperty(String name, String value) {
"""
Add a named output property.
@param name name of the property - must not be null
@param value value of the property - must not be null
"""
if (name == null) {
throw new IllegalArgumentException("name must not be null");
}
if (value == null) {
throw new IllegalArgumentException("value must not be null");
}
output.setProperty(name, value);
} | java | public void addOutputProperty(String name, String value) {
if (name == null) {
throw new IllegalArgumentException("name must not be null");
}
if (value == null) {
throw new IllegalArgumentException("value must not be null");
}
output.setProperty(name, value);
} | [
"public",
"void",
"addOutputProperty",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"name must not be null\"",
")",
";",
"}",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"value must not be null\"",
")",
";",
"}",
"output",
".",
"setProperty",
"(",
"name",
",",
"value",
")",
";",
"}"
] | Add a named output property.
@param name name of the property - must not be null
@param value value of the property - must not be null | [
"Add",
"a",
"named",
"output",
"property",
"."
] | train | https://github.com/xmlunit/xmlunit/blob/fe3d701d43f57ee83dcba336e4c1555619d3084b/xmlunit-core/src/main/java/org/xmlunit/transform/Transformation.java#L84-L92 |
hawkular/hawkular-apm | api/src/main/java/org/hawkular/apm/api/utils/NodeUtil.java | NodeUtil.findNodes | @SuppressWarnings("unchecked")
public static <T extends Node> void findNodes(List<Node> nodes, Class<T> cls, List<T> results) {
"""
This method recursively scans a node hierarchy to locate instances of a particular
type.
@param nodes The nodes to scan
@param cls The class of the node to be returned
@param results The list of nodes found
"""
for (Node n : nodes) {
if (n instanceof ContainerNode) {
findNodes(((ContainerNode) n).getNodes(), cls, results);
}
if (cls == n.getClass()) {
results.add((T) n);
}
}
} | java | @SuppressWarnings("unchecked")
public static <T extends Node> void findNodes(List<Node> nodes, Class<T> cls, List<T> results) {
for (Node n : nodes) {
if (n instanceof ContainerNode) {
findNodes(((ContainerNode) n).getNodes(), cls, results);
}
if (cls == n.getClass()) {
results.add((T) n);
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
"extends",
"Node",
">",
"void",
"findNodes",
"(",
"List",
"<",
"Node",
">",
"nodes",
",",
"Class",
"<",
"T",
">",
"cls",
",",
"List",
"<",
"T",
">",
"results",
")",
"{",
"for",
"(",
"Node",
"n",
":",
"nodes",
")",
"{",
"if",
"(",
"n",
"instanceof",
"ContainerNode",
")",
"{",
"findNodes",
"(",
"(",
"(",
"ContainerNode",
")",
"n",
")",
".",
"getNodes",
"(",
")",
",",
"cls",
",",
"results",
")",
";",
"}",
"if",
"(",
"cls",
"==",
"n",
".",
"getClass",
"(",
")",
")",
"{",
"results",
".",
"add",
"(",
"(",
"T",
")",
"n",
")",
";",
"}",
"}",
"}"
] | This method recursively scans a node hierarchy to locate instances of a particular
type.
@param nodes The nodes to scan
@param cls The class of the node to be returned
@param results The list of nodes found | [
"This",
"method",
"recursively",
"scans",
"a",
"node",
"hierarchy",
"to",
"locate",
"instances",
"of",
"a",
"particular",
"type",
"."
] | train | https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/api/src/main/java/org/hawkular/apm/api/utils/NodeUtil.java#L236-L247 |
mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java | MercatorProjection.longitudeToTileXWithScaleFactor | public static int longitudeToTileXWithScaleFactor(double longitude, double scaleFactor) {
"""
Converts a longitude coordinate (in degrees) to the tile X number at a certain scale factor.
@param longitude the longitude coordinate that should be converted.
@param scaleFactor the scale factor at which the coordinate should be converted.
@return the tile X number of the longitude value.
"""
return pixelXToTileXWithScaleFactor(longitudeToPixelXWithScaleFactor(longitude, scaleFactor, DUMMY_TILE_SIZE), scaleFactor, DUMMY_TILE_SIZE);
} | java | public static int longitudeToTileXWithScaleFactor(double longitude, double scaleFactor) {
return pixelXToTileXWithScaleFactor(longitudeToPixelXWithScaleFactor(longitude, scaleFactor, DUMMY_TILE_SIZE), scaleFactor, DUMMY_TILE_SIZE);
} | [
"public",
"static",
"int",
"longitudeToTileXWithScaleFactor",
"(",
"double",
"longitude",
",",
"double",
"scaleFactor",
")",
"{",
"return",
"pixelXToTileXWithScaleFactor",
"(",
"longitudeToPixelXWithScaleFactor",
"(",
"longitude",
",",
"scaleFactor",
",",
"DUMMY_TILE_SIZE",
")",
",",
"scaleFactor",
",",
"DUMMY_TILE_SIZE",
")",
";",
"}"
] | Converts a longitude coordinate (in degrees) to the tile X number at a certain scale factor.
@param longitude the longitude coordinate that should be converted.
@param scaleFactor the scale factor at which the coordinate should be converted.
@return the tile X number of the longitude value. | [
"Converts",
"a",
"longitude",
"coordinate",
"(",
"in",
"degrees",
")",
"to",
"the",
"tile",
"X",
"number",
"at",
"a",
"certain",
"scale",
"factor",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java#L289-L291 |
JakeWharton/NineOldAndroids | library/src/com/nineoldandroids/animation/ObjectAnimator.java | ObjectAnimator.ofFloat | public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) {
"""
Constructs and returns an ObjectAnimator that animates between float values. A single
value implies that that value is the one being animated to. Two values imply a starting
and ending values. More than two values imply a starting value, values to animate through
along the way, and an ending value (these values will be distributed evenly across
the duration of the animation).
@param target The object whose property is to be animated. This object should
have a public method on it called <code>setName()</code>, where <code>name</code> is
the value of the <code>propertyName</code> parameter.
@param propertyName The name of the property being animated.
@param values A set of values that the animation will animate between over time.
@return An ObjectAnimator object that is set up to animate between the given values.
"""
ObjectAnimator anim = new ObjectAnimator(target, propertyName);
anim.setFloatValues(values);
return anim;
} | java | public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) {
ObjectAnimator anim = new ObjectAnimator(target, propertyName);
anim.setFloatValues(values);
return anim;
} | [
"public",
"static",
"ObjectAnimator",
"ofFloat",
"(",
"Object",
"target",
",",
"String",
"propertyName",
",",
"float",
"...",
"values",
")",
"{",
"ObjectAnimator",
"anim",
"=",
"new",
"ObjectAnimator",
"(",
"target",
",",
"propertyName",
")",
";",
"anim",
".",
"setFloatValues",
"(",
"values",
")",
";",
"return",
"anim",
";",
"}"
] | Constructs and returns an ObjectAnimator that animates between float values. A single
value implies that that value is the one being animated to. Two values imply a starting
and ending values. More than two values imply a starting value, values to animate through
along the way, and an ending value (these values will be distributed evenly across
the duration of the animation).
@param target The object whose property is to be animated. This object should
have a public method on it called <code>setName()</code>, where <code>name</code> is
the value of the <code>propertyName</code> parameter.
@param propertyName The name of the property being animated.
@param values A set of values that the animation will animate between over time.
@return An ObjectAnimator object that is set up to animate between the given values. | [
"Constructs",
"and",
"returns",
"an",
"ObjectAnimator",
"that",
"animates",
"between",
"float",
"values",
".",
"A",
"single",
"value",
"implies",
"that",
"that",
"value",
"is",
"the",
"one",
"being",
"animated",
"to",
".",
"Two",
"values",
"imply",
"a",
"starting",
"and",
"ending",
"values",
".",
"More",
"than",
"two",
"values",
"imply",
"a",
"starting",
"value",
"values",
"to",
"animate",
"through",
"along",
"the",
"way",
"and",
"an",
"ending",
"value",
"(",
"these",
"values",
"will",
"be",
"distributed",
"evenly",
"across",
"the",
"duration",
"of",
"the",
"animation",
")",
"."
] | train | https://github.com/JakeWharton/NineOldAndroids/blob/d582f0ec8e79013e9fa96c07986160b52e662e63/library/src/com/nineoldandroids/animation/ObjectAnimator.java#L230-L234 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/PublicIPPrefixesInner.java | PublicIPPrefixesInner.beginDelete | public void beginDelete(String resourceGroupName, String publicIpPrefixName) {
"""
Deletes the specified public IP prefix.
@param resourceGroupName The name of the resource group.
@param publicIpPrefixName The name of the PublicIpPrefix.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
beginDeleteWithServiceResponseAsync(resourceGroupName, publicIpPrefixName).toBlocking().single().body();
} | java | public void beginDelete(String resourceGroupName, String publicIpPrefixName) {
beginDeleteWithServiceResponseAsync(resourceGroupName, publicIpPrefixName).toBlocking().single().body();
} | [
"public",
"void",
"beginDelete",
"(",
"String",
"resourceGroupName",
",",
"String",
"publicIpPrefixName",
")",
"{",
"beginDeleteWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"publicIpPrefixName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Deletes the specified public IP prefix.
@param resourceGroupName The name of the resource group.
@param publicIpPrefixName The name of the PublicIpPrefix.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Deletes",
"the",
"specified",
"public",
"IP",
"prefix",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/PublicIPPrefixesInner.java#L191-L193 |
jlinn/quartz-redis-jobstore | src/main/java/net/joelinn/quartz/jobstore/RedisClusterStorage.java | RedisClusterStorage.pauseTrigger | @Override
public void pauseTrigger(TriggerKey triggerKey, JedisCluster jedis) throws JobPersistenceException {
"""
Pause the trigger with the given key
@param triggerKey the key of the trigger to be paused
@param jedis a thread-safe Redis connection
@throws JobPersistenceException if the desired trigger does not exist
"""
final String triggerHashKey = redisSchema.triggerHashKey(triggerKey);
Boolean exists = jedis.exists(triggerHashKey);
Double completedScore = jedis.zscore(redisSchema.triggerStateKey(RedisTriggerState.COMPLETED), triggerHashKey);
String nextFireTimeResponse = jedis.hget(triggerHashKey, TRIGGER_NEXT_FIRE_TIME);
Double blockedScore = jedis.zscore(redisSchema.triggerStateKey(RedisTriggerState.BLOCKED), triggerHashKey);
if (!exists) {
return;
}
if (completedScore != null) {
// doesn't make sense to pause a completed trigger
return;
}
final long nextFireTime = nextFireTimeResponse == null
|| nextFireTimeResponse.isEmpty() ? -1 : Long.parseLong(nextFireTimeResponse);
if (blockedScore != null) {
setTriggerState(RedisTriggerState.PAUSED_BLOCKED, (double) nextFireTime, triggerHashKey, jedis);
} else {
setTriggerState(RedisTriggerState.PAUSED, (double) nextFireTime, triggerHashKey, jedis);
}
} | java | @Override
public void pauseTrigger(TriggerKey triggerKey, JedisCluster jedis) throws JobPersistenceException {
final String triggerHashKey = redisSchema.triggerHashKey(triggerKey);
Boolean exists = jedis.exists(triggerHashKey);
Double completedScore = jedis.zscore(redisSchema.triggerStateKey(RedisTriggerState.COMPLETED), triggerHashKey);
String nextFireTimeResponse = jedis.hget(triggerHashKey, TRIGGER_NEXT_FIRE_TIME);
Double blockedScore = jedis.zscore(redisSchema.triggerStateKey(RedisTriggerState.BLOCKED), triggerHashKey);
if (!exists) {
return;
}
if (completedScore != null) {
// doesn't make sense to pause a completed trigger
return;
}
final long nextFireTime = nextFireTimeResponse == null
|| nextFireTimeResponse.isEmpty() ? -1 : Long.parseLong(nextFireTimeResponse);
if (blockedScore != null) {
setTriggerState(RedisTriggerState.PAUSED_BLOCKED, (double) nextFireTime, triggerHashKey, jedis);
} else {
setTriggerState(RedisTriggerState.PAUSED, (double) nextFireTime, triggerHashKey, jedis);
}
} | [
"@",
"Override",
"public",
"void",
"pauseTrigger",
"(",
"TriggerKey",
"triggerKey",
",",
"JedisCluster",
"jedis",
")",
"throws",
"JobPersistenceException",
"{",
"final",
"String",
"triggerHashKey",
"=",
"redisSchema",
".",
"triggerHashKey",
"(",
"triggerKey",
")",
";",
"Boolean",
"exists",
"=",
"jedis",
".",
"exists",
"(",
"triggerHashKey",
")",
";",
"Double",
"completedScore",
"=",
"jedis",
".",
"zscore",
"(",
"redisSchema",
".",
"triggerStateKey",
"(",
"RedisTriggerState",
".",
"COMPLETED",
")",
",",
"triggerHashKey",
")",
";",
"String",
"nextFireTimeResponse",
"=",
"jedis",
".",
"hget",
"(",
"triggerHashKey",
",",
"TRIGGER_NEXT_FIRE_TIME",
")",
";",
"Double",
"blockedScore",
"=",
"jedis",
".",
"zscore",
"(",
"redisSchema",
".",
"triggerStateKey",
"(",
"RedisTriggerState",
".",
"BLOCKED",
")",
",",
"triggerHashKey",
")",
";",
"if",
"(",
"!",
"exists",
")",
"{",
"return",
";",
"}",
"if",
"(",
"completedScore",
"!=",
"null",
")",
"{",
"// doesn't make sense to pause a completed trigger",
"return",
";",
"}",
"final",
"long",
"nextFireTime",
"=",
"nextFireTimeResponse",
"==",
"null",
"||",
"nextFireTimeResponse",
".",
"isEmpty",
"(",
")",
"?",
"-",
"1",
":",
"Long",
".",
"parseLong",
"(",
"nextFireTimeResponse",
")",
";",
"if",
"(",
"blockedScore",
"!=",
"null",
")",
"{",
"setTriggerState",
"(",
"RedisTriggerState",
".",
"PAUSED_BLOCKED",
",",
"(",
"double",
")",
"nextFireTime",
",",
"triggerHashKey",
",",
"jedis",
")",
";",
"}",
"else",
"{",
"setTriggerState",
"(",
"RedisTriggerState",
".",
"PAUSED",
",",
"(",
"double",
")",
"nextFireTime",
",",
"triggerHashKey",
",",
"jedis",
")",
";",
"}",
"}"
] | Pause the trigger with the given key
@param triggerKey the key of the trigger to be paused
@param jedis a thread-safe Redis connection
@throws JobPersistenceException if the desired trigger does not exist | [
"Pause",
"the",
"trigger",
"with",
"the",
"given",
"key"
] | train | https://github.com/jlinn/quartz-redis-jobstore/blob/be9a52ee776d8a09866fe99fd9718bc13a0cb992/src/main/java/net/joelinn/quartz/jobstore/RedisClusterStorage.java#L421-L444 |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/packstream/PackStream.java | Unpacker.unpackNull | public Object unpackNull() throws IOException {
"""
This may seem confusing. This method exists to move forward the internal pointer when encountering
a null value. The idiomatic usage would be someone using {@link #peekNextType()} to detect a null type,
and then this method to "skip past it".
@return null
@throws IOException if the unpacked value was not null
"""
final byte markerByte = in.readByte();
if ( markerByte != NULL )
{
throw new Unexpected( "Expected a null, but got: 0x" + toHexString( markerByte & 0xFF ) );
}
return null;
} | java | public Object unpackNull() throws IOException
{
final byte markerByte = in.readByte();
if ( markerByte != NULL )
{
throw new Unexpected( "Expected a null, but got: 0x" + toHexString( markerByte & 0xFF ) );
}
return null;
} | [
"public",
"Object",
"unpackNull",
"(",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"markerByte",
"=",
"in",
".",
"readByte",
"(",
")",
";",
"if",
"(",
"markerByte",
"!=",
"NULL",
")",
"{",
"throw",
"new",
"Unexpected",
"(",
"\"Expected a null, but got: 0x\"",
"+",
"toHexString",
"(",
"markerByte",
"&",
"0xFF",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | This may seem confusing. This method exists to move forward the internal pointer when encountering
a null value. The idiomatic usage would be someone using {@link #peekNextType()} to detect a null type,
and then this method to "skip past it".
@return null
@throws IOException if the unpacked value was not null | [
"This",
"may",
"seem",
"confusing",
".",
"This",
"method",
"exists",
"to",
"move",
"forward",
"the",
"internal",
"pointer",
"when",
"encountering",
"a",
"null",
"value",
".",
"The",
"idiomatic",
"usage",
"would",
"be",
"someone",
"using",
"{"
] | train | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/packstream/PackStream.java#L527-L535 |
actorapp/actor-platform | actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/util/images/ops/ImageLoading.java | ImageLoading.getScaleFactor | private static int getScaleFactor(ImageMetadata metadata, int minW, int minH) {
"""
Calculating scale factor with limit of pixel amount
@param metadata image metadata
@param minH minimal height
@param minW minimal width
@return scale factor
"""
int scale = 1;
int scaledW = metadata.getW();
int scaledH = metadata.getH();
while (scaledW / 2 > minW && scaledH / 2 > minH) {
scale *= 2;
scaledH /= 2;
scaledW /= 2;
}
return scale;
} | java | private static int getScaleFactor(ImageMetadata metadata, int minW, int minH) {
int scale = 1;
int scaledW = metadata.getW();
int scaledH = metadata.getH();
while (scaledW / 2 > minW && scaledH / 2 > minH) {
scale *= 2;
scaledH /= 2;
scaledW /= 2;
}
return scale;
} | [
"private",
"static",
"int",
"getScaleFactor",
"(",
"ImageMetadata",
"metadata",
",",
"int",
"minW",
",",
"int",
"minH",
")",
"{",
"int",
"scale",
"=",
"1",
";",
"int",
"scaledW",
"=",
"metadata",
".",
"getW",
"(",
")",
";",
"int",
"scaledH",
"=",
"metadata",
".",
"getH",
"(",
")",
";",
"while",
"(",
"scaledW",
"/",
"2",
">",
"minW",
"&&",
"scaledH",
"/",
"2",
">",
"minH",
")",
"{",
"scale",
"*=",
"2",
";",
"scaledH",
"/=",
"2",
";",
"scaledW",
"/=",
"2",
";",
"}",
"return",
"scale",
";",
"}"
] | Calculating scale factor with limit of pixel amount
@param metadata image metadata
@param minH minimal height
@param minW minimal width
@return scale factor | [
"Calculating",
"scale",
"factor",
"with",
"limit",
"of",
"pixel",
"amount"
] | 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#L555-L565 |
alkacon/opencms-core | src/org/opencms/workplace/editors/CmsEditor.java | CmsEditor.buttonActionDirectEdit | public String buttonActionDirectEdit(String jsFunction, int type) {
"""
Builds the html to display the special action button for the direct edit mode of the editor.<p>
@param jsFunction the JavaScript function which will be executed on the mouseup event
@param type 0: image only (default), 1: image and text, 2: text only
@return the html to display the special action button
"""
// get the action class from the OpenCms runtime property
I_CmsEditorActionHandler actionClass = OpenCms.getWorkplaceManager().getEditorActionHandler();
String url;
String name;
boolean active = false;
if (actionClass != null) {
// get button parameters and state from action class
url = actionClass.getButtonUrl(getJsp(), getParamResource());
name = actionClass.getButtonName();
active = actionClass.isButtonActive(getJsp(), getParamResource());
} else {
// action class not defined, display inactive button
url = getSkinUri() + "buttons/publish_in.png";
name = Messages.GUI_EXPLORER_CONTEXT_PUBLISH_0;
}
String image = url.substring(url.lastIndexOf("/") + 1);
if (url.endsWith(".gif")) {
image = image.substring(0, image.length() - 4);
}
if (active) {
// create the link for the button
return button(
"javascript:" + jsFunction,
null,
image,
name,
type,
url.substring(0, url.lastIndexOf("/") + 1));
} else {
// create the inactive button
return button(null, null, image, name, type, url.substring(0, url.lastIndexOf("/") + 1));
}
} | java | public String buttonActionDirectEdit(String jsFunction, int type) {
// get the action class from the OpenCms runtime property
I_CmsEditorActionHandler actionClass = OpenCms.getWorkplaceManager().getEditorActionHandler();
String url;
String name;
boolean active = false;
if (actionClass != null) {
// get button parameters and state from action class
url = actionClass.getButtonUrl(getJsp(), getParamResource());
name = actionClass.getButtonName();
active = actionClass.isButtonActive(getJsp(), getParamResource());
} else {
// action class not defined, display inactive button
url = getSkinUri() + "buttons/publish_in.png";
name = Messages.GUI_EXPLORER_CONTEXT_PUBLISH_0;
}
String image = url.substring(url.lastIndexOf("/") + 1);
if (url.endsWith(".gif")) {
image = image.substring(0, image.length() - 4);
}
if (active) {
// create the link for the button
return button(
"javascript:" + jsFunction,
null,
image,
name,
type,
url.substring(0, url.lastIndexOf("/") + 1));
} else {
// create the inactive button
return button(null, null, image, name, type, url.substring(0, url.lastIndexOf("/") + 1));
}
} | [
"public",
"String",
"buttonActionDirectEdit",
"(",
"String",
"jsFunction",
",",
"int",
"type",
")",
"{",
"// get the action class from the OpenCms runtime property",
"I_CmsEditorActionHandler",
"actionClass",
"=",
"OpenCms",
".",
"getWorkplaceManager",
"(",
")",
".",
"getEditorActionHandler",
"(",
")",
";",
"String",
"url",
";",
"String",
"name",
";",
"boolean",
"active",
"=",
"false",
";",
"if",
"(",
"actionClass",
"!=",
"null",
")",
"{",
"// get button parameters and state from action class",
"url",
"=",
"actionClass",
".",
"getButtonUrl",
"(",
"getJsp",
"(",
")",
",",
"getParamResource",
"(",
")",
")",
";",
"name",
"=",
"actionClass",
".",
"getButtonName",
"(",
")",
";",
"active",
"=",
"actionClass",
".",
"isButtonActive",
"(",
"getJsp",
"(",
")",
",",
"getParamResource",
"(",
")",
")",
";",
"}",
"else",
"{",
"// action class not defined, display inactive button",
"url",
"=",
"getSkinUri",
"(",
")",
"+",
"\"buttons/publish_in.png\"",
";",
"name",
"=",
"Messages",
".",
"GUI_EXPLORER_CONTEXT_PUBLISH_0",
";",
"}",
"String",
"image",
"=",
"url",
".",
"substring",
"(",
"url",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
"+",
"1",
")",
";",
"if",
"(",
"url",
".",
"endsWith",
"(",
"\".gif\"",
")",
")",
"{",
"image",
"=",
"image",
".",
"substring",
"(",
"0",
",",
"image",
".",
"length",
"(",
")",
"-",
"4",
")",
";",
"}",
"if",
"(",
"active",
")",
"{",
"// create the link for the button",
"return",
"button",
"(",
"\"javascript:\"",
"+",
"jsFunction",
",",
"null",
",",
"image",
",",
"name",
",",
"type",
",",
"url",
".",
"substring",
"(",
"0",
",",
"url",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
"+",
"1",
")",
")",
";",
"}",
"else",
"{",
"// create the inactive button",
"return",
"button",
"(",
"null",
",",
"null",
",",
"image",
",",
"name",
",",
"type",
",",
"url",
".",
"substring",
"(",
"0",
",",
"url",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
"+",
"1",
")",
")",
";",
"}",
"}"
] | Builds the html to display the special action button for the direct edit mode of the editor.<p>
@param jsFunction the JavaScript function which will be executed on the mouseup event
@param type 0: image only (default), 1: image and text, 2: text only
@return the html to display the special action button | [
"Builds",
"the",
"html",
"to",
"display",
"the",
"special",
"action",
"button",
"for",
"the",
"direct",
"edit",
"mode",
"of",
"the",
"editor",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/editors/CmsEditor.java#L366-L401 |
sarl/sarl | main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/quickfix/SARLQuickfixProvider.java | SARLQuickfixProvider.fixInvalidImplementedType | @Fix(io.sarl.lang.validation.IssueCodes.INVALID_IMPLEMENTED_TYPE)
public void fixInvalidImplementedType(final Issue issue, IssueResolutionAcceptor acceptor) {
"""
Quick fix for "Invalid implemented type".
@param issue the issue.
@param acceptor the quick fix acceptor.
"""
ImplementedTypeRemoveModification.accept(this, issue, acceptor, RemovalType.OTHER);
} | java | @Fix(io.sarl.lang.validation.IssueCodes.INVALID_IMPLEMENTED_TYPE)
public void fixInvalidImplementedType(final Issue issue, IssueResolutionAcceptor acceptor) {
ImplementedTypeRemoveModification.accept(this, issue, acceptor, RemovalType.OTHER);
} | [
"@",
"Fix",
"(",
"io",
".",
"sarl",
".",
"lang",
".",
"validation",
".",
"IssueCodes",
".",
"INVALID_IMPLEMENTED_TYPE",
")",
"public",
"void",
"fixInvalidImplementedType",
"(",
"final",
"Issue",
"issue",
",",
"IssueResolutionAcceptor",
"acceptor",
")",
"{",
"ImplementedTypeRemoveModification",
".",
"accept",
"(",
"this",
",",
"issue",
",",
"acceptor",
",",
"RemovalType",
".",
"OTHER",
")",
";",
"}"
] | Quick fix for "Invalid implemented type".
@param issue the issue.
@param acceptor the quick fix acceptor. | [
"Quick",
"fix",
"for",
"Invalid",
"implemented",
"type",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/quickfix/SARLQuickfixProvider.java#L805-L808 |
weld/core | environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/WeldServletLifecycle.java | WeldServletLifecycle.findContainer | protected Container findContainer(ContainerContext ctx, StringBuilder dump) {
"""
Find container env.
@param ctx the container context
@param dump the exception dump
@return valid container or null
"""
Container container = null;
// 1. Custom container class
String containerClassName = ctx.getServletContext().getInitParameter(Container.CONTEXT_PARAM_CONTAINER_CLASS);
if (containerClassName != null) {
try {
Class<Container> containerClass = Reflections.classForName(resourceLoader, containerClassName);
container = SecurityActions.newInstance(containerClass);
WeldServletLogger.LOG.containerDetectionSkipped(containerClassName);
} catch (Exception e) {
WeldServletLogger.LOG.unableToInstantiateCustomContainerClass(containerClassName);
WeldServletLogger.LOG.catchingDebug(e);
}
}
if (container == null) {
// 2. Service providers
Iterable<Container> extContainers = ServiceLoader.load(Container.class, getClass().getClassLoader());
container = checkContainers(ctx, dump, extContainers);
if (container == null) {
// 3. Built-in containers in predefined order
container = checkContainers(ctx, dump,
Arrays.asList(TomcatContainer.INSTANCE, JettyContainer.INSTANCE, UndertowContainer.INSTANCE, GwtDevHostedModeContainer.INSTANCE));
}
}
return container;
} | java | protected Container findContainer(ContainerContext ctx, StringBuilder dump) {
Container container = null;
// 1. Custom container class
String containerClassName = ctx.getServletContext().getInitParameter(Container.CONTEXT_PARAM_CONTAINER_CLASS);
if (containerClassName != null) {
try {
Class<Container> containerClass = Reflections.classForName(resourceLoader, containerClassName);
container = SecurityActions.newInstance(containerClass);
WeldServletLogger.LOG.containerDetectionSkipped(containerClassName);
} catch (Exception e) {
WeldServletLogger.LOG.unableToInstantiateCustomContainerClass(containerClassName);
WeldServletLogger.LOG.catchingDebug(e);
}
}
if (container == null) {
// 2. Service providers
Iterable<Container> extContainers = ServiceLoader.load(Container.class, getClass().getClassLoader());
container = checkContainers(ctx, dump, extContainers);
if (container == null) {
// 3. Built-in containers in predefined order
container = checkContainers(ctx, dump,
Arrays.asList(TomcatContainer.INSTANCE, JettyContainer.INSTANCE, UndertowContainer.INSTANCE, GwtDevHostedModeContainer.INSTANCE));
}
}
return container;
} | [
"protected",
"Container",
"findContainer",
"(",
"ContainerContext",
"ctx",
",",
"StringBuilder",
"dump",
")",
"{",
"Container",
"container",
"=",
"null",
";",
"// 1. Custom container class",
"String",
"containerClassName",
"=",
"ctx",
".",
"getServletContext",
"(",
")",
".",
"getInitParameter",
"(",
"Container",
".",
"CONTEXT_PARAM_CONTAINER_CLASS",
")",
";",
"if",
"(",
"containerClassName",
"!=",
"null",
")",
"{",
"try",
"{",
"Class",
"<",
"Container",
">",
"containerClass",
"=",
"Reflections",
".",
"classForName",
"(",
"resourceLoader",
",",
"containerClassName",
")",
";",
"container",
"=",
"SecurityActions",
".",
"newInstance",
"(",
"containerClass",
")",
";",
"WeldServletLogger",
".",
"LOG",
".",
"containerDetectionSkipped",
"(",
"containerClassName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"WeldServletLogger",
".",
"LOG",
".",
"unableToInstantiateCustomContainerClass",
"(",
"containerClassName",
")",
";",
"WeldServletLogger",
".",
"LOG",
".",
"catchingDebug",
"(",
"e",
")",
";",
"}",
"}",
"if",
"(",
"container",
"==",
"null",
")",
"{",
"// 2. Service providers",
"Iterable",
"<",
"Container",
">",
"extContainers",
"=",
"ServiceLoader",
".",
"load",
"(",
"Container",
".",
"class",
",",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
")",
";",
"container",
"=",
"checkContainers",
"(",
"ctx",
",",
"dump",
",",
"extContainers",
")",
";",
"if",
"(",
"container",
"==",
"null",
")",
"{",
"// 3. Built-in containers in predefined order",
"container",
"=",
"checkContainers",
"(",
"ctx",
",",
"dump",
",",
"Arrays",
".",
"asList",
"(",
"TomcatContainer",
".",
"INSTANCE",
",",
"JettyContainer",
".",
"INSTANCE",
",",
"UndertowContainer",
".",
"INSTANCE",
",",
"GwtDevHostedModeContainer",
".",
"INSTANCE",
")",
")",
";",
"}",
"}",
"return",
"container",
";",
"}"
] | Find container env.
@param ctx the container context
@param dump the exception dump
@return valid container or null | [
"Find",
"container",
"env",
"."
] | train | https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/WeldServletLifecycle.java#L341-L366 |
alkacon/opencms-core | src/org/opencms/workflow/CmsExtendedWorkflowManager.java | CmsExtendedWorkflowManager.checkNewParentsInList | protected void checkNewParentsInList(CmsObject userCms, List<CmsResource> resources) throws CmsException {
"""
Checks that the parent folders of new resources which are released are either not new or are also released.<p>
@param userCms the user CMS context
@param resources the resources to check
@throws CmsException if the check fails
"""
Map<String, CmsResource> resourcesByPath = new HashMap<String, CmsResource>();
CmsObject rootCms = OpenCms.initCmsObject(m_adminCms);
rootCms.getRequestContext().setCurrentProject(userCms.getRequestContext().getCurrentProject());
rootCms.getRequestContext().setSiteRoot("");
for (CmsResource resource : resources) {
resourcesByPath.put(resource.getRootPath(), resource);
}
for (CmsResource resource : resources) {
if (resource.getState().isNew()) {
String parentPath = CmsResource.getParentFolder(resource.getRootPath());
CmsResource parent = resourcesByPath.get(parentPath);
if (parent == null) {
parent = rootCms.readResource(parentPath);
if (parent.getState().isNew()) {
throw new CmsNewParentNotInWorkflowException(
Messages.get().container(
Messages.ERR_NEW_PARENT_NOT_IN_WORKFLOW_1,
resource.getRootPath()));
}
}
}
}
} | java | protected void checkNewParentsInList(CmsObject userCms, List<CmsResource> resources) throws CmsException {
Map<String, CmsResource> resourcesByPath = new HashMap<String, CmsResource>();
CmsObject rootCms = OpenCms.initCmsObject(m_adminCms);
rootCms.getRequestContext().setCurrentProject(userCms.getRequestContext().getCurrentProject());
rootCms.getRequestContext().setSiteRoot("");
for (CmsResource resource : resources) {
resourcesByPath.put(resource.getRootPath(), resource);
}
for (CmsResource resource : resources) {
if (resource.getState().isNew()) {
String parentPath = CmsResource.getParentFolder(resource.getRootPath());
CmsResource parent = resourcesByPath.get(parentPath);
if (parent == null) {
parent = rootCms.readResource(parentPath);
if (parent.getState().isNew()) {
throw new CmsNewParentNotInWorkflowException(
Messages.get().container(
Messages.ERR_NEW_PARENT_NOT_IN_WORKFLOW_1,
resource.getRootPath()));
}
}
}
}
} | [
"protected",
"void",
"checkNewParentsInList",
"(",
"CmsObject",
"userCms",
",",
"List",
"<",
"CmsResource",
">",
"resources",
")",
"throws",
"CmsException",
"{",
"Map",
"<",
"String",
",",
"CmsResource",
">",
"resourcesByPath",
"=",
"new",
"HashMap",
"<",
"String",
",",
"CmsResource",
">",
"(",
")",
";",
"CmsObject",
"rootCms",
"=",
"OpenCms",
".",
"initCmsObject",
"(",
"m_adminCms",
")",
";",
"rootCms",
".",
"getRequestContext",
"(",
")",
".",
"setCurrentProject",
"(",
"userCms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentProject",
"(",
")",
")",
";",
"rootCms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"\"\"",
")",
";",
"for",
"(",
"CmsResource",
"resource",
":",
"resources",
")",
"{",
"resourcesByPath",
".",
"put",
"(",
"resource",
".",
"getRootPath",
"(",
")",
",",
"resource",
")",
";",
"}",
"for",
"(",
"CmsResource",
"resource",
":",
"resources",
")",
"{",
"if",
"(",
"resource",
".",
"getState",
"(",
")",
".",
"isNew",
"(",
")",
")",
"{",
"String",
"parentPath",
"=",
"CmsResource",
".",
"getParentFolder",
"(",
"resource",
".",
"getRootPath",
"(",
")",
")",
";",
"CmsResource",
"parent",
"=",
"resourcesByPath",
".",
"get",
"(",
"parentPath",
")",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"parent",
"=",
"rootCms",
".",
"readResource",
"(",
"parentPath",
")",
";",
"if",
"(",
"parent",
".",
"getState",
"(",
")",
".",
"isNew",
"(",
")",
")",
"{",
"throw",
"new",
"CmsNewParentNotInWorkflowException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_NEW_PARENT_NOT_IN_WORKFLOW_1",
",",
"resource",
".",
"getRootPath",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Checks that the parent folders of new resources which are released are either not new or are also released.<p>
@param userCms the user CMS context
@param resources the resources to check
@throws CmsException if the check fails | [
"Checks",
"that",
"the",
"parent",
"folders",
"of",
"new",
"resources",
"which",
"are",
"released",
"are",
"either",
"not",
"new",
"or",
"are",
"also",
"released",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workflow/CmsExtendedWorkflowManager.java#L368-L392 |
languagetool-org/languagetool | languagetool-core/src/main/java/org/languagetool/tools/StringTools.java | StringTools.uppercaseFirstChar | @Nullable
public static String uppercaseFirstChar(String str, Language language) {
"""
Like {@link #uppercaseFirstChar(String)}, but handles a special case for Dutch (IJ in
e.g. "ijsselmeer" -> "IJsselmeer").
@param language the language, will be ignored if it's {@code null}
@since 2.7
"""
if (language != null && "nl".equals(language.getShortCode()) && str != null && str.toLowerCase().startsWith("ij")) {
// hack to fix https://github.com/languagetool-org/languagetool/issues/148
return "IJ" + str.substring(2);
} else {
return changeFirstCharCase(str, true);
}
} | java | @Nullable
public static String uppercaseFirstChar(String str, Language language) {
if (language != null && "nl".equals(language.getShortCode()) && str != null && str.toLowerCase().startsWith("ij")) {
// hack to fix https://github.com/languagetool-org/languagetool/issues/148
return "IJ" + str.substring(2);
} else {
return changeFirstCharCase(str, true);
}
} | [
"@",
"Nullable",
"public",
"static",
"String",
"uppercaseFirstChar",
"(",
"String",
"str",
",",
"Language",
"language",
")",
"{",
"if",
"(",
"language",
"!=",
"null",
"&&",
"\"nl\"",
".",
"equals",
"(",
"language",
".",
"getShortCode",
"(",
")",
")",
"&&",
"str",
"!=",
"null",
"&&",
"str",
".",
"toLowerCase",
"(",
")",
".",
"startsWith",
"(",
"\"ij\"",
")",
")",
"{",
"// hack to fix https://github.com/languagetool-org/languagetool/issues/148",
"return",
"\"IJ\"",
"+",
"str",
".",
"substring",
"(",
"2",
")",
";",
"}",
"else",
"{",
"return",
"changeFirstCharCase",
"(",
"str",
",",
"true",
")",
";",
"}",
"}"
] | Like {@link #uppercaseFirstChar(String)}, but handles a special case for Dutch (IJ in
e.g. "ijsselmeer" -> "IJsselmeer").
@param language the language, will be ignored if it's {@code null}
@since 2.7 | [
"Like",
"{"
] | train | https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/tools/StringTools.java#L206-L214 |
aws/aws-sdk-java | aws-java-sdk-guardduty/src/main/java/com/amazonaws/services/guardduty/model/FindingStatistics.java | FindingStatistics.withCountBySeverity | public FindingStatistics withCountBySeverity(java.util.Map<String, Integer> countBySeverity) {
"""
Represents a map of severity to count statistic for a set of findings
@param countBySeverity
Represents a map of severity to count statistic for a set of findings
@return Returns a reference to this object so that method calls can be chained together.
"""
setCountBySeverity(countBySeverity);
return this;
} | java | public FindingStatistics withCountBySeverity(java.util.Map<String, Integer> countBySeverity) {
setCountBySeverity(countBySeverity);
return this;
} | [
"public",
"FindingStatistics",
"withCountBySeverity",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"Integer",
">",
"countBySeverity",
")",
"{",
"setCountBySeverity",
"(",
"countBySeverity",
")",
";",
"return",
"this",
";",
"}"
] | Represents a map of severity to count statistic for a set of findings
@param countBySeverity
Represents a map of severity to count statistic for a set of findings
@return Returns a reference to this object so that method calls can be chained together. | [
"Represents",
"a",
"map",
"of",
"severity",
"to",
"count",
"statistic",
"for",
"a",
"set",
"of",
"findings"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-guardduty/src/main/java/com/amazonaws/services/guardduty/model/FindingStatistics.java#L61-L64 |
OpenLiberty/open-liberty | dev/com.ibm.ws.product.utility/src/com/ibm/ws/product/utility/extension/IFixCompareCommandTask.java | IFixCompareCommandTask.isIFixApplicable | private boolean isIFixApplicable(Version productVersion, IFixInfo iFixInfo) throws VersionParsingException {
"""
Returns <code>true</code> if the IFixInfo applies the current installation version.
@param productVersion
@param iFixInfo
@return
"""
// If we don't know the product version just return true
if (productVersion == null) {
return true;
}
// Get the applicability for the iFix
Applicability applicability = iFixInfo.getApplicability();
if (applicability == null) {
throw new VersionParsingException(getMessage("compare.unable.to.find.offering", iFixInfo.getId()));
}
List<Offering> offerings = applicability.getOfferings();
if (offerings == null || offerings.isEmpty()) {
throw new VersionParsingException(getMessage("compare.unable.to.find.offering", iFixInfo.getId()));
}
// All offerings do not have the same version range so we need to iterate to see if we match
// an of the applicable ranges
boolean matches = false;
for (Offering offering : offerings) {
String tolerance = offering.getTolerance();
VersionRange toleranceRange = VersionRange.parseVersionRange(tolerance);
// Make sure the product version is in the range of the tolerance
if (toleranceRange.matches(productVersion)) {
matches = true;
break;
}
}
return matches;
} | java | private boolean isIFixApplicable(Version productVersion, IFixInfo iFixInfo) throws VersionParsingException {
// If we don't know the product version just return true
if (productVersion == null) {
return true;
}
// Get the applicability for the iFix
Applicability applicability = iFixInfo.getApplicability();
if (applicability == null) {
throw new VersionParsingException(getMessage("compare.unable.to.find.offering", iFixInfo.getId()));
}
List<Offering> offerings = applicability.getOfferings();
if (offerings == null || offerings.isEmpty()) {
throw new VersionParsingException(getMessage("compare.unable.to.find.offering", iFixInfo.getId()));
}
// All offerings do not have the same version range so we need to iterate to see if we match
// an of the applicable ranges
boolean matches = false;
for (Offering offering : offerings) {
String tolerance = offering.getTolerance();
VersionRange toleranceRange = VersionRange.parseVersionRange(tolerance);
// Make sure the product version is in the range of the tolerance
if (toleranceRange.matches(productVersion)) {
matches = true;
break;
}
}
return matches;
} | [
"private",
"boolean",
"isIFixApplicable",
"(",
"Version",
"productVersion",
",",
"IFixInfo",
"iFixInfo",
")",
"throws",
"VersionParsingException",
"{",
"// If we don't know the product version just return true",
"if",
"(",
"productVersion",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"// Get the applicability for the iFix",
"Applicability",
"applicability",
"=",
"iFixInfo",
".",
"getApplicability",
"(",
")",
";",
"if",
"(",
"applicability",
"==",
"null",
")",
"{",
"throw",
"new",
"VersionParsingException",
"(",
"getMessage",
"(",
"\"compare.unable.to.find.offering\"",
",",
"iFixInfo",
".",
"getId",
"(",
")",
")",
")",
";",
"}",
"List",
"<",
"Offering",
">",
"offerings",
"=",
"applicability",
".",
"getOfferings",
"(",
")",
";",
"if",
"(",
"offerings",
"==",
"null",
"||",
"offerings",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"VersionParsingException",
"(",
"getMessage",
"(",
"\"compare.unable.to.find.offering\"",
",",
"iFixInfo",
".",
"getId",
"(",
")",
")",
")",
";",
"}",
"// All offerings do not have the same version range so we need to iterate to see if we match",
"// an of the applicable ranges",
"boolean",
"matches",
"=",
"false",
";",
"for",
"(",
"Offering",
"offering",
":",
"offerings",
")",
"{",
"String",
"tolerance",
"=",
"offering",
".",
"getTolerance",
"(",
")",
";",
"VersionRange",
"toleranceRange",
"=",
"VersionRange",
".",
"parseVersionRange",
"(",
"tolerance",
")",
";",
"// Make sure the product version is in the range of the tolerance",
"if",
"(",
"toleranceRange",
".",
"matches",
"(",
"productVersion",
")",
")",
"{",
"matches",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"matches",
";",
"}"
] | Returns <code>true</code> if the IFixInfo applies the current installation version.
@param productVersion
@param iFixInfo
@return | [
"Returns",
"<code",
">",
"true<",
"/",
"code",
">",
"if",
"the",
"IFixInfo",
"applies",
"the",
"current",
"installation",
"version",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.product.utility/src/com/ibm/ws/product/utility/extension/IFixCompareCommandTask.java#L474-L504 |
airbnb/lottie-android | lottie/src/main/java/com/airbnb/lottie/model/KeyPath.java | KeyPath.fullyResolvesTo | @RestrictTo(RestrictTo.Scope.LIBRARY)
public boolean fullyResolvesTo(String key, int depth) {
"""
Returns whether the key at specified depth is fully specific enough to match the full set of
keys in this keypath.
"""
if (depth >= keys.size()) {
return false;
}
boolean isLastDepth = depth == keys.size() - 1;
String keyAtDepth = keys.get(depth);
boolean isGlobstar = keyAtDepth.equals("**");
if (!isGlobstar) {
boolean matches = keyAtDepth.equals(key) || keyAtDepth.equals("*");
return (isLastDepth || (depth == keys.size() - 2 && endsWithGlobstar())) && matches;
}
boolean isGlobstarButNextKeyMatches = !isLastDepth && keys.get(depth + 1).equals(key);
if (isGlobstarButNextKeyMatches) {
return depth == keys.size() - 2 ||
(depth == keys.size() - 3 && endsWithGlobstar());
}
if (isLastDepth) {
return true;
}
if (depth + 1 < keys.size() - 1) {
// We are a globstar but there is more than 1 key after the globstar we we can't fully match.
return false;
}
// Return whether the next key (which we now know is the last one) is the same as the current
// key.
return keys.get(depth + 1).equals(key);
} | java | @RestrictTo(RestrictTo.Scope.LIBRARY)
public boolean fullyResolvesTo(String key, int depth) {
if (depth >= keys.size()) {
return false;
}
boolean isLastDepth = depth == keys.size() - 1;
String keyAtDepth = keys.get(depth);
boolean isGlobstar = keyAtDepth.equals("**");
if (!isGlobstar) {
boolean matches = keyAtDepth.equals(key) || keyAtDepth.equals("*");
return (isLastDepth || (depth == keys.size() - 2 && endsWithGlobstar())) && matches;
}
boolean isGlobstarButNextKeyMatches = !isLastDepth && keys.get(depth + 1).equals(key);
if (isGlobstarButNextKeyMatches) {
return depth == keys.size() - 2 ||
(depth == keys.size() - 3 && endsWithGlobstar());
}
if (isLastDepth) {
return true;
}
if (depth + 1 < keys.size() - 1) {
// We are a globstar but there is more than 1 key after the globstar we we can't fully match.
return false;
}
// Return whether the next key (which we now know is the last one) is the same as the current
// key.
return keys.get(depth + 1).equals(key);
} | [
"@",
"RestrictTo",
"(",
"RestrictTo",
".",
"Scope",
".",
"LIBRARY",
")",
"public",
"boolean",
"fullyResolvesTo",
"(",
"String",
"key",
",",
"int",
"depth",
")",
"{",
"if",
"(",
"depth",
">=",
"keys",
".",
"size",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"boolean",
"isLastDepth",
"=",
"depth",
"==",
"keys",
".",
"size",
"(",
")",
"-",
"1",
";",
"String",
"keyAtDepth",
"=",
"keys",
".",
"get",
"(",
"depth",
")",
";",
"boolean",
"isGlobstar",
"=",
"keyAtDepth",
".",
"equals",
"(",
"\"**\"",
")",
";",
"if",
"(",
"!",
"isGlobstar",
")",
"{",
"boolean",
"matches",
"=",
"keyAtDepth",
".",
"equals",
"(",
"key",
")",
"||",
"keyAtDepth",
".",
"equals",
"(",
"\"*\"",
")",
";",
"return",
"(",
"isLastDepth",
"||",
"(",
"depth",
"==",
"keys",
".",
"size",
"(",
")",
"-",
"2",
"&&",
"endsWithGlobstar",
"(",
")",
")",
")",
"&&",
"matches",
";",
"}",
"boolean",
"isGlobstarButNextKeyMatches",
"=",
"!",
"isLastDepth",
"&&",
"keys",
".",
"get",
"(",
"depth",
"+",
"1",
")",
".",
"equals",
"(",
"key",
")",
";",
"if",
"(",
"isGlobstarButNextKeyMatches",
")",
"{",
"return",
"depth",
"==",
"keys",
".",
"size",
"(",
")",
"-",
"2",
"||",
"(",
"depth",
"==",
"keys",
".",
"size",
"(",
")",
"-",
"3",
"&&",
"endsWithGlobstar",
"(",
")",
")",
";",
"}",
"if",
"(",
"isLastDepth",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"depth",
"+",
"1",
"<",
"keys",
".",
"size",
"(",
")",
"-",
"1",
")",
"{",
"// We are a globstar but there is more than 1 key after the globstar we we can't fully match.",
"return",
"false",
";",
"}",
"// Return whether the next key (which we now know is the last one) is the same as the current",
"// key.",
"return",
"keys",
".",
"get",
"(",
"depth",
"+",
"1",
")",
".",
"equals",
"(",
"key",
")",
";",
"}"
] | Returns whether the key at specified depth is fully specific enough to match the full set of
keys in this keypath. | [
"Returns",
"whether",
"the",
"key",
"at",
"specified",
"depth",
"is",
"fully",
"specific",
"enough",
"to",
"match",
"the",
"full",
"set",
"of",
"keys",
"in",
"this",
"keypath",
"."
] | train | https://github.com/airbnb/lottie-android/blob/126dabdc9f586c87822f85fe1128cdad439d30fa/lottie/src/main/java/com/airbnb/lottie/model/KeyPath.java#L148-L178 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/distort/spherical/EquirectangularTools_F32.java | EquirectangularTools_F32.latlonToEqui | public void latlonToEqui(float lat, float lon, Point2D_F32 rect) {
"""
Convert from latitude-longitude coordinates into equirectangular coordinates
@param lat Latitude
@param lon Longitude
@param rect (Output) equirectangular coordinate
"""
rect.x = UtilAngle.wrapZeroToOne(lon / GrlConstants.F_PI2 + 0.5f)*width;
rect.y = UtilAngle.reflectZeroToOne(lat / GrlConstants.F_PI + 0.5f)*(height-1);
} | java | public void latlonToEqui(float lat, float lon, Point2D_F32 rect) {
rect.x = UtilAngle.wrapZeroToOne(lon / GrlConstants.F_PI2 + 0.5f)*width;
rect.y = UtilAngle.reflectZeroToOne(lat / GrlConstants.F_PI + 0.5f)*(height-1);
} | [
"public",
"void",
"latlonToEqui",
"(",
"float",
"lat",
",",
"float",
"lon",
",",
"Point2D_F32",
"rect",
")",
"{",
"rect",
".",
"x",
"=",
"UtilAngle",
".",
"wrapZeroToOne",
"(",
"lon",
"/",
"GrlConstants",
".",
"F_PI2",
"+",
"0.5f",
")",
"*",
"width",
";",
"rect",
".",
"y",
"=",
"UtilAngle",
".",
"reflectZeroToOne",
"(",
"lat",
"/",
"GrlConstants",
".",
"F_PI",
"+",
"0.5f",
")",
"*",
"(",
"height",
"-",
"1",
")",
";",
"}"
] | Convert from latitude-longitude coordinates into equirectangular coordinates
@param lat Latitude
@param lon Longitude
@param rect (Output) equirectangular coordinate | [
"Convert",
"from",
"latitude",
"-",
"longitude",
"coordinates",
"into",
"equirectangular",
"coordinates"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/distort/spherical/EquirectangularTools_F32.java#L145-L148 |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/internal/provisioning/api/UsersApi.java | UsersApi.updateUser | public ApiSuccessResponse updateUser(String dbid, UpdateUserData updateUserData) throws ApiException {
"""
Update a user.
Update a user ([CfgPerson](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgPerson)) with the specified attributes.
@param dbid The user's DBID. (required)
@param updateUserData Update user data (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<ApiSuccessResponse> resp = updateUserWithHttpInfo(dbid, updateUserData);
return resp.getData();
} | java | public ApiSuccessResponse updateUser(String dbid, UpdateUserData updateUserData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = updateUserWithHttpInfo(dbid, updateUserData);
return resp.getData();
} | [
"public",
"ApiSuccessResponse",
"updateUser",
"(",
"String",
"dbid",
",",
"UpdateUserData",
"updateUserData",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ApiSuccessResponse",
">",
"resp",
"=",
"updateUserWithHttpInfo",
"(",
"dbid",
",",
"updateUserData",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Update a user.
Update a user ([CfgPerson](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgPerson)) with the specified attributes.
@param dbid The user's DBID. (required)
@param updateUserData Update user data (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Update",
"a",
"user",
".",
"Update",
"a",
"user",
"(",
"[",
"CfgPerson",
"]",
"(",
"https",
":",
"//",
"docs",
".",
"genesys",
".",
"com",
"/",
"Documentation",
"/",
"PSDK",
"/",
"latest",
"/",
"ConfigLayerRef",
"/",
"CfgPerson",
"))",
"with",
"the",
"specified",
"attributes",
"."
] | train | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/internal/provisioning/api/UsersApi.java#L800-L803 |
infinispan/infinispan | hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/access/PutFromLoadValidator.java | PutFromLoadValidator.endInvalidatingKey | public boolean endInvalidatingKey(Object lockOwner, Object key, boolean doPFER) {
"""
Called after the transaction completes, allowing caching of entries. It is possible that this method
is called without previous invocation of {@link #beginInvalidatingKey(Object, Object)}, then it should be a no-op.
@param lockOwner owner of the invalidation - transaction or thread
@param key
@return
"""
PendingPutMap pending = pendingPuts.get(key);
if (pending == null) {
if (trace) {
log.tracef("endInvalidatingKey(%s#%s, %s) could not find pending puts", cache.getName(), key, lockOwnerToString(lockOwner));
}
return true;
}
if (pending.acquireLock(60, TimeUnit.SECONDS)) {
try {
long now = timeSource.nextTimestamp();
pending.removeInvalidator(lockOwner, key, now, doPFER);
// we can't remove the pending put yet because we wait for naked puts
// pendingPuts should be configured with maxIdle time so won't have memory leak
return true;
}
finally {
pending.releaseLock();
if (trace) {
log.tracef("endInvalidatingKey(%s#%s, %s) ends with %s", cache.getName(), key, lockOwnerToString(lockOwner), pending);
}
}
}
else {
if (trace) {
log.tracef("endInvalidatingKey(%s#%s, %s) failed to acquire lock", cache.getName(), key, lockOwnerToString(lockOwner));
}
return false;
}
} | java | public boolean endInvalidatingKey(Object lockOwner, Object key, boolean doPFER) {
PendingPutMap pending = pendingPuts.get(key);
if (pending == null) {
if (trace) {
log.tracef("endInvalidatingKey(%s#%s, %s) could not find pending puts", cache.getName(), key, lockOwnerToString(lockOwner));
}
return true;
}
if (pending.acquireLock(60, TimeUnit.SECONDS)) {
try {
long now = timeSource.nextTimestamp();
pending.removeInvalidator(lockOwner, key, now, doPFER);
// we can't remove the pending put yet because we wait for naked puts
// pendingPuts should be configured with maxIdle time so won't have memory leak
return true;
}
finally {
pending.releaseLock();
if (trace) {
log.tracef("endInvalidatingKey(%s#%s, %s) ends with %s", cache.getName(), key, lockOwnerToString(lockOwner), pending);
}
}
}
else {
if (trace) {
log.tracef("endInvalidatingKey(%s#%s, %s) failed to acquire lock", cache.getName(), key, lockOwnerToString(lockOwner));
}
return false;
}
} | [
"public",
"boolean",
"endInvalidatingKey",
"(",
"Object",
"lockOwner",
",",
"Object",
"key",
",",
"boolean",
"doPFER",
")",
"{",
"PendingPutMap",
"pending",
"=",
"pendingPuts",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"pending",
"==",
"null",
")",
"{",
"if",
"(",
"trace",
")",
"{",
"log",
".",
"tracef",
"(",
"\"endInvalidatingKey(%s#%s, %s) could not find pending puts\"",
",",
"cache",
".",
"getName",
"(",
")",
",",
"key",
",",
"lockOwnerToString",
"(",
"lockOwner",
")",
")",
";",
"}",
"return",
"true",
";",
"}",
"if",
"(",
"pending",
".",
"acquireLock",
"(",
"60",
",",
"TimeUnit",
".",
"SECONDS",
")",
")",
"{",
"try",
"{",
"long",
"now",
"=",
"timeSource",
".",
"nextTimestamp",
"(",
")",
";",
"pending",
".",
"removeInvalidator",
"(",
"lockOwner",
",",
"key",
",",
"now",
",",
"doPFER",
")",
";",
"// we can't remove the pending put yet because we wait for naked puts",
"// pendingPuts should be configured with maxIdle time so won't have memory leak",
"return",
"true",
";",
"}",
"finally",
"{",
"pending",
".",
"releaseLock",
"(",
")",
";",
"if",
"(",
"trace",
")",
"{",
"log",
".",
"tracef",
"(",
"\"endInvalidatingKey(%s#%s, %s) ends with %s\"",
",",
"cache",
".",
"getName",
"(",
")",
",",
"key",
",",
"lockOwnerToString",
"(",
"lockOwner",
")",
",",
"pending",
")",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"trace",
")",
"{",
"log",
".",
"tracef",
"(",
"\"endInvalidatingKey(%s#%s, %s) failed to acquire lock\"",
",",
"cache",
".",
"getName",
"(",
")",
",",
"key",
",",
"lockOwnerToString",
"(",
"lockOwner",
")",
")",
";",
"}",
"return",
"false",
";",
"}",
"}"
] | Called after the transaction completes, allowing caching of entries. It is possible that this method
is called without previous invocation of {@link #beginInvalidatingKey(Object, Object)}, then it should be a no-op.
@param lockOwner owner of the invalidation - transaction or thread
@param key
@return | [
"Called",
"after",
"the",
"transaction",
"completes",
"allowing",
"caching",
"of",
"entries",
".",
"It",
"is",
"possible",
"that",
"this",
"method",
"is",
"called",
"without",
"previous",
"invocation",
"of",
"{",
"@link",
"#beginInvalidatingKey",
"(",
"Object",
"Object",
")",
"}",
"then",
"it",
"should",
"be",
"a",
"no",
"-",
"op",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/access/PutFromLoadValidator.java#L623-L652 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java | Feature.setStringAttribute | public void setStringAttribute(String name, String value) {
"""
Set attribute value of given type.
@param name attribute name
@param value attribute value
"""
Attribute attribute = getAttributes().get(name);
if (!(attribute instanceof StringAttribute)) {
throw new IllegalStateException("Cannot set boolean value on attribute with different type, " +
attribute.getClass().getName() + " setting value " + value);
}
((StringAttribute) attribute).setValue(value);
} | java | public void setStringAttribute(String name, String value) {
Attribute attribute = getAttributes().get(name);
if (!(attribute instanceof StringAttribute)) {
throw new IllegalStateException("Cannot set boolean value on attribute with different type, " +
attribute.getClass().getName() + " setting value " + value);
}
((StringAttribute) attribute).setValue(value);
} | [
"public",
"void",
"setStringAttribute",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"Attribute",
"attribute",
"=",
"getAttributes",
"(",
")",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"!",
"(",
"attribute",
"instanceof",
"StringAttribute",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot set boolean value on attribute with different type, \"",
"+",
"attribute",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" setting value \"",
"+",
"value",
")",
";",
"}",
"(",
"(",
"StringAttribute",
")",
"attribute",
")",
".",
"setValue",
"(",
"value",
")",
";",
"}"
] | Set attribute value of given type.
@param name attribute name
@param value attribute value | [
"Set",
"attribute",
"value",
"of",
"given",
"type",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java#L350-L357 |
sagiegurari/fax4j | src/main/java/org/fax4j/spi/hylafax/HylaFaxClientSpi.java | HylaFaxClientSpi.cancelFaxJob | protected void cancelFaxJob(HylaFaxJob faxJob,HylaFAXClient client) throws Exception {
"""
This function will cancel an existing fax job.
@param client
The client instance
@param faxJob
The fax job object containing the needed information
@throws Exception
Any exception
"""
//get job
Job job=faxJob.getHylaFaxJob();
//cancel job
client.kill(job);
} | java | protected void cancelFaxJob(HylaFaxJob faxJob,HylaFAXClient client) throws Exception
{
//get job
Job job=faxJob.getHylaFaxJob();
//cancel job
client.kill(job);
} | [
"protected",
"void",
"cancelFaxJob",
"(",
"HylaFaxJob",
"faxJob",
",",
"HylaFAXClient",
"client",
")",
"throws",
"Exception",
"{",
"//get job",
"Job",
"job",
"=",
"faxJob",
".",
"getHylaFaxJob",
"(",
")",
";",
"//cancel job",
"client",
".",
"kill",
"(",
"job",
")",
";",
"}"
] | This function will cancel an existing fax job.
@param client
The client instance
@param faxJob
The fax job object containing the needed information
@throws Exception
Any exception | [
"This",
"function",
"will",
"cancel",
"an",
"existing",
"fax",
"job",
"."
] | train | https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxClientSpi.java#L491-L498 |
fuwjax/ev-oss | funco/src/main/java/org/fuwjax/oss/util/assertion/Assert2.java | Assert2.assertByteEquals | public static void assertByteEquals(final Path sub, final Path expected, final Path actual) throws IOException {
"""
Asserts that two paths are byte-equivalent.
@param sub the shared portion of the two paths
@param expected the expected path
@param actual the actual path
@throws IOException if the paths cannot be opened and consumed
"""
final int length = 4096;
final byte[] hereBuffer = new byte[length];
final byte[] thereBuffer = new byte[length];
long hereLimit = 0;
long thereLimit = 0;
try(InputStream hereStream = newInputStream(expected); InputStream thereStream = newInputStream(actual)) {
int line = 1;
int ch = 0;
for(long i = 0; i < Files.size(expected); i++) {
if(i >= hereLimit) {
hereLimit += read(hereStream, hereBuffer, hereLimit);
}
if(i >= thereLimit) {
thereLimit += read(thereStream, thereBuffer, thereLimit);
}
final int c = hereBuffer[(int) (i % length)];
assertThat(thereBuffer[(int) (i % length)], asserts(message(sub, i, line, ch), t -> t == c));
if(c == '\n') {
ch = 0;
line++;
} else {
ch++;
}
}
}
} | java | public static void assertByteEquals(final Path sub, final Path expected, final Path actual) throws IOException {
final int length = 4096;
final byte[] hereBuffer = new byte[length];
final byte[] thereBuffer = new byte[length];
long hereLimit = 0;
long thereLimit = 0;
try(InputStream hereStream = newInputStream(expected); InputStream thereStream = newInputStream(actual)) {
int line = 1;
int ch = 0;
for(long i = 0; i < Files.size(expected); i++) {
if(i >= hereLimit) {
hereLimit += read(hereStream, hereBuffer, hereLimit);
}
if(i >= thereLimit) {
thereLimit += read(thereStream, thereBuffer, thereLimit);
}
final int c = hereBuffer[(int) (i % length)];
assertThat(thereBuffer[(int) (i % length)], asserts(message(sub, i, line, ch), t -> t == c));
if(c == '\n') {
ch = 0;
line++;
} else {
ch++;
}
}
}
} | [
"public",
"static",
"void",
"assertByteEquals",
"(",
"final",
"Path",
"sub",
",",
"final",
"Path",
"expected",
",",
"final",
"Path",
"actual",
")",
"throws",
"IOException",
"{",
"final",
"int",
"length",
"=",
"4096",
";",
"final",
"byte",
"[",
"]",
"hereBuffer",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"final",
"byte",
"[",
"]",
"thereBuffer",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"long",
"hereLimit",
"=",
"0",
";",
"long",
"thereLimit",
"=",
"0",
";",
"try",
"(",
"InputStream",
"hereStream",
"=",
"newInputStream",
"(",
"expected",
")",
";",
"InputStream",
"thereStream",
"=",
"newInputStream",
"(",
"actual",
")",
")",
"{",
"int",
"line",
"=",
"1",
";",
"int",
"ch",
"=",
"0",
";",
"for",
"(",
"long",
"i",
"=",
"0",
";",
"i",
"<",
"Files",
".",
"size",
"(",
"expected",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">=",
"hereLimit",
")",
"{",
"hereLimit",
"+=",
"read",
"(",
"hereStream",
",",
"hereBuffer",
",",
"hereLimit",
")",
";",
"}",
"if",
"(",
"i",
">=",
"thereLimit",
")",
"{",
"thereLimit",
"+=",
"read",
"(",
"thereStream",
",",
"thereBuffer",
",",
"thereLimit",
")",
";",
"}",
"final",
"int",
"c",
"=",
"hereBuffer",
"[",
"(",
"int",
")",
"(",
"i",
"%",
"length",
")",
"]",
";",
"assertThat",
"(",
"thereBuffer",
"[",
"(",
"int",
")",
"(",
"i",
"%",
"length",
")",
"]",
",",
"asserts",
"(",
"message",
"(",
"sub",
",",
"i",
",",
"line",
",",
"ch",
")",
",",
"t",
"->",
"t",
"==",
"c",
")",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"ch",
"=",
"0",
";",
"line",
"++",
";",
"}",
"else",
"{",
"ch",
"++",
";",
"}",
"}",
"}",
"}"
] | Asserts that two paths are byte-equivalent.
@param sub the shared portion of the two paths
@param expected the expected path
@param actual the actual path
@throws IOException if the paths cannot be opened and consumed | [
"Asserts",
"that",
"two",
"paths",
"are",
"byte",
"-",
"equivalent",
"."
] | train | https://github.com/fuwjax/ev-oss/blob/cbd88592e9b2fa9547c3bdd41e52e790061a2253/funco/src/main/java/org/fuwjax/oss/util/assertion/Assert2.java#L152-L178 |
alkacon/opencms-core | src/org/opencms/file/CmsProperty.java | CmsProperty.createValueFromMap | private String createValueFromMap(Map<String, String> valueMap) {
"""
Returns the single String value representation for the given value map.<p>
@param valueMap the value map to create the single String value for
@return the single String value representation for the given value map
"""
if (valueMap == null) {
return null;
}
StringBuffer result = new StringBuffer(valueMap.size() * 32);
Iterator<Map.Entry<String, String>> i = valueMap.entrySet().iterator();
while (i.hasNext()) {
Map.Entry<String, String> entry = i.next();
String key = entry.getKey();
String value = entry.getValue();
key = replaceDelimiter(key, VALUE_LIST_DELIMITER, VALUE_LIST_DELIMITER_REPLACEMENT);
key = replaceDelimiter(key, VALUE_MAP_DELIMITER, VALUE_MAP_DELIMITER_REPLACEMENT);
value = replaceDelimiter(value, VALUE_LIST_DELIMITER, VALUE_LIST_DELIMITER_REPLACEMENT);
value = replaceDelimiter(value, VALUE_MAP_DELIMITER, VALUE_MAP_DELIMITER_REPLACEMENT);
result.append(key);
result.append(VALUE_MAP_DELIMITER);
result.append(value);
if (i.hasNext()) {
result.append(VALUE_LIST_DELIMITER);
}
}
return result.toString();
} | java | private String createValueFromMap(Map<String, String> valueMap) {
if (valueMap == null) {
return null;
}
StringBuffer result = new StringBuffer(valueMap.size() * 32);
Iterator<Map.Entry<String, String>> i = valueMap.entrySet().iterator();
while (i.hasNext()) {
Map.Entry<String, String> entry = i.next();
String key = entry.getKey();
String value = entry.getValue();
key = replaceDelimiter(key, VALUE_LIST_DELIMITER, VALUE_LIST_DELIMITER_REPLACEMENT);
key = replaceDelimiter(key, VALUE_MAP_DELIMITER, VALUE_MAP_DELIMITER_REPLACEMENT);
value = replaceDelimiter(value, VALUE_LIST_DELIMITER, VALUE_LIST_DELIMITER_REPLACEMENT);
value = replaceDelimiter(value, VALUE_MAP_DELIMITER, VALUE_MAP_DELIMITER_REPLACEMENT);
result.append(key);
result.append(VALUE_MAP_DELIMITER);
result.append(value);
if (i.hasNext()) {
result.append(VALUE_LIST_DELIMITER);
}
}
return result.toString();
} | [
"private",
"String",
"createValueFromMap",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"valueMap",
")",
"{",
"if",
"(",
"valueMap",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"valueMap",
".",
"size",
"(",
")",
"*",
"32",
")",
";",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
">",
"i",
"=",
"valueMap",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
"=",
"i",
".",
"next",
"(",
")",
";",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"String",
"value",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"key",
"=",
"replaceDelimiter",
"(",
"key",
",",
"VALUE_LIST_DELIMITER",
",",
"VALUE_LIST_DELIMITER_REPLACEMENT",
")",
";",
"key",
"=",
"replaceDelimiter",
"(",
"key",
",",
"VALUE_MAP_DELIMITER",
",",
"VALUE_MAP_DELIMITER_REPLACEMENT",
")",
";",
"value",
"=",
"replaceDelimiter",
"(",
"value",
",",
"VALUE_LIST_DELIMITER",
",",
"VALUE_LIST_DELIMITER_REPLACEMENT",
")",
";",
"value",
"=",
"replaceDelimiter",
"(",
"value",
",",
"VALUE_MAP_DELIMITER",
",",
"VALUE_MAP_DELIMITER_REPLACEMENT",
")",
";",
"result",
".",
"append",
"(",
"key",
")",
";",
"result",
".",
"append",
"(",
"VALUE_MAP_DELIMITER",
")",
";",
"result",
".",
"append",
"(",
"value",
")",
";",
"if",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"result",
".",
"append",
"(",
"VALUE_LIST_DELIMITER",
")",
";",
"}",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Returns the single String value representation for the given value map.<p>
@param valueMap the value map to create the single String value for
@return the single String value representation for the given value map | [
"Returns",
"the",
"single",
"String",
"value",
"representation",
"for",
"the",
"given",
"value",
"map",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/CmsProperty.java#L1304-L1327 |
rhuss/jolokia | agent/jmx/src/main/java/org/jolokia/jmx/JolokiaMBeanServer.java | JolokiaMBeanServer.fromJson | Object fromJson(OpenType type, String json) {
"""
Convert from JSON for OpenType objects. Throws an {@link IllegalArgumentException} if
@param type open type
@param json JSON representation to convert from
@return the converted object
"""
return converters.getToOpenTypeConverter().convertToObject(type,json);
} | java | Object fromJson(OpenType type, String json) {
return converters.getToOpenTypeConverter().convertToObject(type,json);
} | [
"Object",
"fromJson",
"(",
"OpenType",
"type",
",",
"String",
"json",
")",
"{",
"return",
"converters",
".",
"getToOpenTypeConverter",
"(",
")",
".",
"convertToObject",
"(",
"type",
",",
"json",
")",
";",
"}"
] | Convert from JSON for OpenType objects. Throws an {@link IllegalArgumentException} if
@param type open type
@param json JSON representation to convert from
@return the converted object | [
"Convert",
"from",
"JSON",
"for",
"OpenType",
"objects",
".",
"Throws",
"an",
"{",
"@link",
"IllegalArgumentException",
"}",
"if"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/jmx/src/main/java/org/jolokia/jmx/JolokiaMBeanServer.java#L178-L180 |
osglworks/java-mvc | src/main/java/org/osgl/mvc/result/Gone.java | Gone.of | public static Gone of(Throwable cause) {
"""
Returns a static Gone instance and set the {@link #payload} thread local
with cause specified.
When calling the instance on {@link #getMessage()} method, it will return whatever
stored in the {@link #payload} thread local
@param cause the cause
@return a static Gone instance as described above
"""
if (_localizedErrorMsg()) {
return of(cause, defaultMessage(GONE));
} else {
touchPayload().cause(cause);
return _INSTANCE;
}
} | java | public static Gone of(Throwable cause) {
if (_localizedErrorMsg()) {
return of(cause, defaultMessage(GONE));
} else {
touchPayload().cause(cause);
return _INSTANCE;
}
} | [
"public",
"static",
"Gone",
"of",
"(",
"Throwable",
"cause",
")",
"{",
"if",
"(",
"_localizedErrorMsg",
"(",
")",
")",
"{",
"return",
"of",
"(",
"cause",
",",
"defaultMessage",
"(",
"GONE",
")",
")",
";",
"}",
"else",
"{",
"touchPayload",
"(",
")",
".",
"cause",
"(",
"cause",
")",
";",
"return",
"_INSTANCE",
";",
"}",
"}"
] | Returns a static Gone instance and set the {@link #payload} thread local
with cause specified.
When calling the instance on {@link #getMessage()} method, it will return whatever
stored in the {@link #payload} thread local
@param cause the cause
@return a static Gone instance as described above | [
"Returns",
"a",
"static",
"Gone",
"instance",
"and",
"set",
"the",
"{",
"@link",
"#payload",
"}",
"thread",
"local",
"with",
"cause",
"specified",
"."
] | train | https://github.com/osglworks/java-mvc/blob/4d2b2ec40498ac6ee7040c0424377cbeacab124b/src/main/java/org/osgl/mvc/result/Gone.java#L130-L137 |
hawkular/hawkular-apm | api/src/main/java/org/hawkular/apm/api/utils/NodeUtil.java | NodeUtil.rewriteURI | @Deprecated
public static void rewriteURI(Node node, String uri) {
"""
This method rewrites the URI associated with the supplied
node and stores the original in the node's details.
@param node The node
@param uri The new URI
@deprecated Only used in original JavaAgent. Not to be used with OpenTracing.
"""
node.getProperties().add(new Property(APM_ORIGINAL_URI, node.getUri()));
node.setUri(uri);
} | java | @Deprecated
public static void rewriteURI(Node node, String uri) {
node.getProperties().add(new Property(APM_ORIGINAL_URI, node.getUri()));
node.setUri(uri);
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"rewriteURI",
"(",
"Node",
"node",
",",
"String",
"uri",
")",
"{",
"node",
".",
"getProperties",
"(",
")",
".",
"add",
"(",
"new",
"Property",
"(",
"APM_ORIGINAL_URI",
",",
"node",
".",
"getUri",
"(",
")",
")",
")",
";",
"node",
".",
"setUri",
"(",
"uri",
")",
";",
"}"
] | This method rewrites the URI associated with the supplied
node and stores the original in the node's details.
@param node The node
@param uri The new URI
@deprecated Only used in original JavaAgent. Not to be used with OpenTracing. | [
"This",
"method",
"rewrites",
"the",
"URI",
"associated",
"with",
"the",
"supplied",
"node",
"and",
"stores",
"the",
"original",
"in",
"the",
"node",
"s",
"details",
"."
] | train | https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/api/src/main/java/org/hawkular/apm/api/utils/NodeUtil.java#L65-L69 |
virgo47/javasimon | jdbc41/src/main/java/org/javasimon/jdbcx4/WrappingSimonDataSource.java | WrappingSimonDataSource.getConnection | @Override
public Connection getConnection(String user, String password) throws SQLException {
"""
Attempts to establish a connection with the data source that this {@code DataSource} object represents.
@param user the database user on whose behalf the connection is being made
@param password the user's password
@return a connection to the data source
@throws SQLException if a database access error occurs
"""
return new SimonConnection(getDataSource().getConnection(user, password), getPrefix());
} | java | @Override
public Connection getConnection(String user, String password) throws SQLException {
return new SimonConnection(getDataSource().getConnection(user, password), getPrefix());
} | [
"@",
"Override",
"public",
"Connection",
"getConnection",
"(",
"String",
"user",
",",
"String",
"password",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"SimonConnection",
"(",
"getDataSource",
"(",
")",
".",
"getConnection",
"(",
"user",
",",
"password",
")",
",",
"getPrefix",
"(",
")",
")",
";",
"}"
] | Attempts to establish a connection with the data source that this {@code DataSource} object represents.
@param user the database user on whose behalf the connection is being made
@param password the user's password
@return a connection to the data source
@throws SQLException if a database access error occurs | [
"Attempts",
"to",
"establish",
"a",
"connection",
"with",
"the",
"data",
"source",
"that",
"this",
"{",
"@code",
"DataSource",
"}",
"object",
"represents",
"."
] | train | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/jdbc41/src/main/java/org/javasimon/jdbcx4/WrappingSimonDataSource.java#L66-L69 |
google/closure-compiler | src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java | SourceMapGeneratorV3.addExtension | public void addExtension(String name, Object object)
throws SourceMapParseException {
"""
Adds field extensions to the json source map. The value is allowed to be
any value accepted by json, eg. string, JsonObject, JsonArray, etc.
Extensions must follow the format x_orgranization_field (based on V3
proposal), otherwise a {@code SourceMapParseExtension} will be thrown.
@param name The name of the extension with format organization_field
@param object The value of the extension as a valid json value
@throws SourceMapParseException if extension name is malformed
"""
if (!name.startsWith("x_")){
throw new SourceMapParseException("Extension '" + name +
"' must start with 'x_'");
}
this.extensions.put(name, object);
} | java | public void addExtension(String name, Object object)
throws SourceMapParseException{
if (!name.startsWith("x_")){
throw new SourceMapParseException("Extension '" + name +
"' must start with 'x_'");
}
this.extensions.put(name, object);
} | [
"public",
"void",
"addExtension",
"(",
"String",
"name",
",",
"Object",
"object",
")",
"throws",
"SourceMapParseException",
"{",
"if",
"(",
"!",
"name",
".",
"startsWith",
"(",
"\"x_\"",
")",
")",
"{",
"throw",
"new",
"SourceMapParseException",
"(",
"\"Extension '\"",
"+",
"name",
"+",
"\"' must start with 'x_'\"",
")",
";",
"}",
"this",
".",
"extensions",
".",
"put",
"(",
"name",
",",
"object",
")",
";",
"}"
] | Adds field extensions to the json source map. The value is allowed to be
any value accepted by json, eg. string, JsonObject, JsonArray, etc.
Extensions must follow the format x_orgranization_field (based on V3
proposal), otherwise a {@code SourceMapParseExtension} will be thrown.
@param name The name of the extension with format organization_field
@param object The value of the extension as a valid json value
@throws SourceMapParseException if extension name is malformed | [
"Adds",
"field",
"extensions",
"to",
"the",
"json",
"source",
"map",
".",
"The",
"value",
"is",
"allowed",
"to",
"be",
"any",
"value",
"accepted",
"by",
"json",
"eg",
".",
"string",
"JsonObject",
"JsonArray",
"etc",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java#L448-L455 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java | DatabasesInner.importMethod | public ImportExportResponseInner importMethod(String resourceGroupName, String serverName, ImportRequest parameters) {
"""
Imports a bacpac into a new database.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The required parameters for importing a Bacpac into a database.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ImportExportResponseInner object if successful.
"""
return importMethodWithServiceResponseAsync(resourceGroupName, serverName, parameters).toBlocking().last().body();
} | java | public ImportExportResponseInner importMethod(String resourceGroupName, String serverName, ImportRequest parameters) {
return importMethodWithServiceResponseAsync(resourceGroupName, serverName, parameters).toBlocking().last().body();
} | [
"public",
"ImportExportResponseInner",
"importMethod",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"ImportRequest",
"parameters",
")",
"{",
"return",
"importMethodWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Imports a bacpac into a new database.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The required parameters for importing a Bacpac into a database.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ImportExportResponseInner object if successful. | [
"Imports",
"a",
"bacpac",
"into",
"a",
"new",
"database",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java#L1737-L1739 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/XlsLoader.java | XlsLoader.loadDetail | public <P> SheetBindingErrors<P> loadDetail(final InputStream xlsIn, final Class<P> clazz)
throws XlsMapperException, IOException {
"""
Excelファイルの1シートを読み込み、任意のクラスにマッピングする。
@param <P> シートをマッピングするクラスタイプ
@param xlsIn 読み込み元のExcelファイルのストリーム。
@param clazz マッピング先のクラスタイプ。
@return マッピングの詳細情報。
{@link Configuration#isIgnoreSheetNotFound()}の値がtrueで、シートが見つからない場合、nullを返します。
@throws IllegalArgumentException {@literal xlsIn == null or clazz == null}
@throws XlsMapperException Excelファイルのマッピングに失敗した場合
@throws IOException ファイルの読み込みに失敗した場合
"""
ArgUtils.notNull(xlsIn, "xlsIn");
ArgUtils.notNull(clazz, "clazz");
final AnnotationReader annoReader = new AnnotationReader(configuration.getAnnotationMapping().orElse(null));
final XlsSheet sheetAnno = annoReader.getAnnotation(clazz, XlsSheet.class);
if(sheetAnno == null) {
throw new AnnotationInvalidException(sheetAnno, MessageBuilder.create("anno.notFound")
.varWithClass("property", clazz)
.varWithAnno("anno", XlsSheet.class)
.format());
}
final Workbook book;
try {
book = WorkbookFactory.create(xlsIn);
} catch (InvalidFormatException e) {
throw new XlsMapperException(MessageBuilder.create("file.failLoadExcel.notSupportType").format(), e);
}
try {
final Sheet[] xlsSheet = configuration.getSheetFinder().findForLoading(book, sheetAnno, annoReader, clazz);
return loadSheet(xlsSheet[0], clazz, annoReader);
} catch(SheetNotFoundException e) {
if(configuration.isIgnoreSheetNotFound()){
logger.warn(MessageBuilder.create("log.skipNotFoundSheet").format(), e);
return null;
} else {
throw e;
}
}
} | java | public <P> SheetBindingErrors<P> loadDetail(final InputStream xlsIn, final Class<P> clazz)
throws XlsMapperException, IOException {
ArgUtils.notNull(xlsIn, "xlsIn");
ArgUtils.notNull(clazz, "clazz");
final AnnotationReader annoReader = new AnnotationReader(configuration.getAnnotationMapping().orElse(null));
final XlsSheet sheetAnno = annoReader.getAnnotation(clazz, XlsSheet.class);
if(sheetAnno == null) {
throw new AnnotationInvalidException(sheetAnno, MessageBuilder.create("anno.notFound")
.varWithClass("property", clazz)
.varWithAnno("anno", XlsSheet.class)
.format());
}
final Workbook book;
try {
book = WorkbookFactory.create(xlsIn);
} catch (InvalidFormatException e) {
throw new XlsMapperException(MessageBuilder.create("file.failLoadExcel.notSupportType").format(), e);
}
try {
final Sheet[] xlsSheet = configuration.getSheetFinder().findForLoading(book, sheetAnno, annoReader, clazz);
return loadSheet(xlsSheet[0], clazz, annoReader);
} catch(SheetNotFoundException e) {
if(configuration.isIgnoreSheetNotFound()){
logger.warn(MessageBuilder.create("log.skipNotFoundSheet").format(), e);
return null;
} else {
throw e;
}
}
} | [
"public",
"<",
"P",
">",
"SheetBindingErrors",
"<",
"P",
">",
"loadDetail",
"(",
"final",
"InputStream",
"xlsIn",
",",
"final",
"Class",
"<",
"P",
">",
"clazz",
")",
"throws",
"XlsMapperException",
",",
"IOException",
"{",
"ArgUtils",
".",
"notNull",
"(",
"xlsIn",
",",
"\"xlsIn\"",
")",
";",
"ArgUtils",
".",
"notNull",
"(",
"clazz",
",",
"\"clazz\"",
")",
";",
"final",
"AnnotationReader",
"annoReader",
"=",
"new",
"AnnotationReader",
"(",
"configuration",
".",
"getAnnotationMapping",
"(",
")",
".",
"orElse",
"(",
"null",
")",
")",
";",
"final",
"XlsSheet",
"sheetAnno",
"=",
"annoReader",
".",
"getAnnotation",
"(",
"clazz",
",",
"XlsSheet",
".",
"class",
")",
";",
"if",
"(",
"sheetAnno",
"==",
"null",
")",
"{",
"throw",
"new",
"AnnotationInvalidException",
"(",
"sheetAnno",
",",
"MessageBuilder",
".",
"create",
"(",
"\"anno.notFound\"",
")",
".",
"varWithClass",
"(",
"\"property\"",
",",
"clazz",
")",
".",
"varWithAnno",
"(",
"\"anno\"",
",",
"XlsSheet",
".",
"class",
")",
".",
"format",
"(",
")",
")",
";",
"}",
"final",
"Workbook",
"book",
";",
"try",
"{",
"book",
"=",
"WorkbookFactory",
".",
"create",
"(",
"xlsIn",
")",
";",
"}",
"catch",
"(",
"InvalidFormatException",
"e",
")",
"{",
"throw",
"new",
"XlsMapperException",
"(",
"MessageBuilder",
".",
"create",
"(",
"\"file.failLoadExcel.notSupportType\"",
")",
".",
"format",
"(",
")",
",",
"e",
")",
";",
"}",
"try",
"{",
"final",
"Sheet",
"[",
"]",
"xlsSheet",
"=",
"configuration",
".",
"getSheetFinder",
"(",
")",
".",
"findForLoading",
"(",
"book",
",",
"sheetAnno",
",",
"annoReader",
",",
"clazz",
")",
";",
"return",
"loadSheet",
"(",
"xlsSheet",
"[",
"0",
"]",
",",
"clazz",
",",
"annoReader",
")",
";",
"}",
"catch",
"(",
"SheetNotFoundException",
"e",
")",
"{",
"if",
"(",
"configuration",
".",
"isIgnoreSheetNotFound",
"(",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"MessageBuilder",
".",
"create",
"(",
"\"log.skipNotFoundSheet\"",
")",
".",
"format",
"(",
")",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"else",
"{",
"throw",
"e",
";",
"}",
"}",
"}"
] | Excelファイルの1シートを読み込み、任意のクラスにマッピングする。
@param <P> シートをマッピングするクラスタイプ
@param xlsIn 読み込み元のExcelファイルのストリーム。
@param clazz マッピング先のクラスタイプ。
@return マッピングの詳細情報。
{@link Configuration#isIgnoreSheetNotFound()}の値がtrueで、シートが見つからない場合、nullを返します。
@throws IllegalArgumentException {@literal xlsIn == null or clazz == null}
@throws XlsMapperException Excelファイルのマッピングに失敗した場合
@throws IOException ファイルの読み込みに失敗した場合 | [
"Excelファイルの1シートを読み込み、任意のクラスにマッピングする。"
] | train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/XlsLoader.java#L102-L139 |
mygreen/excel-cellformatter | src/main/java/com/github/mygreen/cellformatter/lang/MessageResolver.java | MessageResolver.loadDefaultResource | private MessageResource loadDefaultResource(final boolean allowedNoDefault, final boolean appendUserResource) {
"""
プロパティファイルから取得する。
<p>プロパティ名を補完する。
@param path プロパティファイルのパス名
@param allowedNoDefault デフォルトのメッセージがない場合を許可するかどうか。
@param appendUserResource クラスパスのルートにあるユーザ定義のメッセージソースも読み込むかどうか指定します。
@return
"""
final String path = getPropertyPath();
Properties props = new Properties();
try {
props.load(new InputStreamReader(MessageResolver.class.getResourceAsStream(path), "UTF-8"));
} catch (NullPointerException | IOException e) {
if(allowedNoDefault) {
return MessageResource.NULL_OBJECT;
} else {
throw new RuntimeException("fail default properties. :" + path, e);
}
}
final MessageResource resource = new MessageResource();
final Enumeration<?> keys = props.propertyNames();
while(keys.hasMoreElements()) {
String key = (String) keys.nextElement();
String value = props.getProperty(key);
resource.addMessage(key, value);
}
// ユーザのリソースの読み込み
if(appendUserResource) {
resource.addMessage(loadUserResource(path));
}
return resource;
} | java | private MessageResource loadDefaultResource(final boolean allowedNoDefault, final boolean appendUserResource) {
final String path = getPropertyPath();
Properties props = new Properties();
try {
props.load(new InputStreamReader(MessageResolver.class.getResourceAsStream(path), "UTF-8"));
} catch (NullPointerException | IOException e) {
if(allowedNoDefault) {
return MessageResource.NULL_OBJECT;
} else {
throw new RuntimeException("fail default properties. :" + path, e);
}
}
final MessageResource resource = new MessageResource();
final Enumeration<?> keys = props.propertyNames();
while(keys.hasMoreElements()) {
String key = (String) keys.nextElement();
String value = props.getProperty(key);
resource.addMessage(key, value);
}
// ユーザのリソースの読み込み
if(appendUserResource) {
resource.addMessage(loadUserResource(path));
}
return resource;
} | [
"private",
"MessageResource",
"loadDefaultResource",
"(",
"final",
"boolean",
"allowedNoDefault",
",",
"final",
"boolean",
"appendUserResource",
")",
"{",
"final",
"String",
"path",
"=",
"getPropertyPath",
"(",
")",
";",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"try",
"{",
"props",
".",
"load",
"(",
"new",
"InputStreamReader",
"(",
"MessageResolver",
".",
"class",
".",
"getResourceAsStream",
"(",
"path",
")",
",",
"\"UTF-8\"",
")",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"|",
"IOException",
"e",
")",
"{",
"if",
"(",
"allowedNoDefault",
")",
"{",
"return",
"MessageResource",
".",
"NULL_OBJECT",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"fail default properties. :\"",
"+",
"path",
",",
"e",
")",
";",
"}",
"}",
"final",
"MessageResource",
"resource",
"=",
"new",
"MessageResource",
"(",
")",
";",
"final",
"Enumeration",
"<",
"?",
">",
"keys",
"=",
"props",
".",
"propertyNames",
"(",
")",
";",
"while",
"(",
"keys",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"String",
"key",
"=",
"(",
"String",
")",
"keys",
".",
"nextElement",
"(",
")",
";",
"String",
"value",
"=",
"props",
".",
"getProperty",
"(",
"key",
")",
";",
"resource",
".",
"addMessage",
"(",
"key",
",",
"value",
")",
";",
"}",
"// ユーザのリソースの読み込み\r",
"if",
"(",
"appendUserResource",
")",
"{",
"resource",
".",
"addMessage",
"(",
"loadUserResource",
"(",
"path",
")",
")",
";",
"}",
"return",
"resource",
";",
"}"
] | プロパティファイルから取得する。
<p>プロパティ名を補完する。
@param path プロパティファイルのパス名
@param allowedNoDefault デフォルトのメッセージがない場合を許可するかどうか。
@param appendUserResource クラスパスのルートにあるユーザ定義のメッセージソースも読み込むかどうか指定します。
@return | [
"プロパティファイルから取得する。",
"<p",
">",
"プロパティ名を補完する。"
] | train | https://github.com/mygreen/excel-cellformatter/blob/e802af273d49889500591e03799c9262cbf29185/src/main/java/com/github/mygreen/cellformatter/lang/MessageResolver.java#L128-L158 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/Getter.java | Getter.getView | public View getView(int id, int index, int timeout) {
"""
Returns a {@code View} with a given id.
@param id the R.id of the {@code View} to be returned
@param index the index of the {@link View}. {@code 0} if only one is available
@param timeout the timeout in milliseconds
@return a {@code View} with a given id
"""
return waiter.waitForView(id, index, timeout);
} | java | public View getView(int id, int index, int timeout){
return waiter.waitForView(id, index, timeout);
} | [
"public",
"View",
"getView",
"(",
"int",
"id",
",",
"int",
"index",
",",
"int",
"timeout",
")",
"{",
"return",
"waiter",
".",
"waitForView",
"(",
"id",
",",
"index",
",",
"timeout",
")",
";",
"}"
] | Returns a {@code View} with a given id.
@param id the R.id of the {@code View} to be returned
@param index the index of the {@link View}. {@code 0} if only one is available
@param timeout the timeout in milliseconds
@return a {@code View} with a given id | [
"Returns",
"a",
"{",
"@code",
"View",
"}",
"with",
"a",
"given",
"id",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Getter.java#L116-L118 |
ksclarke/vertx-pairtree | src/main/java/info/freelibrary/pairtree/PairtreeUtils.java | PairtreeUtils.removePrefix | public static String removePrefix(final String aPrefix, final String aID) {
"""
Removes the supplied Pairtree prefix from the supplied ID.
@param aPrefix A Pairtree prefix
@param aID An ID
@return The ID without the Pairtree prefix prepended to it
@throws PairtreeRuntimeException If the supplied prefix or ID is null
"""
Objects.requireNonNull(aPrefix, LOGGER.getMessage(MessageCodes.PT_006));
Objects.requireNonNull(aID, LOGGER.getMessage(MessageCodes.PT_004));
final String id;
if (aID.indexOf(aPrefix) == 0) {
id = aID.substring(aPrefix.length());
} else {
id = aID;
}
return id;
} | java | public static String removePrefix(final String aPrefix, final String aID) {
Objects.requireNonNull(aPrefix, LOGGER.getMessage(MessageCodes.PT_006));
Objects.requireNonNull(aID, LOGGER.getMessage(MessageCodes.PT_004));
final String id;
if (aID.indexOf(aPrefix) == 0) {
id = aID.substring(aPrefix.length());
} else {
id = aID;
}
return id;
} | [
"public",
"static",
"String",
"removePrefix",
"(",
"final",
"String",
"aPrefix",
",",
"final",
"String",
"aID",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"aPrefix",
",",
"LOGGER",
".",
"getMessage",
"(",
"MessageCodes",
".",
"PT_006",
")",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"aID",
",",
"LOGGER",
".",
"getMessage",
"(",
"MessageCodes",
".",
"PT_004",
")",
")",
";",
"final",
"String",
"id",
";",
"if",
"(",
"aID",
".",
"indexOf",
"(",
"aPrefix",
")",
"==",
"0",
")",
"{",
"id",
"=",
"aID",
".",
"substring",
"(",
"aPrefix",
".",
"length",
"(",
")",
")",
";",
"}",
"else",
"{",
"id",
"=",
"aID",
";",
"}",
"return",
"id",
";",
"}"
] | Removes the supplied Pairtree prefix from the supplied ID.
@param aPrefix A Pairtree prefix
@param aID An ID
@return The ID without the Pairtree prefix prepended to it
@throws PairtreeRuntimeException If the supplied prefix or ID is null | [
"Removes",
"the",
"supplied",
"Pairtree",
"prefix",
"from",
"the",
"supplied",
"ID",
"."
] | train | https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/PairtreeUtils.java#L343-L356 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/searchindex/CmsEditFieldDialog.java | CmsEditFieldDialog.getTokenizedWidgetConfiguration | private List<CmsSelectWidgetOption> getTokenizedWidgetConfiguration() {
"""
Returns a list for the indexed select box.<p>
@return a list for the indexed select box
"""
List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>();
result.add(new CmsSelectWidgetOption("true", true));
result.add(new CmsSelectWidgetOption("false", false));
result.add(new CmsSelectWidgetOption("untokenized", false));
return result;
} | java | private List<CmsSelectWidgetOption> getTokenizedWidgetConfiguration() {
List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>();
result.add(new CmsSelectWidgetOption("true", true));
result.add(new CmsSelectWidgetOption("false", false));
result.add(new CmsSelectWidgetOption("untokenized", false));
return result;
} | [
"private",
"List",
"<",
"CmsSelectWidgetOption",
">",
"getTokenizedWidgetConfiguration",
"(",
")",
"{",
"List",
"<",
"CmsSelectWidgetOption",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"CmsSelectWidgetOption",
">",
"(",
")",
";",
"result",
".",
"add",
"(",
"new",
"CmsSelectWidgetOption",
"(",
"\"true\"",
",",
"true",
")",
")",
";",
"result",
".",
"add",
"(",
"new",
"CmsSelectWidgetOption",
"(",
"\"false\"",
",",
"false",
")",
")",
";",
"result",
".",
"add",
"(",
"new",
"CmsSelectWidgetOption",
"(",
"\"untokenized\"",
",",
"false",
")",
")",
";",
"return",
"result",
";",
"}"
] | Returns a list for the indexed select box.<p>
@return a list for the indexed select box | [
"Returns",
"a",
"list",
"for",
"the",
"indexed",
"select",
"box",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/searchindex/CmsEditFieldDialog.java#L180-L187 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java | ComputerVisionImpl.analyzeImageByDomainInStream | public DomainModelResults analyzeImageByDomainInStream(String model, byte[] image, AnalyzeImageByDomainInStreamOptionalParameter analyzeImageByDomainInStreamOptionalParameter) {
"""
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
@param model The domain-specific content to recognize.
@param image An image stream.
@param analyzeImageByDomainInStreamOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ComputerVisionErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DomainModelResults object if successful.
"""
return analyzeImageByDomainInStreamWithServiceResponseAsync(model, image, analyzeImageByDomainInStreamOptionalParameter).toBlocking().single().body();
} | java | public DomainModelResults analyzeImageByDomainInStream(String model, byte[] image, AnalyzeImageByDomainInStreamOptionalParameter analyzeImageByDomainInStreamOptionalParameter) {
return analyzeImageByDomainInStreamWithServiceResponseAsync(model, image, analyzeImageByDomainInStreamOptionalParameter).toBlocking().single().body();
} | [
"public",
"DomainModelResults",
"analyzeImageByDomainInStream",
"(",
"String",
"model",
",",
"byte",
"[",
"]",
"image",
",",
"AnalyzeImageByDomainInStreamOptionalParameter",
"analyzeImageByDomainInStreamOptionalParameter",
")",
"{",
"return",
"analyzeImageByDomainInStreamWithServiceResponseAsync",
"(",
"model",
",",
"image",
",",
"analyzeImageByDomainInStreamOptionalParameter",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities. Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
@param model The domain-specific content to recognize.
@param image An image stream.
@param analyzeImageByDomainInStreamOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ComputerVisionErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DomainModelResults object if successful. | [
"This",
"operation",
"recognizes",
"content",
"within",
"an",
"image",
"by",
"applying",
"a",
"domain",
"-",
"specific",
"model",
".",
"The",
"list",
"of",
"domain",
"-",
"specific",
"models",
"that",
"are",
"supported",
"by",
"the",
"Computer",
"Vision",
"API",
"can",
"be",
"retrieved",
"using",
"the",
"/",
"models",
"GET",
"request",
".",
"Currently",
"the",
"API",
"only",
"provides",
"a",
"single",
"domain",
"-",
"specific",
"model",
":",
"celebrities",
".",
"Two",
"input",
"methods",
"are",
"supported",
"--",
"(",
"1",
")",
"Uploading",
"an",
"image",
"or",
"(",
"2",
")",
"specifying",
"an",
"image",
"URL",
".",
"A",
"successful",
"response",
"will",
"be",
"returned",
"in",
"JSON",
".",
"If",
"the",
"request",
"failed",
"the",
"response",
"will",
"contain",
"an",
"error",
"code",
"and",
"a",
"message",
"to",
"help",
"understand",
"what",
"went",
"wrong",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java#L257-L259 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java | IOGroovyMethods.withPrintWriter | public static <T> T withPrintWriter(OutputStream stream, @ClosureParams(value=SimpleType.class, options="java.io.PrintWriter") Closure<T> closure) throws IOException {
"""
Create a new PrintWriter for this OutputStream. The writer is passed to the
closure, and will be closed before this method returns.
@param stream an OutputStream
@param closure the closure to invoke with the PrintWriter
@return the value returned by the closure
@throws IOException if an IOException occurs.
@since 2.2.0
"""
return withWriter(newPrintWriter(stream), closure);
} | java | public static <T> T withPrintWriter(OutputStream stream, @ClosureParams(value=SimpleType.class, options="java.io.PrintWriter") Closure<T> closure) throws IOException {
return withWriter(newPrintWriter(stream), closure);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"withPrintWriter",
"(",
"OutputStream",
"stream",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"SimpleType",
".",
"class",
",",
"options",
"=",
"\"java.io.PrintWriter\"",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
"{",
"return",
"withWriter",
"(",
"newPrintWriter",
"(",
"stream",
")",
",",
"closure",
")",
";",
"}"
] | Create a new PrintWriter for this OutputStream. The writer is passed to the
closure, and will be closed before this method returns.
@param stream an OutputStream
@param closure the closure to invoke with the PrintWriter
@return the value returned by the closure
@throws IOException if an IOException occurs.
@since 2.2.0 | [
"Create",
"a",
"new",
"PrintWriter",
"for",
"this",
"OutputStream",
".",
"The",
"writer",
"is",
"passed",
"to",
"the",
"closure",
"and",
"will",
"be",
"closed",
"before",
"this",
"method",
"returns",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java#L1117-L1119 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/dbinfo/DatabaseInformationMain.java | DatabaseInformationMain.allTables | protected final Iterator allTables() {
"""
Retrieves an enumeration over all of the tables in this database.
This means all user tables, views, system tables, system views,
including temporary and text tables. <p>
@return an enumeration over all of the tables in this database
"""
return new WrapperIterator(
database.schemaManager.databaseObjectIterator(SchemaObject.TABLE),
new WrapperIterator(sysTables, true));
} | java | protected final Iterator allTables() {
return new WrapperIterator(
database.schemaManager.databaseObjectIterator(SchemaObject.TABLE),
new WrapperIterator(sysTables, true));
} | [
"protected",
"final",
"Iterator",
"allTables",
"(",
")",
"{",
"return",
"new",
"WrapperIterator",
"(",
"database",
".",
"schemaManager",
".",
"databaseObjectIterator",
"(",
"SchemaObject",
".",
"TABLE",
")",
",",
"new",
"WrapperIterator",
"(",
"sysTables",
",",
"true",
")",
")",
";",
"}"
] | Retrieves an enumeration over all of the tables in this database.
This means all user tables, views, system tables, system views,
including temporary and text tables. <p>
@return an enumeration over all of the tables in this database | [
"Retrieves",
"an",
"enumeration",
"over",
"all",
"of",
"the",
"tables",
"in",
"this",
"database",
".",
"This",
"means",
"all",
"user",
"tables",
"views",
"system",
"tables",
"system",
"views",
"including",
"temporary",
"and",
"text",
"tables",
".",
"<p",
">"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/dbinfo/DatabaseInformationMain.java#L268-L273 |
NextFaze/power-adapters | power-adapters/src/main/java/com/nextfaze/poweradapters/PowerAdapter.java | PowerAdapter.compose | @CheckResult
@NonNull
public final PowerAdapter compose(@NonNull Transformer transformer) {
"""
Applies the specified {@link Transformer} to this adapter, and returns the result.
"""
return checkNotNull(transformer, "transformer").transform(this);
} | java | @CheckResult
@NonNull
public final PowerAdapter compose(@NonNull Transformer transformer) {
return checkNotNull(transformer, "transformer").transform(this);
} | [
"@",
"CheckResult",
"@",
"NonNull",
"public",
"final",
"PowerAdapter",
"compose",
"(",
"@",
"NonNull",
"Transformer",
"transformer",
")",
"{",
"return",
"checkNotNull",
"(",
"transformer",
",",
"\"transformer\"",
")",
".",
"transform",
"(",
"this",
")",
";",
"}"
] | Applies the specified {@link Transformer} to this adapter, and returns the result. | [
"Applies",
"the",
"specified",
"{"
] | train | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters/src/main/java/com/nextfaze/poweradapters/PowerAdapter.java#L369-L373 |
krummas/DrizzleJDBC | src/main/java/org/drizzle/jdbc/DrizzleBlob.java | DrizzleBlob.getBinaryStream | public InputStream getBinaryStream(final long pos, final long length) throws SQLException {
"""
Returns an <code>InputStream</code> object that contains a partial <code>Blob</code> value, starting with the
byte specified by pos, which is length bytes in length.
@param pos the offset to the first byte of the partial value to be retrieved. The first byte in the
<code>Blob</code> is at position 1
@param length the length in bytes of the partial value to be retrieved
@return <code>InputStream</code> through which the partial <code>Blob</code> value can be read.
@throws java.sql.SQLException if pos is less than 1 or if pos is greater than the number of bytes in the
<code>Blob</code> or if pos + length is greater than the number of bytes in the
<code>Blob</code>
"""
if (pos < 1 || pos > actualSize || pos + length > actualSize) {
throw SQLExceptionMapper.getSQLException("Out of range");
}
return new ByteArrayInputStream(Utils.copyRange(blobContent,
(int) pos,
(int) length));
} | java | public InputStream getBinaryStream(final long pos, final long length) throws SQLException {
if (pos < 1 || pos > actualSize || pos + length > actualSize) {
throw SQLExceptionMapper.getSQLException("Out of range");
}
return new ByteArrayInputStream(Utils.copyRange(blobContent,
(int) pos,
(int) length));
} | [
"public",
"InputStream",
"getBinaryStream",
"(",
"final",
"long",
"pos",
",",
"final",
"long",
"length",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"pos",
"<",
"1",
"||",
"pos",
">",
"actualSize",
"||",
"pos",
"+",
"length",
">",
"actualSize",
")",
"{",
"throw",
"SQLExceptionMapper",
".",
"getSQLException",
"(",
"\"Out of range\"",
")",
";",
"}",
"return",
"new",
"ByteArrayInputStream",
"(",
"Utils",
".",
"copyRange",
"(",
"blobContent",
",",
"(",
"int",
")",
"pos",
",",
"(",
"int",
")",
"length",
")",
")",
";",
"}"
] | Returns an <code>InputStream</code> object that contains a partial <code>Blob</code> value, starting with the
byte specified by pos, which is length bytes in length.
@param pos the offset to the first byte of the partial value to be retrieved. The first byte in the
<code>Blob</code> is at position 1
@param length the length in bytes of the partial value to be retrieved
@return <code>InputStream</code> through which the partial <code>Blob</code> value can be read.
@throws java.sql.SQLException if pos is less than 1 or if pos is greater than the number of bytes in the
<code>Blob</code> or if pos + length is greater than the number of bytes in the
<code>Blob</code> | [
"Returns",
"an",
"<code",
">",
"InputStream<",
"/",
"code",
">",
"object",
"that",
"contains",
"a",
"partial",
"<code",
">",
"Blob<",
"/",
"code",
">",
"value",
"starting",
"with",
"the",
"byte",
"specified",
"by",
"pos",
"which",
"is",
"length",
"bytes",
"in",
"length",
"."
] | train | https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleBlob.java#L341-L349 |
craftercms/commons | utilities/src/main/java/org/craftercms/commons/zip/ZipUtils.java | ZipUtils.zipFiles | public static void zipFiles(List<File> files, OutputStream outputStream) throws IOException {
"""
Zips a collection of files to a destination zip output stream.
@param files A collection of files and directories
@param outputStream The output stream of the destination zip file
@throws FileNotFoundException
@throws IOException
"""
ZipOutputStream zos = new ZipOutputStream(outputStream);
for (File file : files) {
if (file.isDirectory()) { //if it's a folder
addFolderToZip("", file, zos);
} else {
addFileToZip("", file, zos);
}
}
zos.finish();
} | java | public static void zipFiles(List<File> files, OutputStream outputStream) throws IOException {
ZipOutputStream zos = new ZipOutputStream(outputStream);
for (File file : files) {
if (file.isDirectory()) { //if it's a folder
addFolderToZip("", file, zos);
} else {
addFileToZip("", file, zos);
}
}
zos.finish();
} | [
"public",
"static",
"void",
"zipFiles",
"(",
"List",
"<",
"File",
">",
"files",
",",
"OutputStream",
"outputStream",
")",
"throws",
"IOException",
"{",
"ZipOutputStream",
"zos",
"=",
"new",
"ZipOutputStream",
"(",
"outputStream",
")",
";",
"for",
"(",
"File",
"file",
":",
"files",
")",
"{",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"//if it's a folder",
"addFolderToZip",
"(",
"\"\"",
",",
"file",
",",
"zos",
")",
";",
"}",
"else",
"{",
"addFileToZip",
"(",
"\"\"",
",",
"file",
",",
"zos",
")",
";",
"}",
"}",
"zos",
".",
"finish",
"(",
")",
";",
"}"
] | Zips a collection of files to a destination zip output stream.
@param files A collection of files and directories
@param outputStream The output stream of the destination zip file
@throws FileNotFoundException
@throws IOException | [
"Zips",
"a",
"collection",
"of",
"files",
"to",
"a",
"destination",
"zip",
"output",
"stream",
"."
] | train | https://github.com/craftercms/commons/blob/3074fe49e56c2a4aae0832f40b17ae563335dc83/utilities/src/main/java/org/craftercms/commons/zip/ZipUtils.java#L53-L65 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java | FSDataset.removeVolumes | public void removeVolumes(Configuration conf, List<File> directories)
throws Exception {
"""
remove directories that are given from the list of volumes to use.
This function also makes sure to remove all the blocks that belong to
these volumes.
"""
if (directories == null || directories.isEmpty()) {
DataNode.LOG.warn("There were no directories to remove. Exiting ");
return;
}
List<FSVolume> volArray = null;
lock.readLock().lock();
try {
volArray = volumes.removeBVolumes(directories);
} finally {
lock.readLock().unlock();
}
// remove related blocks
long mlsec = System.currentTimeMillis();
lock.writeLock().lock();
try {
volumeMap.removeUnhealthyVolumes(volArray);
} finally {
lock.writeLock().unlock();
}
mlsec = System.currentTimeMillis() - mlsec;
DataNode.LOG.warn(">>>>>>>>>Removing these blocks took " + mlsec +
" millisecs in refresh<<<<<<<<<<<<<<< ");
StringBuilder sb = new StringBuilder();
for(FSVolume fv : volArray) {
sb.append(fv.toString() + ";");
}
throw new DiskErrorException("These volumes were removed: " + sb);
} | java | public void removeVolumes(Configuration conf, List<File> directories)
throws Exception {
if (directories == null || directories.isEmpty()) {
DataNode.LOG.warn("There were no directories to remove. Exiting ");
return;
}
List<FSVolume> volArray = null;
lock.readLock().lock();
try {
volArray = volumes.removeBVolumes(directories);
} finally {
lock.readLock().unlock();
}
// remove related blocks
long mlsec = System.currentTimeMillis();
lock.writeLock().lock();
try {
volumeMap.removeUnhealthyVolumes(volArray);
} finally {
lock.writeLock().unlock();
}
mlsec = System.currentTimeMillis() - mlsec;
DataNode.LOG.warn(">>>>>>>>>Removing these blocks took " + mlsec +
" millisecs in refresh<<<<<<<<<<<<<<< ");
StringBuilder sb = new StringBuilder();
for(FSVolume fv : volArray) {
sb.append(fv.toString() + ";");
}
throw new DiskErrorException("These volumes were removed: " + sb);
} | [
"public",
"void",
"removeVolumes",
"(",
"Configuration",
"conf",
",",
"List",
"<",
"File",
">",
"directories",
")",
"throws",
"Exception",
"{",
"if",
"(",
"directories",
"==",
"null",
"||",
"directories",
".",
"isEmpty",
"(",
")",
")",
"{",
"DataNode",
".",
"LOG",
".",
"warn",
"(",
"\"There were no directories to remove. Exiting \"",
")",
";",
"return",
";",
"}",
"List",
"<",
"FSVolume",
">",
"volArray",
"=",
"null",
";",
"lock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"volArray",
"=",
"volumes",
".",
"removeBVolumes",
"(",
"directories",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"readLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"// remove related blocks",
"long",
"mlsec",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"lock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"volumeMap",
".",
"removeUnhealthyVolumes",
"(",
"volArray",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"mlsec",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"mlsec",
";",
"DataNode",
".",
"LOG",
".",
"warn",
"(",
"\">>>>>>>>>Removing these blocks took \"",
"+",
"mlsec",
"+",
"\" millisecs in refresh<<<<<<<<<<<<<<< \"",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"FSVolume",
"fv",
":",
"volArray",
")",
"{",
"sb",
".",
"append",
"(",
"fv",
".",
"toString",
"(",
")",
"+",
"\";\"",
")",
";",
"}",
"throw",
"new",
"DiskErrorException",
"(",
"\"These volumes were removed: \"",
"+",
"sb",
")",
";",
"}"
] | remove directories that are given from the list of volumes to use.
This function also makes sure to remove all the blocks that belong to
these volumes. | [
"remove",
"directories",
"that",
"are",
"given",
"from",
"the",
"list",
"of",
"volumes",
"to",
"use",
".",
"This",
"function",
"also",
"makes",
"sure",
"to",
"remove",
"all",
"the",
"blocks",
"that",
"belong",
"to",
"these",
"volumes",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java#L2873-L2902 |
protostuff/protostuff | protostuff-json/src/main/java/io/protostuff/JsonIOUtil.java | JsonIOUtil.mergeFrom | public static <T> void mergeFrom(JsonParser parser, T message, Schema<T> schema,
boolean numeric) throws IOException {
"""
Merges the {@code message} from the JsonParser using the given {@code schema}.
"""
if (parser.nextToken() != JsonToken.START_OBJECT)
{
throw new JsonInputException("Expected token: { but was " +
parser.getCurrentToken() + " on message " +
schema.messageFullName());
}
schema.mergeFrom(new JsonInput(parser, numeric), message);
if (parser.getCurrentToken() != JsonToken.END_OBJECT)
{
throw new JsonInputException("Expected token: } but was " +
parser.getCurrentToken() + " on message " +
schema.messageFullName());
}
} | java | public static <T> void mergeFrom(JsonParser parser, T message, Schema<T> schema,
boolean numeric) throws IOException
{
if (parser.nextToken() != JsonToken.START_OBJECT)
{
throw new JsonInputException("Expected token: { but was " +
parser.getCurrentToken() + " on message " +
schema.messageFullName());
}
schema.mergeFrom(new JsonInput(parser, numeric), message);
if (parser.getCurrentToken() != JsonToken.END_OBJECT)
{
throw new JsonInputException("Expected token: } but was " +
parser.getCurrentToken() + " on message " +
schema.messageFullName());
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"mergeFrom",
"(",
"JsonParser",
"parser",
",",
"T",
"message",
",",
"Schema",
"<",
"T",
">",
"schema",
",",
"boolean",
"numeric",
")",
"throws",
"IOException",
"{",
"if",
"(",
"parser",
".",
"nextToken",
"(",
")",
"!=",
"JsonToken",
".",
"START_OBJECT",
")",
"{",
"throw",
"new",
"JsonInputException",
"(",
"\"Expected token: { but was \"",
"+",
"parser",
".",
"getCurrentToken",
"(",
")",
"+",
"\" on message \"",
"+",
"schema",
".",
"messageFullName",
"(",
")",
")",
";",
"}",
"schema",
".",
"mergeFrom",
"(",
"new",
"JsonInput",
"(",
"parser",
",",
"numeric",
")",
",",
"message",
")",
";",
"if",
"(",
"parser",
".",
"getCurrentToken",
"(",
")",
"!=",
"JsonToken",
".",
"END_OBJECT",
")",
"{",
"throw",
"new",
"JsonInputException",
"(",
"\"Expected token: } but was \"",
"+",
"parser",
".",
"getCurrentToken",
"(",
")",
"+",
"\" on message \"",
"+",
"schema",
".",
"messageFullName",
"(",
")",
")",
";",
"}",
"}"
] | Merges the {@code message} from the JsonParser using the given {@code schema}. | [
"Merges",
"the",
"{"
] | train | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-json/src/main/java/io/protostuff/JsonIOUtil.java#L327-L345 |
lotaris/rox-commons-maven-plugin | src/main/java/com/lotaris/maven/plugin/AbstractGenericMojo.java | AbstractGenericMojo.useCleanPlugin | protected void useCleanPlugin(Element ... elements) throws MojoExecutionException {
"""
Utility method to use the clean plugin in the cleanup methods
@param elements Elements to configure the clean plugin
@throws MojoExecutionException Throws when error occurred in the clean plugin
"""
List<Element> tempElems = new ArrayList<>(Arrays.asList(elements));
tempElems.add(new Element("excludeDefaultDirectories", "true"));
// Configure the Maven Clean Plugin to clean working files
executeMojo(
plugin(
groupId("org.apache.maven.plugins"),
artifactId("maven-clean-plugin"),
version("2.5")
),
goal("clean"),
configuration(
tempElems.toArray(new Element[tempElems.size()])
),
executionEnvironment(
project,
session,
pluginManager
)
);
} | java | protected void useCleanPlugin(Element ... elements) throws MojoExecutionException {
List<Element> tempElems = new ArrayList<>(Arrays.asList(elements));
tempElems.add(new Element("excludeDefaultDirectories", "true"));
// Configure the Maven Clean Plugin to clean working files
executeMojo(
plugin(
groupId("org.apache.maven.plugins"),
artifactId("maven-clean-plugin"),
version("2.5")
),
goal("clean"),
configuration(
tempElems.toArray(new Element[tempElems.size()])
),
executionEnvironment(
project,
session,
pluginManager
)
);
} | [
"protected",
"void",
"useCleanPlugin",
"(",
"Element",
"...",
"elements",
")",
"throws",
"MojoExecutionException",
"{",
"List",
"<",
"Element",
">",
"tempElems",
"=",
"new",
"ArrayList",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"elements",
")",
")",
";",
"tempElems",
".",
"add",
"(",
"new",
"Element",
"(",
"\"excludeDefaultDirectories\"",
",",
"\"true\"",
")",
")",
";",
"// Configure the Maven Clean Plugin to clean working files",
"executeMojo",
"(",
"plugin",
"(",
"groupId",
"(",
"\"org.apache.maven.plugins\"",
")",
",",
"artifactId",
"(",
"\"maven-clean-plugin\"",
")",
",",
"version",
"(",
"\"2.5\"",
")",
")",
",",
"goal",
"(",
"\"clean\"",
")",
",",
"configuration",
"(",
"tempElems",
".",
"toArray",
"(",
"new",
"Element",
"[",
"tempElems",
".",
"size",
"(",
")",
"]",
")",
")",
",",
"executionEnvironment",
"(",
"project",
",",
"session",
",",
"pluginManager",
")",
")",
";",
"}"
] | Utility method to use the clean plugin in the cleanup methods
@param elements Elements to configure the clean plugin
@throws MojoExecutionException Throws when error occurred in the clean plugin | [
"Utility",
"method",
"to",
"use",
"the",
"clean",
"plugin",
"in",
"the",
"cleanup",
"methods"
] | train | https://github.com/lotaris/rox-commons-maven-plugin/blob/e2602d7f1e8c2e6994c0df07cc0003828adfa2af/src/main/java/com/lotaris/maven/plugin/AbstractGenericMojo.java#L122-L143 |
JavaMoney/jsr354-ri-bp | src/main/java/org/javamoney/moneta/internal/ConfigurableCurrencyUnitProvider.java | ConfigurableCurrencyUnitProvider.registerCurrencyUnit | public static CurrencyUnit registerCurrencyUnit(CurrencyUnit currencyUnit, Locale locale) {
"""
Registers a bew currency unit under the given Locale.
@param currencyUnit the new currency to be registered, not null.
@param locale the Locale, not null.
@return any unit instance registered previously by this instance, or null.
"""
Objects.requireNonNull(locale);
Objects.requireNonNull(currencyUnit);
return ConfigurableCurrencyUnitProvider.currencyUnitsByLocale.put(locale, currencyUnit);
} | java | public static CurrencyUnit registerCurrencyUnit(CurrencyUnit currencyUnit, Locale locale) {
Objects.requireNonNull(locale);
Objects.requireNonNull(currencyUnit);
return ConfigurableCurrencyUnitProvider.currencyUnitsByLocale.put(locale, currencyUnit);
} | [
"public",
"static",
"CurrencyUnit",
"registerCurrencyUnit",
"(",
"CurrencyUnit",
"currencyUnit",
",",
"Locale",
"locale",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"locale",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"currencyUnit",
")",
";",
"return",
"ConfigurableCurrencyUnitProvider",
".",
"currencyUnitsByLocale",
".",
"put",
"(",
"locale",
",",
"currencyUnit",
")",
";",
"}"
] | Registers a bew currency unit under the given Locale.
@param currencyUnit the new currency to be registered, not null.
@param locale the Locale, not null.
@return any unit instance registered previously by this instance, or null. | [
"Registers",
"a",
"bew",
"currency",
"unit",
"under",
"the",
"given",
"Locale",
"."
] | train | https://github.com/JavaMoney/jsr354-ri-bp/blob/9c147ef5623d8032a6dc4c0e5eefdfb41641a9a2/src/main/java/org/javamoney/moneta/internal/ConfigurableCurrencyUnitProvider.java#L90-L94 |
nulab/backlog4j | src/main/java/com/nulabinc/backlog4j/internal/http/MimeHelper.java | MimeHelper.decodeContentDisposition | public static String decodeContentDisposition(String value, Map<String, String> params) {
"""
Decodes the Content-Disposition header value according to RFC 2183 and
RFC 2231.
<p/>
Does not deal with continuation lines.
<p/>
See <a href="http://tools.ietf.org/html/rfc2231">RFC 2231</a> for
details.
@param value the header value to decode
@param params the map of parameters to fill
@return the disposition
"""
try {
HeaderTokenizer tokenizer = new HeaderTokenizer(value);
// get the first token, which must be an ATOM
Token token = tokenizer.next();
if (token.getType() != Token.ATOM) {
return null;
}
String disposition = token.getValue();
// value ignored in this method
// the remainder is the parameters
String remainder = tokenizer.getRemainder();
if (remainder != null) {
getParameters(remainder, params);
}
return disposition;
} catch (ParseException e) {
return null;
}
} | java | public static String decodeContentDisposition(String value, Map<String, String> params) {
try {
HeaderTokenizer tokenizer = new HeaderTokenizer(value);
// get the first token, which must be an ATOM
Token token = tokenizer.next();
if (token.getType() != Token.ATOM) {
return null;
}
String disposition = token.getValue();
// value ignored in this method
// the remainder is the parameters
String remainder = tokenizer.getRemainder();
if (remainder != null) {
getParameters(remainder, params);
}
return disposition;
} catch (ParseException e) {
return null;
}
} | [
"public",
"static",
"String",
"decodeContentDisposition",
"(",
"String",
"value",
",",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"{",
"try",
"{",
"HeaderTokenizer",
"tokenizer",
"=",
"new",
"HeaderTokenizer",
"(",
"value",
")",
";",
"// get the first token, which must be an ATOM",
"Token",
"token",
"=",
"tokenizer",
".",
"next",
"(",
")",
";",
"if",
"(",
"token",
".",
"getType",
"(",
")",
"!=",
"Token",
".",
"ATOM",
")",
"{",
"return",
"null",
";",
"}",
"String",
"disposition",
"=",
"token",
".",
"getValue",
"(",
")",
";",
"// value ignored in this method",
"// the remainder is the parameters",
"String",
"remainder",
"=",
"tokenizer",
".",
"getRemainder",
"(",
")",
";",
"if",
"(",
"remainder",
"!=",
"null",
")",
"{",
"getParameters",
"(",
"remainder",
",",
"params",
")",
";",
"}",
"return",
"disposition",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Decodes the Content-Disposition header value according to RFC 2183 and
RFC 2231.
<p/>
Does not deal with continuation lines.
<p/>
See <a href="http://tools.ietf.org/html/rfc2231">RFC 2231</a> for
details.
@param value the header value to decode
@param params the map of parameters to fill
@return the disposition | [
"Decodes",
"the",
"Content",
"-",
"Disposition",
"header",
"value",
"according",
"to",
"RFC",
"2183",
"and",
"RFC",
"2231",
".",
"<p",
"/",
">",
"Does",
"not",
"deal",
"with",
"continuation",
"lines",
".",
"<p",
"/",
">",
"See",
"<a",
"href",
"=",
"http",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc2231",
">",
"RFC",
"2231<",
"/",
"a",
">",
"for",
"details",
"."
] | train | https://github.com/nulab/backlog4j/blob/862ae0586ad808b2ec413f665b8dfc0c9a107b4e/src/main/java/com/nulabinc/backlog4j/internal/http/MimeHelper.java#L61-L81 |
jeremylong/DependencyCheck | core/src/main/java/org/owasp/dependencycheck/analyzer/PythonDistributionAnalyzer.java | PythonDistributionAnalyzer.getNextTempDirectory | private File getNextTempDirectory() throws AnalysisException {
"""
Retrieves the next temporary destination directory for extracting an
archive.
@return a directory
@throws AnalysisException thrown if unable to create temporary directory
"""
File directory;
// getting an exception for some directories not being able to be
// created; might be because the directory already exists?
do {
final int dirCount = DIR_COUNT.incrementAndGet();
directory = new File(tempFileLocation, String.valueOf(dirCount));
} while (directory.exists());
if (!directory.mkdirs()) {
throw new AnalysisException(String.format(
"Unable to create temp directory '%s'.",
directory.getAbsolutePath()));
}
return directory;
} | java | private File getNextTempDirectory() throws AnalysisException {
File directory;
// getting an exception for some directories not being able to be
// created; might be because the directory already exists?
do {
final int dirCount = DIR_COUNT.incrementAndGet();
directory = new File(tempFileLocation, String.valueOf(dirCount));
} while (directory.exists());
if (!directory.mkdirs()) {
throw new AnalysisException(String.format(
"Unable to create temp directory '%s'.",
directory.getAbsolutePath()));
}
return directory;
} | [
"private",
"File",
"getNextTempDirectory",
"(",
")",
"throws",
"AnalysisException",
"{",
"File",
"directory",
";",
"// getting an exception for some directories not being able to be",
"// created; might be because the directory already exists?",
"do",
"{",
"final",
"int",
"dirCount",
"=",
"DIR_COUNT",
".",
"incrementAndGet",
"(",
")",
";",
"directory",
"=",
"new",
"File",
"(",
"tempFileLocation",
",",
"String",
".",
"valueOf",
"(",
"dirCount",
")",
")",
";",
"}",
"while",
"(",
"directory",
".",
"exists",
"(",
")",
")",
";",
"if",
"(",
"!",
"directory",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"AnalysisException",
"(",
"String",
".",
"format",
"(",
"\"Unable to create temp directory '%s'.\"",
",",
"directory",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"return",
"directory",
";",
"}"
] | Retrieves the next temporary destination directory for extracting an
archive.
@return a directory
@throws AnalysisException thrown if unable to create temporary directory | [
"Retrieves",
"the",
"next",
"temporary",
"destination",
"directory",
"for",
"extracting",
"an",
"archive",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/PythonDistributionAnalyzer.java#L392-L407 |
Azure/azure-sdk-for-java | datamigration/resource-manager/v2017_11_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2017_11_15_preview/implementation/ServicesInner.java | ServicesInner.checkChildrenNameAvailabilityAsync | public Observable<NameAvailabilityResponseInner> checkChildrenNameAvailabilityAsync(String groupName, String serviceName, NameAvailabilityRequest parameters) {
"""
Check nested resource name validity and availability.
This method checks whether a proposed nested resource name is valid and available.
@param groupName Name of the resource group
@param serviceName Name of the service
@param parameters Requested name to validate
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NameAvailabilityResponseInner object
"""
return checkChildrenNameAvailabilityWithServiceResponseAsync(groupName, serviceName, parameters).map(new Func1<ServiceResponse<NameAvailabilityResponseInner>, NameAvailabilityResponseInner>() {
@Override
public NameAvailabilityResponseInner call(ServiceResponse<NameAvailabilityResponseInner> response) {
return response.body();
}
});
} | java | public Observable<NameAvailabilityResponseInner> checkChildrenNameAvailabilityAsync(String groupName, String serviceName, NameAvailabilityRequest parameters) {
return checkChildrenNameAvailabilityWithServiceResponseAsync(groupName, serviceName, parameters).map(new Func1<ServiceResponse<NameAvailabilityResponseInner>, NameAvailabilityResponseInner>() {
@Override
public NameAvailabilityResponseInner call(ServiceResponse<NameAvailabilityResponseInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"NameAvailabilityResponseInner",
">",
"checkChildrenNameAvailabilityAsync",
"(",
"String",
"groupName",
",",
"String",
"serviceName",
",",
"NameAvailabilityRequest",
"parameters",
")",
"{",
"return",
"checkChildrenNameAvailabilityWithServiceResponseAsync",
"(",
"groupName",
",",
"serviceName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"NameAvailabilityResponseInner",
">",
",",
"NameAvailabilityResponseInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"NameAvailabilityResponseInner",
"call",
"(",
"ServiceResponse",
"<",
"NameAvailabilityResponseInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Check nested resource name validity and availability.
This method checks whether a proposed nested resource name is valid and available.
@param groupName Name of the resource group
@param serviceName Name of the service
@param parameters Requested name to validate
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NameAvailabilityResponseInner object | [
"Check",
"nested",
"resource",
"name",
"validity",
"and",
"availability",
".",
"This",
"method",
"checks",
"whether",
"a",
"proposed",
"nested",
"resource",
"name",
"is",
"valid",
"and",
"available",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datamigration/resource-manager/v2017_11_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2017_11_15_preview/implementation/ServicesInner.java#L1512-L1519 |