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
|
---|---|---|---|---|---|---|---|---|---|---|
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSection.java | IPv4AddressSection.getIPv4Count | private long getIPv4Count(boolean excludeZeroHosts, int segCount) {
"""
This was added so count available as a long and not as BigInteger
"""
if(!isMultiple()) {
if(excludeZeroHosts && isZero()) {
return 0L;
}
return 1L;
}
long result = getCount(i -> getSegment(i).getValueCount(), segCount);
if(excludeZeroHosts && includesZeroHost()) {
int prefixedSegment = getNetworkSegmentIndex(getNetworkPrefixLength(), IPv4Address.BYTES_PER_SEGMENT, IPv4Address.BITS_PER_SEGMENT);
long zeroHostCount = getCount(i -> {
if(i == prefixedSegment) {
IPAddressSegment seg = getSegment(i);
int shift = seg.getBitCount() - seg.getSegmentPrefixLength();
int count = ((seg.getUpperSegmentValue() >>> shift) - (seg.getSegmentValue() >>> shift)) + 1;
return count;
}
return getSegment(i).getValueCount();
}, prefixedSegment + 1);
result -= zeroHostCount;
}
return result;
} | java | private long getIPv4Count(boolean excludeZeroHosts, int segCount) {
if(!isMultiple()) {
if(excludeZeroHosts && isZero()) {
return 0L;
}
return 1L;
}
long result = getCount(i -> getSegment(i).getValueCount(), segCount);
if(excludeZeroHosts && includesZeroHost()) {
int prefixedSegment = getNetworkSegmentIndex(getNetworkPrefixLength(), IPv4Address.BYTES_PER_SEGMENT, IPv4Address.BITS_PER_SEGMENT);
long zeroHostCount = getCount(i -> {
if(i == prefixedSegment) {
IPAddressSegment seg = getSegment(i);
int shift = seg.getBitCount() - seg.getSegmentPrefixLength();
int count = ((seg.getUpperSegmentValue() >>> shift) - (seg.getSegmentValue() >>> shift)) + 1;
return count;
}
return getSegment(i).getValueCount();
}, prefixedSegment + 1);
result -= zeroHostCount;
}
return result;
} | [
"private",
"long",
"getIPv4Count",
"(",
"boolean",
"excludeZeroHosts",
",",
"int",
"segCount",
")",
"{",
"if",
"(",
"!",
"isMultiple",
"(",
")",
")",
"{",
"if",
"(",
"excludeZeroHosts",
"&&",
"isZero",
"(",
")",
")",
"{",
"return",
"0L",
";",
"}",
"return",
"1L",
";",
"}",
"long",
"result",
"=",
"getCount",
"(",
"i",
"->",
"getSegment",
"(",
"i",
")",
".",
"getValueCount",
"(",
")",
",",
"segCount",
")",
";",
"if",
"(",
"excludeZeroHosts",
"&&",
"includesZeroHost",
"(",
")",
")",
"{",
"int",
"prefixedSegment",
"=",
"getNetworkSegmentIndex",
"(",
"getNetworkPrefixLength",
"(",
")",
",",
"IPv4Address",
".",
"BYTES_PER_SEGMENT",
",",
"IPv4Address",
".",
"BITS_PER_SEGMENT",
")",
";",
"long",
"zeroHostCount",
"=",
"getCount",
"(",
"i",
"->",
"{",
"if",
"(",
"i",
"==",
"prefixedSegment",
")",
"{",
"IPAddressSegment",
"seg",
"=",
"getSegment",
"(",
"i",
")",
";",
"int",
"shift",
"=",
"seg",
".",
"getBitCount",
"(",
")",
"-",
"seg",
".",
"getSegmentPrefixLength",
"(",
")",
";",
"int",
"count",
"=",
"(",
"(",
"seg",
".",
"getUpperSegmentValue",
"(",
")",
">>>",
"shift",
")",
"-",
"(",
"seg",
".",
"getSegmentValue",
"(",
")",
">>>",
"shift",
")",
")",
"+",
"1",
";",
"return",
"count",
";",
"}",
"return",
"getSegment",
"(",
"i",
")",
".",
"getValueCount",
"(",
")",
";",
"}",
",",
"prefixedSegment",
"+",
"1",
")",
";",
"result",
"-=",
"zeroHostCount",
";",
"}",
"return",
"result",
";",
"}"
] | This was added so count available as a long and not as BigInteger | [
"This",
"was",
"added",
"so",
"count",
"available",
"as",
"a",
"long",
"and",
"not",
"as",
"BigInteger"
] | train | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSection.java#L768-L790 |
h2oai/h2o-3 | h2o-core/src/main/java/water/util/StringUtils.java | StringUtils.toCharacterSet | public static HashSet<Character> toCharacterSet(String src) {
"""
Convert a string into the set of its characters.
@param src Source string
@return Set of characters within the source string
"""
int n = src.length();
HashSet<Character> res = new HashSet<>(n);
for (int i = 0; i < n; i++)
res.add(src.charAt(i));
return res;
}
public static Character[] toCharacterArray(String src) {
return ArrayUtils.box(src.toCharArray());
}
public static int unhex(String str) {
int res = 0;
for (char c : str.toCharArray()) {
if (!hexCode.containsKey(c)) throw new NumberFormatException("Not a hexademical character " + c);
res = (res << 4) + hexCode.get(c);
}
return res;
}
public static byte[] bytesOf(CharSequence str) {
return str.toString().getBytes(Charset.forName("UTF-8"));
}
public static byte[] toBytes(Object value) {
return bytesOf(String.valueOf(value));
}
public static String toString(byte[] bytes, int from, int length) {
return new String(bytes, from, length, Charset.forName("UTF-8"));
}
} | java | public static HashSet<Character> toCharacterSet(String src) {
int n = src.length();
HashSet<Character> res = new HashSet<>(n);
for (int i = 0; i < n; i++)
res.add(src.charAt(i));
return res;
}
public static Character[] toCharacterArray(String src) {
return ArrayUtils.box(src.toCharArray());
}
public static int unhex(String str) {
int res = 0;
for (char c : str.toCharArray()) {
if (!hexCode.containsKey(c)) throw new NumberFormatException("Not a hexademical character " + c);
res = (res << 4) + hexCode.get(c);
}
return res;
}
public static byte[] bytesOf(CharSequence str) {
return str.toString().getBytes(Charset.forName("UTF-8"));
}
public static byte[] toBytes(Object value) {
return bytesOf(String.valueOf(value));
}
public static String toString(byte[] bytes, int from, int length) {
return new String(bytes, from, length, Charset.forName("UTF-8"));
}
} | [
"public",
"static",
"HashSet",
"<",
"Character",
">",
"toCharacterSet",
"(",
"String",
"src",
")",
"{",
"int",
"n",
"=",
"src",
".",
"length",
"(",
")",
";",
"HashSet",
"<",
"Character",
">",
"res",
"=",
"new",
"HashSet",
"<>",
"(",
"n",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"res",
".",
"(",
"src",
".",
"charAt",
"(",
"i",
")",
")",
";",
"return",
"res",
";",
"}",
"public",
"static",
"Character",
"[",
"]",
"toCharacterArray",
"(",
"String",
"src",
")",
"{",
"return",
"ArrayUtils",
".",
"box",
"(",
"src",
".",
"toCharArray",
"(",
")",
")",
";",
"}",
"public",
"static",
"int",
"unhex",
"",
"(",
"String",
"str",
")",
"{",
"int",
"res",
"=",
"0",
";",
"for",
"(",
"char",
"c",
":",
"str",
".",
"toCharArray",
"(",
")",
")",
"{",
"if",
"(",
"!",
"hexCode",
".",
"containsKey",
"(",
"c",
")",
")",
"throw",
"new",
"NumberFormatException",
"(",
"\"Not a hexademical character \"",
"+",
"c",
")",
";",
"res",
"=",
"(",
"res",
"<<",
"4",
")",
"+",
"hexCode",
".",
"get",
"(",
"c",
")",
";",
"}",
"return",
"res",
";",
"}",
"public",
"static",
"byte",
"[",
"]",
"bytesOf",
"",
"(",
"CharSequence",
"str",
")",
"{",
"return",
"str",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
")",
";",
"}",
"public",
"static",
"byte",
"[",
"]",
"toBytes",
"",
"(",
"Object",
"value",
")",
"{",
"return",
"bytesOf",
"(",
"String",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"}",
"public",
"static",
"String",
"toString",
"",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"from",
",",
"int",
"length",
")",
"{",
"return",
"new",
"String",
"(",
"bytes",
",",
"from",
",",
"length",
",",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
")",
";",
"}",
"}"
] | Convert a string into the set of its characters.
@param src Source string
@return Set of characters within the source string | [
"Convert",
"a",
"string",
"into",
"the",
"set",
"of",
"its",
"characters",
"."
] | train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-core/src/main/java/water/util/StringUtils.java#L172-L204 |
alkacon/opencms-core | src/org/opencms/util/CmsDateUtil.java | CmsDateUtil.parseDate | public static long parseDate(int year, int month, int date) {
"""
Returns the long value of a date created by the given integer values.<p>
@param year the integer value of year
@param month the integer value of month
@param date the integer value of date
@return the long value of a date created by the given integer values
"""
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, date);
return calendar.getTime().getTime();
} | java | public static long parseDate(int year, int month, int date) {
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, date);
return calendar.getTime().getTime();
} | [
"public",
"static",
"long",
"parseDate",
"(",
"int",
"year",
",",
"int",
"month",
",",
"int",
"date",
")",
"{",
"Calendar",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"calendar",
".",
"set",
"(",
"year",
",",
"month",
",",
"date",
")",
";",
"return",
"calendar",
".",
"getTime",
"(",
")",
".",
"getTime",
"(",
")",
";",
"}"
] | Returns the long value of a date created by the given integer values.<p>
@param year the integer value of year
@param month the integer value of month
@param date the integer value of date
@return the long value of a date created by the given integer values | [
"Returns",
"the",
"long",
"value",
"of",
"a",
"date",
"created",
"by",
"the",
"given",
"integer",
"values",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsDateUtil.java#L190-L195 |
Whiley/WhileyCompiler | src/main/java/wyil/check/FlowTypeCheck.java | FlowTypeCheck.checkIfElse | private Environment checkIfElse(Stmt.IfElse stmt, Environment environment, EnclosingScope scope) {
"""
Type check an if-statement. To do this, we check the environment through both
sides of condition expression. Each can produce a different environment in
the case that runtime type tests are used. These potentially updated
environments are then passed through the true and false blocks which, in
turn, produce updated environments. Finally, these two environments are
joined back together. The following illustrates:
<pre>
// Environment
function f(int|null x) -> int:
// {x : int|null}
if x is null:
// {x : null}
return 0
// {x : int}
else:
// {x : int}
x = x + 1
// {x : int}
// --------------------------------------------------
// {x : int} o {x : int} => {x : int}
return x
</pre>
Here, we see that the type of <code>x</code> is initially
<code>int|null</code> before the first statement of the function body. On the
true branch of the type test this is updated to <code>null</code>, whilst on
the false branch it is updated to <code>int</code>. Finally, the type of
<code>x</code> at the end of each block is <code>int</code> and, hence, its
type after the if-statement is <code>int</code>.
@param stmt
Statement to type check
@param environment
Determines the type of all variables immediately going into this
block
@return
@throws ResolveError
If a named type within this statement cannot be resolved within
the enclosing project.
"""
// Check condition and apply variable retypings.
Environment trueEnvironment = checkCondition(stmt.getCondition(), true, environment);
Environment falseEnvironment = checkCondition(stmt.getCondition(), false, environment);
// Update environments for true and false branches
if (stmt.hasFalseBranch()) {
trueEnvironment = checkBlock(stmt.getTrueBranch(), trueEnvironment, scope);
falseEnvironment = checkBlock(stmt.getFalseBranch(), falseEnvironment, scope);
} else {
trueEnvironment = checkBlock(stmt.getTrueBranch(), trueEnvironment, scope);
}
// Join results back together
return FlowTypeUtils.union(trueEnvironment, falseEnvironment);
} | java | private Environment checkIfElse(Stmt.IfElse stmt, Environment environment, EnclosingScope scope) {
// Check condition and apply variable retypings.
Environment trueEnvironment = checkCondition(stmt.getCondition(), true, environment);
Environment falseEnvironment = checkCondition(stmt.getCondition(), false, environment);
// Update environments for true and false branches
if (stmt.hasFalseBranch()) {
trueEnvironment = checkBlock(stmt.getTrueBranch(), trueEnvironment, scope);
falseEnvironment = checkBlock(stmt.getFalseBranch(), falseEnvironment, scope);
} else {
trueEnvironment = checkBlock(stmt.getTrueBranch(), trueEnvironment, scope);
}
// Join results back together
return FlowTypeUtils.union(trueEnvironment, falseEnvironment);
} | [
"private",
"Environment",
"checkIfElse",
"(",
"Stmt",
".",
"IfElse",
"stmt",
",",
"Environment",
"environment",
",",
"EnclosingScope",
"scope",
")",
"{",
"// Check condition and apply variable retypings.",
"Environment",
"trueEnvironment",
"=",
"checkCondition",
"(",
"stmt",
".",
"getCondition",
"(",
")",
",",
"true",
",",
"environment",
")",
";",
"Environment",
"falseEnvironment",
"=",
"checkCondition",
"(",
"stmt",
".",
"getCondition",
"(",
")",
",",
"false",
",",
"environment",
")",
";",
"// Update environments for true and false branches",
"if",
"(",
"stmt",
".",
"hasFalseBranch",
"(",
")",
")",
"{",
"trueEnvironment",
"=",
"checkBlock",
"(",
"stmt",
".",
"getTrueBranch",
"(",
")",
",",
"trueEnvironment",
",",
"scope",
")",
";",
"falseEnvironment",
"=",
"checkBlock",
"(",
"stmt",
".",
"getFalseBranch",
"(",
")",
",",
"falseEnvironment",
",",
"scope",
")",
";",
"}",
"else",
"{",
"trueEnvironment",
"=",
"checkBlock",
"(",
"stmt",
".",
"getTrueBranch",
"(",
")",
",",
"trueEnvironment",
",",
"scope",
")",
";",
"}",
"// Join results back together",
"return",
"FlowTypeUtils",
".",
"union",
"(",
"trueEnvironment",
",",
"falseEnvironment",
")",
";",
"}"
] | Type check an if-statement. To do this, we check the environment through both
sides of condition expression. Each can produce a different environment in
the case that runtime type tests are used. These potentially updated
environments are then passed through the true and false blocks which, in
turn, produce updated environments. Finally, these two environments are
joined back together. The following illustrates:
<pre>
// Environment
function f(int|null x) -> int:
// {x : int|null}
if x is null:
// {x : null}
return 0
// {x : int}
else:
// {x : int}
x = x + 1
// {x : int}
// --------------------------------------------------
// {x : int} o {x : int} => {x : int}
return x
</pre>
Here, we see that the type of <code>x</code> is initially
<code>int|null</code> before the first statement of the function body. On the
true branch of the type test this is updated to <code>null</code>, whilst on
the false branch it is updated to <code>int</code>. Finally, the type of
<code>x</code> at the end of each block is <code>int</code> and, hence, its
type after the if-statement is <code>int</code>.
@param stmt
Statement to type check
@param environment
Determines the type of all variables immediately going into this
block
@return
@throws ResolveError
If a named type within this statement cannot be resolved within
the enclosing project. | [
"Type",
"check",
"an",
"if",
"-",
"statement",
".",
"To",
"do",
"this",
"we",
"check",
"the",
"environment",
"through",
"both",
"sides",
"of",
"condition",
"expression",
".",
"Each",
"can",
"produce",
"a",
"different",
"environment",
"in",
"the",
"case",
"that",
"runtime",
"type",
"tests",
"are",
"used",
".",
"These",
"potentially",
"updated",
"environments",
"are",
"then",
"passed",
"through",
"the",
"true",
"and",
"false",
"blocks",
"which",
"in",
"turn",
"produce",
"updated",
"environments",
".",
"Finally",
"these",
"two",
"environments",
"are",
"joined",
"back",
"together",
".",
"The",
"following",
"illustrates",
":"
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/check/FlowTypeCheck.java#L574-L587 |
fleipold/jproc | src/main/java/org/buildobjects/process/ProcBuilder.java | ProcBuilder.run | public ProcResult run() throws StartupException, TimeoutException, ExternalProcessFailureException {
"""
Spawn the actual execution.
This will block until the process terminates.
@return the result of the successful execution
@throws StartupException if the process can't be started
@throws TimeoutException if the timeout kicked in
@throws ExternalProcessFailureException if the external process returned a non-null exit value
"""
if (stdout != defaultStdout && outputConsumer != null) {
throw new IllegalArgumentException("You can either ...");
}
try {
Proc proc = new Proc(command, args, env, stdin, outputConsumer != null ? outputConsumer : stdout , directory, timoutMillis, expectedExitStatuses, stderr);
return new ProcResult(proc.toString(), defaultStdout == stdout && outputConsumer == null ? defaultStdout : null, proc.getExitValue(), proc.getExecutionTime(), proc.getErrorBytes());
} finally {
stdout = defaultStdout = new ByteArrayOutputStream();
stdin = null;
}
} | java | public ProcResult run() throws StartupException, TimeoutException, ExternalProcessFailureException {
if (stdout != defaultStdout && outputConsumer != null) {
throw new IllegalArgumentException("You can either ...");
}
try {
Proc proc = new Proc(command, args, env, stdin, outputConsumer != null ? outputConsumer : stdout , directory, timoutMillis, expectedExitStatuses, stderr);
return new ProcResult(proc.toString(), defaultStdout == stdout && outputConsumer == null ? defaultStdout : null, proc.getExitValue(), proc.getExecutionTime(), proc.getErrorBytes());
} finally {
stdout = defaultStdout = new ByteArrayOutputStream();
stdin = null;
}
} | [
"public",
"ProcResult",
"run",
"(",
")",
"throws",
"StartupException",
",",
"TimeoutException",
",",
"ExternalProcessFailureException",
"{",
"if",
"(",
"stdout",
"!=",
"defaultStdout",
"&&",
"outputConsumer",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"You can either ...\"",
")",
";",
"}",
"try",
"{",
"Proc",
"proc",
"=",
"new",
"Proc",
"(",
"command",
",",
"args",
",",
"env",
",",
"stdin",
",",
"outputConsumer",
"!=",
"null",
"?",
"outputConsumer",
":",
"stdout",
",",
"directory",
",",
"timoutMillis",
",",
"expectedExitStatuses",
",",
"stderr",
")",
";",
"return",
"new",
"ProcResult",
"(",
"proc",
".",
"toString",
"(",
")",
",",
"defaultStdout",
"==",
"stdout",
"&&",
"outputConsumer",
"==",
"null",
"?",
"defaultStdout",
":",
"null",
",",
"proc",
".",
"getExitValue",
"(",
")",
",",
"proc",
".",
"getExecutionTime",
"(",
")",
",",
"proc",
".",
"getErrorBytes",
"(",
")",
")",
";",
"}",
"finally",
"{",
"stdout",
"=",
"defaultStdout",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"stdin",
"=",
"null",
";",
"}",
"}"
] | Spawn the actual execution.
This will block until the process terminates.
@return the result of the successful execution
@throws StartupException if the process can't be started
@throws TimeoutException if the timeout kicked in
@throws ExternalProcessFailureException if the external process returned a non-null exit value | [
"Spawn",
"the",
"actual",
"execution",
".",
"This",
"will",
"block",
"until",
"the",
"process",
"terminates",
"."
] | train | https://github.com/fleipold/jproc/blob/617f498c63a822c6b0506a2474b3bc954ea25c9a/src/main/java/org/buildobjects/process/ProcBuilder.java#L198-L212 |
radkovo/jStyleParser | src/main/java/cz/vutbr/web/css/CSSFactory.java | CSSFactory.assignDOM | public static final StyleMap assignDOM(Document doc, String encoding,
URL base, String media, boolean useInheritance, final MatchCondition matchCond) {
"""
This is the same as {@link CSSFactory#assignDOM(Document, String, URL, MediaSpec, boolean)} but only the
media type is provided instead of the complete media specification.
@param doc
DOM tree
@param encoding
The default encoding used for the referenced style sheets
@param base
Base URL against which all files are searched
@param media
Selected media type for style sheet
@param useInheritance
Whether inheritance will be used to determine values
@param matchCond
The match condition to match the against.
@return Map between DOM element nodes and data structure containing CSS
information
"""
return assignDOM(doc, encoding, base, new MediaSpec(media), useInheritance, matchCond);
} | java | public static final StyleMap assignDOM(Document doc, String encoding,
URL base, String media, boolean useInheritance, final MatchCondition matchCond) {
return assignDOM(doc, encoding, base, new MediaSpec(media), useInheritance, matchCond);
} | [
"public",
"static",
"final",
"StyleMap",
"assignDOM",
"(",
"Document",
"doc",
",",
"String",
"encoding",
",",
"URL",
"base",
",",
"String",
"media",
",",
"boolean",
"useInheritance",
",",
"final",
"MatchCondition",
"matchCond",
")",
"{",
"return",
"assignDOM",
"(",
"doc",
",",
"encoding",
",",
"base",
",",
"new",
"MediaSpec",
"(",
"media",
")",
",",
"useInheritance",
",",
"matchCond",
")",
";",
"}"
] | This is the same as {@link CSSFactory#assignDOM(Document, String, URL, MediaSpec, boolean)} but only the
media type is provided instead of the complete media specification.
@param doc
DOM tree
@param encoding
The default encoding used for the referenced style sheets
@param base
Base URL against which all files are searched
@param media
Selected media type for style sheet
@param useInheritance
Whether inheritance will be used to determine values
@param matchCond
The match condition to match the against.
@return Map between DOM element nodes and data structure containing CSS
information | [
"This",
"is",
"the",
"same",
"as",
"{",
"@link",
"CSSFactory#assignDOM",
"(",
"Document",
"String",
"URL",
"MediaSpec",
"boolean",
")",
"}",
"but",
"only",
"the",
"media",
"type",
"is",
"provided",
"instead",
"of",
"the",
"complete",
"media",
"specification",
"."
] | train | https://github.com/radkovo/jStyleParser/blob/8ab049ac6866aa52c4d7deee25c9e294e7191957/src/main/java/cz/vutbr/web/css/CSSFactory.java#L770-L774 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/PathUtils.java | PathUtils.checkCase | public static boolean checkCase(final File file, String pathToTest) {
"""
The artifact API is case sensitive even on a file system that is not case sensitive.
This method will test that the case of the supplied <em>existing</em> file matches the case
in the pathToTest. It is assumed that you already tested that the file exists using
the pathToTest. Therefore, on a case sensitive files system, the case must match and
true is returned without doing any further testing. In other words, the check for file
existence is sufficient on a case sensitive file system, and there is no reason to call
this checkCase method.
If the file system is not case sensitive, then a test for file existence will pass
even when the case does not match. So this method will do further testing to ensure
the case matches.
It assumes that the final part of the file's path will be equal to
the whole of the pathToTest.
The path to test should be a unix style path with "/" as the separator character,
regardless of the operating system. If the file is a directory then a trailing slash
or the absence thereof will not affect whether the case matches since the trailing
slash on a directory is optional.
If you call checkCase(...) with a file that does NOT exist:
On case sensitive file system: Always returns true
On case insensitive file system: It compares the pathToTest to the file path of the
java.io.File that you passed in rather than the file on disk (since it doesn't exist).
file.getCanonicalFile() returns the path using the case of the file on disk, if it exists.
If the file doesn't exist then it returns the path using the case of the java.io.File itself.
@param file The existing file to compare against
@param pathToTest The path to test if it is the same
@return <code>true</code> if the case is the same in the file and the pathToTest
"""
if (pathToTest == null || pathToTest.isEmpty()) {
return true;
}
if (IS_OS_CASE_SENSITIVE) {
// It is assumed that the file exists. Therefore, its case must
// match if we know that the file system is case sensitive.
return true;
}
try {
// This will handle the case where the file system is not case sensitive, but
// doesn't support symbolic links. A canonical file path will handle this case.
if (checkCaseCanonical(file, pathToTest)) {
return true;
}
// We didn't know for sure that the file system is case sensitive and a
// canonical check didn't pass. Try to handle both symbolic links and case
// insensitive files together.
return checkCaseSymlink(file, pathToTest);
} catch (PrivilegedActionException e) {
// We couldn't access the file system to test the path so must have failed
return false;
}
} | java | public static boolean checkCase(final File file, String pathToTest) {
if (pathToTest == null || pathToTest.isEmpty()) {
return true;
}
if (IS_OS_CASE_SENSITIVE) {
// It is assumed that the file exists. Therefore, its case must
// match if we know that the file system is case sensitive.
return true;
}
try {
// This will handle the case where the file system is not case sensitive, but
// doesn't support symbolic links. A canonical file path will handle this case.
if (checkCaseCanonical(file, pathToTest)) {
return true;
}
// We didn't know for sure that the file system is case sensitive and a
// canonical check didn't pass. Try to handle both symbolic links and case
// insensitive files together.
return checkCaseSymlink(file, pathToTest);
} catch (PrivilegedActionException e) {
// We couldn't access the file system to test the path so must have failed
return false;
}
} | [
"public",
"static",
"boolean",
"checkCase",
"(",
"final",
"File",
"file",
",",
"String",
"pathToTest",
")",
"{",
"if",
"(",
"pathToTest",
"==",
"null",
"||",
"pathToTest",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"IS_OS_CASE_SENSITIVE",
")",
"{",
"// It is assumed that the file exists. Therefore, its case must",
"// match if we know that the file system is case sensitive.",
"return",
"true",
";",
"}",
"try",
"{",
"// This will handle the case where the file system is not case sensitive, but",
"// doesn't support symbolic links. A canonical file path will handle this case.",
"if",
"(",
"checkCaseCanonical",
"(",
"file",
",",
"pathToTest",
")",
")",
"{",
"return",
"true",
";",
"}",
"// We didn't know for sure that the file system is case sensitive and a",
"// canonical check didn't pass. Try to handle both symbolic links and case",
"// insensitive files together.",
"return",
"checkCaseSymlink",
"(",
"file",
",",
"pathToTest",
")",
";",
"}",
"catch",
"(",
"PrivilegedActionException",
"e",
")",
"{",
"// We couldn't access the file system to test the path so must have failed",
"return",
"false",
";",
"}",
"}"
] | The artifact API is case sensitive even on a file system that is not case sensitive.
This method will test that the case of the supplied <em>existing</em> file matches the case
in the pathToTest. It is assumed that you already tested that the file exists using
the pathToTest. Therefore, on a case sensitive files system, the case must match and
true is returned without doing any further testing. In other words, the check for file
existence is sufficient on a case sensitive file system, and there is no reason to call
this checkCase method.
If the file system is not case sensitive, then a test for file existence will pass
even when the case does not match. So this method will do further testing to ensure
the case matches.
It assumes that the final part of the file's path will be equal to
the whole of the pathToTest.
The path to test should be a unix style path with "/" as the separator character,
regardless of the operating system. If the file is a directory then a trailing slash
or the absence thereof will not affect whether the case matches since the trailing
slash on a directory is optional.
If you call checkCase(...) with a file that does NOT exist:
On case sensitive file system: Always returns true
On case insensitive file system: It compares the pathToTest to the file path of the
java.io.File that you passed in rather than the file on disk (since it doesn't exist).
file.getCanonicalFile() returns the path using the case of the file on disk, if it exists.
If the file doesn't exist then it returns the path using the case of the java.io.File itself.
@param file The existing file to compare against
@param pathToTest The path to test if it is the same
@return <code>true</code> if the case is the same in the file and the pathToTest | [
"The",
"artifact",
"API",
"is",
"case",
"sensitive",
"even",
"on",
"a",
"file",
"system",
"that",
"is",
"not",
"case",
"sensitive",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/PathUtils.java#L1252-L1279 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java | ApiOvhEmaildomain.domain_task_filter_id_GET | public OvhTaskFilter domain_task_filter_id_GET(String domain, Long id) throws IOException {
"""
Get this object properties
REST: GET /email/domain/{domain}/task/filter/{id}
@param domain [required] Name of your domain name
@param id [required] Id of task
"""
String qPath = "/email/domain/{domain}/task/filter/{id}";
StringBuilder sb = path(qPath, domain, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhTaskFilter.class);
} | java | public OvhTaskFilter domain_task_filter_id_GET(String domain, Long id) throws IOException {
String qPath = "/email/domain/{domain}/task/filter/{id}";
StringBuilder sb = path(qPath, domain, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhTaskFilter.class);
} | [
"public",
"OvhTaskFilter",
"domain_task_filter_id_GET",
"(",
"String",
"domain",
",",
"Long",
"id",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/domain/{domain}/task/filter/{id}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"domain",
",",
"id",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTaskFilter",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /email/domain/{domain}/task/filter/{id}
@param domain [required] Name of your domain name
@param id [required] Id of task | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java#L1158-L1163 |
wnameless/rubycollect4j | src/main/java/net/sf/rubycollect4j/RubyObject.java | RubyObject.send | public static <E> E send(Object o, String methodName, Boolean arg) {
"""
Executes a method of any Object by Java reflection.
@param o
an Object
@param methodName
name of the method
@param arg
a Boolean
@return the result of the method called
"""
return send(o, methodName, (Object) arg);
} | java | public static <E> E send(Object o, String methodName, Boolean arg) {
return send(o, methodName, (Object) arg);
} | [
"public",
"static",
"<",
"E",
">",
"E",
"send",
"(",
"Object",
"o",
",",
"String",
"methodName",
",",
"Boolean",
"arg",
")",
"{",
"return",
"send",
"(",
"o",
",",
"methodName",
",",
"(",
"Object",
")",
"arg",
")",
";",
"}"
] | Executes a method of any Object by Java reflection.
@param o
an Object
@param methodName
name of the method
@param arg
a Boolean
@return the result of the method called | [
"Executes",
"a",
"method",
"of",
"any",
"Object",
"by",
"Java",
"reflection",
"."
] | train | https://github.com/wnameless/rubycollect4j/blob/b8b8d8eccaca2254a3d09b91745882fb7a0d5add/src/main/java/net/sf/rubycollect4j/RubyObject.java#L327-L329 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/utils/linkedlist/LinkedList.java | LinkedList.newCursorAtBottom | public Cursor newCursorAtBottom(String name) {
"""
Synchronized. Creates a new cursor over this list, initially sitting
at the bottoms of the list.
"""
if (tc.isEntryEnabled())
SibTr.entry(tc, "newCursorAtBottom", name);
Cursor cursor = new Cursor(name,this,false);
if (tc.isEntryEnabled())
SibTr.exit(tc, "newCursorAtBottom", cursor);
return cursor;
} | java | public Cursor newCursorAtBottom(String name)
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "newCursorAtBottom", name);
Cursor cursor = new Cursor(name,this,false);
if (tc.isEntryEnabled())
SibTr.exit(tc, "newCursorAtBottom", cursor);
return cursor;
} | [
"public",
"Cursor",
"newCursorAtBottom",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"newCursorAtBottom\"",
",",
"name",
")",
";",
"Cursor",
"cursor",
"=",
"new",
"Cursor",
"(",
"name",
",",
"this",
",",
"false",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"newCursorAtBottom\"",
",",
"cursor",
")",
";",
"return",
"cursor",
";",
"}"
] | Synchronized. Creates a new cursor over this list, initially sitting
at the bottoms of the list. | [
"Synchronized",
".",
"Creates",
"a",
"new",
"cursor",
"over",
"this",
"list",
"initially",
"sitting",
"at",
"the",
"bottoms",
"of",
"the",
"list",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/utils/linkedlist/LinkedList.java#L78-L89 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/core/urltemplates/URLTemplates.java | URLTemplates.getTemplateNameByRef | public String getTemplateNameByRef( String refGroupName, String key ) {
"""
Retrieve a template name from a reference group in url-template-config.
@param refGroupName the name of the template reference group.
@param key the key to the particular template reference in the group.
@return a template name from the reference group.
"""
String templateName = null;
Map/*< String, String >*/ templateRefGroup = ( Map ) _templateRefGroups.get( refGroupName );
if ( templateRefGroup != null )
{
templateName = ( String ) templateRefGroup.get( key );
}
return templateName;
} | java | public String getTemplateNameByRef( String refGroupName, String key )
{
String templateName = null;
Map/*< String, String >*/ templateRefGroup = ( Map ) _templateRefGroups.get( refGroupName );
if ( templateRefGroup != null )
{
templateName = ( String ) templateRefGroup.get( key );
}
return templateName;
} | [
"public",
"String",
"getTemplateNameByRef",
"(",
"String",
"refGroupName",
",",
"String",
"key",
")",
"{",
"String",
"templateName",
"=",
"null",
";",
"Map",
"/*< String, String >*/",
"templateRefGroup",
"=",
"(",
"Map",
")",
"_templateRefGroups",
".",
"get",
"(",
"refGroupName",
")",
";",
"if",
"(",
"templateRefGroup",
"!=",
"null",
")",
"{",
"templateName",
"=",
"(",
"String",
")",
"templateRefGroup",
".",
"get",
"(",
"key",
")",
";",
"}",
"return",
"templateName",
";",
"}"
] | Retrieve a template name from a reference group in url-template-config.
@param refGroupName the name of the template reference group.
@param key the key to the particular template reference in the group.
@return a template name from the reference group. | [
"Retrieve",
"a",
"template",
"name",
"from",
"a",
"reference",
"group",
"in",
"url",
"-",
"template",
"-",
"config",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/core/urltemplates/URLTemplates.java#L129-L139 |
HanSolo/SteelSeries-Swing | src/main/java/eu/hansolo/steelseries/gauges/AbstractRadial.java | AbstractRadial.create_TITLE_Image | protected BufferedImage create_TITLE_Image(final int WIDTH, final String TITLE, final String UNIT_STRING) {
"""
Returns the image with the given title and unitstring.
@param WIDTH
@param TITLE
@param UNIT_STRING
@return the image with the given title and unitstring.
"""
return create_TITLE_Image(WIDTH, TITLE, UNIT_STRING, null);
} | java | protected BufferedImage create_TITLE_Image(final int WIDTH, final String TITLE, final String UNIT_STRING) {
return create_TITLE_Image(WIDTH, TITLE, UNIT_STRING, null);
} | [
"protected",
"BufferedImage",
"create_TITLE_Image",
"(",
"final",
"int",
"WIDTH",
",",
"final",
"String",
"TITLE",
",",
"final",
"String",
"UNIT_STRING",
")",
"{",
"return",
"create_TITLE_Image",
"(",
"WIDTH",
",",
"TITLE",
",",
"UNIT_STRING",
",",
"null",
")",
";",
"}"
] | Returns the image with the given title and unitstring.
@param WIDTH
@param TITLE
@param UNIT_STRING
@return the image with the given title and unitstring. | [
"Returns",
"the",
"image",
"with",
"the",
"given",
"title",
"and",
"unitstring",
"."
] | train | https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/AbstractRadial.java#L1411-L1413 |
lessthanoptimal/BoofCV | integration/boofcv-swing/src/main/java/boofcv/gui/image/VisualizeImageData.java | VisualizeImageData.grayMagnitudeTemp | public static BufferedImage grayMagnitudeTemp(ImageGray src, BufferedImage dst, double normalize) {
"""
<p>
Renders a gray scale image using color values from cold to hot.
</p>
@param src Input single band image.
@param dst Where the image is rendered into. If null a new BufferedImage will be created and return.
@param normalize Used to normalize the input image.
@return Rendered image.
"""
if (normalize < 0)
normalize = GImageStatistics.maxAbs(src);
dst = checkInputs(src, dst);
if (src.getDataType().isInteger()) {
return grayMagnitudeTemp((GrayI) src, dst, (int) normalize);
} else {
throw new RuntimeException("Add support");
}
} | java | public static BufferedImage grayMagnitudeTemp(ImageGray src, BufferedImage dst, double normalize) {
if (normalize < 0)
normalize = GImageStatistics.maxAbs(src);
dst = checkInputs(src, dst);
if (src.getDataType().isInteger()) {
return grayMagnitudeTemp((GrayI) src, dst, (int) normalize);
} else {
throw new RuntimeException("Add support");
}
} | [
"public",
"static",
"BufferedImage",
"grayMagnitudeTemp",
"(",
"ImageGray",
"src",
",",
"BufferedImage",
"dst",
",",
"double",
"normalize",
")",
"{",
"if",
"(",
"normalize",
"<",
"0",
")",
"normalize",
"=",
"GImageStatistics",
".",
"maxAbs",
"(",
"src",
")",
";",
"dst",
"=",
"checkInputs",
"(",
"src",
",",
"dst",
")",
";",
"if",
"(",
"src",
".",
"getDataType",
"(",
")",
".",
"isInteger",
"(",
")",
")",
"{",
"return",
"grayMagnitudeTemp",
"(",
"(",
"GrayI",
")",
"src",
",",
"dst",
",",
"(",
"int",
")",
"normalize",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Add support\"",
")",
";",
"}",
"}"
] | <p>
Renders a gray scale image using color values from cold to hot.
</p>
@param src Input single band image.
@param dst Where the image is rendered into. If null a new BufferedImage will be created and return.
@param normalize Used to normalize the input image.
@return Rendered image. | [
"<p",
">",
"Renders",
"a",
"gray",
"scale",
"image",
"using",
"color",
"values",
"from",
"cold",
"to",
"hot",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/image/VisualizeImageData.java#L186-L197 |
petergeneric/stdlib | service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/impl/ServiceManagerResourceRestServiceImpl.java | ServiceManagerResourceRestServiceImpl.provision | @Override
public ResourceInstanceDTO provision(final String templateName, final ProvisionResourceParametersDTO parameters) {
"""
N.B. no {@link Transactional} annotation because the inner service does transaction management
@param templateName
@param parameters
@return
"""
final Map<String, String> metadata = ResourceKVP.toMap(parameters.metadata);
ResourceInstanceEntity entity = service.newInstance(templateName, metadata);
return getInstanceById(entity.getId());
} | java | @Override
public ResourceInstanceDTO provision(final String templateName, final ProvisionResourceParametersDTO parameters)
{
final Map<String, String> metadata = ResourceKVP.toMap(parameters.metadata);
ResourceInstanceEntity entity = service.newInstance(templateName, metadata);
return getInstanceById(entity.getId());
} | [
"@",
"Override",
"public",
"ResourceInstanceDTO",
"provision",
"(",
"final",
"String",
"templateName",
",",
"final",
"ProvisionResourceParametersDTO",
"parameters",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"metadata",
"=",
"ResourceKVP",
".",
"toMap",
"(",
"parameters",
".",
"metadata",
")",
";",
"ResourceInstanceEntity",
"entity",
"=",
"service",
".",
"newInstance",
"(",
"templateName",
",",
"metadata",
")",
";",
"return",
"getInstanceById",
"(",
"entity",
".",
"getId",
"(",
")",
")",
";",
"}"
] | N.B. no {@link Transactional} annotation because the inner service does transaction management
@param templateName
@param parameters
@return | [
"N",
".",
"B",
".",
"no",
"{",
"@link",
"Transactional",
"}",
"annotation",
"because",
"the",
"inner",
"service",
"does",
"transaction",
"management"
] | train | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/impl/ServiceManagerResourceRestServiceImpl.java#L77-L85 |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java | StreamExecutionEnvironment.readTextFile | public DataStreamSource<String> readTextFile(String filePath, String charsetName) {
"""
Reads the given file line-by-line and creates a data stream that contains a string with the
contents of each such line. The {@link java.nio.charset.Charset} with the given name will be
used to read the files.
<p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
{@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
@param filePath
The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
@param charsetName
The name of the character set used to read the file
@return The data stream that represents the data read from the given file as text lines
"""
Preconditions.checkArgument(!StringUtils.isNullOrWhitespaceOnly(filePath), "The file path must not be null or blank.");
TextInputFormat format = new TextInputFormat(new Path(filePath));
format.setFilesFilter(FilePathFilter.createDefaultFilter());
TypeInformation<String> typeInfo = BasicTypeInfo.STRING_TYPE_INFO;
format.setCharsetName(charsetName);
return readFile(format, filePath, FileProcessingMode.PROCESS_ONCE, -1, typeInfo);
} | java | public DataStreamSource<String> readTextFile(String filePath, String charsetName) {
Preconditions.checkArgument(!StringUtils.isNullOrWhitespaceOnly(filePath), "The file path must not be null or blank.");
TextInputFormat format = new TextInputFormat(new Path(filePath));
format.setFilesFilter(FilePathFilter.createDefaultFilter());
TypeInformation<String> typeInfo = BasicTypeInfo.STRING_TYPE_INFO;
format.setCharsetName(charsetName);
return readFile(format, filePath, FileProcessingMode.PROCESS_ONCE, -1, typeInfo);
} | [
"public",
"DataStreamSource",
"<",
"String",
">",
"readTextFile",
"(",
"String",
"filePath",
",",
"String",
"charsetName",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"StringUtils",
".",
"isNullOrWhitespaceOnly",
"(",
"filePath",
")",
",",
"\"The file path must not be null or blank.\"",
")",
";",
"TextInputFormat",
"format",
"=",
"new",
"TextInputFormat",
"(",
"new",
"Path",
"(",
"filePath",
")",
")",
";",
"format",
".",
"setFilesFilter",
"(",
"FilePathFilter",
".",
"createDefaultFilter",
"(",
")",
")",
";",
"TypeInformation",
"<",
"String",
">",
"typeInfo",
"=",
"BasicTypeInfo",
".",
"STRING_TYPE_INFO",
";",
"format",
".",
"setCharsetName",
"(",
"charsetName",
")",
";",
"return",
"readFile",
"(",
"format",
",",
"filePath",
",",
"FileProcessingMode",
".",
"PROCESS_ONCE",
",",
"-",
"1",
",",
"typeInfo",
")",
";",
"}"
] | Reads the given file line-by-line and creates a data stream that contains a string with the
contents of each such line. The {@link java.nio.charset.Charset} with the given name will be
used to read the files.
<p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
{@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
@param filePath
The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
@param charsetName
The name of the character set used to read the file
@return The data stream that represents the data read from the given file as text lines | [
"Reads",
"the",
"given",
"file",
"line",
"-",
"by",
"-",
"line",
"and",
"creates",
"a",
"data",
"stream",
"that",
"contains",
"a",
"string",
"with",
"the",
"contents",
"of",
"each",
"such",
"line",
".",
"The",
"{",
"@link",
"java",
".",
"nio",
".",
"charset",
".",
"Charset",
"}",
"with",
"the",
"given",
"name",
"will",
"be",
"used",
"to",
"read",
"the",
"files",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java#L959-L968 |
line/armeria | core/src/main/java/com/linecorp/armeria/internal/ArmeriaHttpUtil.java | ArmeriaHttpUtil.toNettyHttp2 | public static Http2Headers toNettyHttp2(HttpHeaders in, boolean server) {
"""
Converts the specified Armeria HTTP/2 headers into Netty HTTP/2 headers.
"""
final Http2Headers out = new DefaultHttp2Headers(false, in.size());
// Trailing headers if it does not have :status.
if (server && in.status() == null) {
for (Entry<AsciiString, String> entry : in) {
final AsciiString name = entry.getKey();
final String value = entry.getValue();
if (name.isEmpty() || HTTP_TRAILER_BLACKLIST.contains(name)) {
continue;
}
out.add(name, value);
}
} else {
out.set(in);
out.remove(HttpHeaderNames.CONNECTION);
out.remove(HttpHeaderNames.TRANSFER_ENCODING);
}
if (!out.contains(HttpHeaderNames.COOKIE)) {
return out;
}
// Split up cookies to allow for better compression.
// https://tools.ietf.org/html/rfc7540#section-8.1.2.5
final List<CharSequence> cookies = out.getAllAndRemove(HttpHeaderNames.COOKIE);
for (CharSequence c : cookies) {
out.add(HttpHeaderNames.COOKIE, COOKIE_SPLITTER.split(c));
}
return out;
} | java | public static Http2Headers toNettyHttp2(HttpHeaders in, boolean server) {
final Http2Headers out = new DefaultHttp2Headers(false, in.size());
// Trailing headers if it does not have :status.
if (server && in.status() == null) {
for (Entry<AsciiString, String> entry : in) {
final AsciiString name = entry.getKey();
final String value = entry.getValue();
if (name.isEmpty() || HTTP_TRAILER_BLACKLIST.contains(name)) {
continue;
}
out.add(name, value);
}
} else {
out.set(in);
out.remove(HttpHeaderNames.CONNECTION);
out.remove(HttpHeaderNames.TRANSFER_ENCODING);
}
if (!out.contains(HttpHeaderNames.COOKIE)) {
return out;
}
// Split up cookies to allow for better compression.
// https://tools.ietf.org/html/rfc7540#section-8.1.2.5
final List<CharSequence> cookies = out.getAllAndRemove(HttpHeaderNames.COOKIE);
for (CharSequence c : cookies) {
out.add(HttpHeaderNames.COOKIE, COOKIE_SPLITTER.split(c));
}
return out;
} | [
"public",
"static",
"Http2Headers",
"toNettyHttp2",
"(",
"HttpHeaders",
"in",
",",
"boolean",
"server",
")",
"{",
"final",
"Http2Headers",
"out",
"=",
"new",
"DefaultHttp2Headers",
"(",
"false",
",",
"in",
".",
"size",
"(",
")",
")",
";",
"// Trailing headers if it does not have :status.",
"if",
"(",
"server",
"&&",
"in",
".",
"status",
"(",
")",
"==",
"null",
")",
"{",
"for",
"(",
"Entry",
"<",
"AsciiString",
",",
"String",
">",
"entry",
":",
"in",
")",
"{",
"final",
"AsciiString",
"name",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"final",
"String",
"value",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"name",
".",
"isEmpty",
"(",
")",
"||",
"HTTP_TRAILER_BLACKLIST",
".",
"contains",
"(",
"name",
")",
")",
"{",
"continue",
";",
"}",
"out",
".",
"add",
"(",
"name",
",",
"value",
")",
";",
"}",
"}",
"else",
"{",
"out",
".",
"set",
"(",
"in",
")",
";",
"out",
".",
"remove",
"(",
"HttpHeaderNames",
".",
"CONNECTION",
")",
";",
"out",
".",
"remove",
"(",
"HttpHeaderNames",
".",
"TRANSFER_ENCODING",
")",
";",
"}",
"if",
"(",
"!",
"out",
".",
"contains",
"(",
"HttpHeaderNames",
".",
"COOKIE",
")",
")",
"{",
"return",
"out",
";",
"}",
"// Split up cookies to allow for better compression.",
"// https://tools.ietf.org/html/rfc7540#section-8.1.2.5",
"final",
"List",
"<",
"CharSequence",
">",
"cookies",
"=",
"out",
".",
"getAllAndRemove",
"(",
"HttpHeaderNames",
".",
"COOKIE",
")",
";",
"for",
"(",
"CharSequence",
"c",
":",
"cookies",
")",
"{",
"out",
".",
"add",
"(",
"HttpHeaderNames",
".",
"COOKIE",
",",
"COOKIE_SPLITTER",
".",
"split",
"(",
"c",
")",
")",
";",
"}",
"return",
"out",
";",
"}"
] | Converts the specified Armeria HTTP/2 headers into Netty HTTP/2 headers. | [
"Converts",
"the",
"specified",
"Armeria",
"HTTP",
"/",
"2",
"headers",
"into",
"Netty",
"HTTP",
"/",
"2",
"headers",
"."
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/internal/ArmeriaHttpUtil.java#L748-L779 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/config/Config.java | Config.getFlakeIdGeneratorConfig | public FlakeIdGeneratorConfig getFlakeIdGeneratorConfig(String name) {
"""
Returns the {@link FlakeIdGeneratorConfig} for the given name, creating
one if necessary and adding it to the collection of known configurations.
<p>
The configuration is found by matching the configuration name
pattern to the provided {@code name} without the partition qualifier
(the part of the name after {@code '@'}).
If no configuration matches, it will create one by cloning the
{@code "default"} configuration and add it to the configuration
collection.
<p>
This method is intended to easily and fluently create and add
configurations more specific than the default configuration without
explicitly adding it by invoking {@link #addFlakeIdGeneratorConfig(FlakeIdGeneratorConfig)}.
<p>
Because it adds new configurations if they are not already present,
this method is intended to be used before this config is used to
create a hazelcast instance. Afterwards, newly added configurations
may be ignored.
@param name name of the flake ID generator config
@return the cache configuration
@throws ConfigurationException if ambiguous configurations are found
@see com.hazelcast.partition.strategy.StringPartitioningStrategy#getBaseName(java.lang.String)
@see #setConfigPatternMatcher(ConfigPatternMatcher)
@see #getConfigPatternMatcher()
"""
return ConfigUtils.getConfig(configPatternMatcher, flakeIdGeneratorConfigMap, name,
FlakeIdGeneratorConfig.class, new BiConsumer<FlakeIdGeneratorConfig, String>() {
@Override
public void accept(FlakeIdGeneratorConfig flakeIdGeneratorConfig, String name) {
flakeIdGeneratorConfig.setName(name);
}
});
} | java | public FlakeIdGeneratorConfig getFlakeIdGeneratorConfig(String name) {
return ConfigUtils.getConfig(configPatternMatcher, flakeIdGeneratorConfigMap, name,
FlakeIdGeneratorConfig.class, new BiConsumer<FlakeIdGeneratorConfig, String>() {
@Override
public void accept(FlakeIdGeneratorConfig flakeIdGeneratorConfig, String name) {
flakeIdGeneratorConfig.setName(name);
}
});
} | [
"public",
"FlakeIdGeneratorConfig",
"getFlakeIdGeneratorConfig",
"(",
"String",
"name",
")",
"{",
"return",
"ConfigUtils",
".",
"getConfig",
"(",
"configPatternMatcher",
",",
"flakeIdGeneratorConfigMap",
",",
"name",
",",
"FlakeIdGeneratorConfig",
".",
"class",
",",
"new",
"BiConsumer",
"<",
"FlakeIdGeneratorConfig",
",",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"accept",
"(",
"FlakeIdGeneratorConfig",
"flakeIdGeneratorConfig",
",",
"String",
"name",
")",
"{",
"flakeIdGeneratorConfig",
".",
"setName",
"(",
"name",
")",
";",
"}",
"}",
")",
";",
"}"
] | Returns the {@link FlakeIdGeneratorConfig} for the given name, creating
one if necessary and adding it to the collection of known configurations.
<p>
The configuration is found by matching the configuration name
pattern to the provided {@code name} without the partition qualifier
(the part of the name after {@code '@'}).
If no configuration matches, it will create one by cloning the
{@code "default"} configuration and add it to the configuration
collection.
<p>
This method is intended to easily and fluently create and add
configurations more specific than the default configuration without
explicitly adding it by invoking {@link #addFlakeIdGeneratorConfig(FlakeIdGeneratorConfig)}.
<p>
Because it adds new configurations if they are not already present,
this method is intended to be used before this config is used to
create a hazelcast instance. Afterwards, newly added configurations
may be ignored.
@param name name of the flake ID generator config
@return the cache configuration
@throws ConfigurationException if ambiguous configurations are found
@see com.hazelcast.partition.strategy.StringPartitioningStrategy#getBaseName(java.lang.String)
@see #setConfigPatternMatcher(ConfigPatternMatcher)
@see #getConfigPatternMatcher() | [
"Returns",
"the",
"{",
"@link",
"FlakeIdGeneratorConfig",
"}",
"for",
"the",
"given",
"name",
"creating",
"one",
"if",
"necessary",
"and",
"adding",
"it",
"to",
"the",
"collection",
"of",
"known",
"configurations",
".",
"<p",
">",
"The",
"configuration",
"is",
"found",
"by",
"matching",
"the",
"configuration",
"name",
"pattern",
"to",
"the",
"provided",
"{",
"@code",
"name",
"}",
"without",
"the",
"partition",
"qualifier",
"(",
"the",
"part",
"of",
"the",
"name",
"after",
"{",
"@code",
"@",
"}",
")",
".",
"If",
"no",
"configuration",
"matches",
"it",
"will",
"create",
"one",
"by",
"cloning",
"the",
"{",
"@code",
"default",
"}",
"configuration",
"and",
"add",
"it",
"to",
"the",
"configuration",
"collection",
".",
"<p",
">",
"This",
"method",
"is",
"intended",
"to",
"easily",
"and",
"fluently",
"create",
"and",
"add",
"configurations",
"more",
"specific",
"than",
"the",
"default",
"configuration",
"without",
"explicitly",
"adding",
"it",
"by",
"invoking",
"{",
"@link",
"#addFlakeIdGeneratorConfig",
"(",
"FlakeIdGeneratorConfig",
")",
"}",
".",
"<p",
">",
"Because",
"it",
"adds",
"new",
"configurations",
"if",
"they",
"are",
"not",
"already",
"present",
"this",
"method",
"is",
"intended",
"to",
"be",
"used",
"before",
"this",
"config",
"is",
"used",
"to",
"create",
"a",
"hazelcast",
"instance",
".",
"Afterwards",
"newly",
"added",
"configurations",
"may",
"be",
"ignored",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/Config.java#L3052-L3060 |
lucee/Lucee | core/src/main/java/lucee/runtime/op/Caster.java | Caster.toTimespan | public static TimeSpan toTimespan(Object o) throws PageException {
"""
cast a Object to a TimeSpan Object (alias for toTimeSpan)
@param o Object to cast
@return casted TimeSpan Object
@throws PageException
"""
TimeSpan ts = toTimespan(o, null);
if (ts != null) return ts;
throw new CasterException(o, "timespan");
} | java | public static TimeSpan toTimespan(Object o) throws PageException {
TimeSpan ts = toTimespan(o, null);
if (ts != null) return ts;
throw new CasterException(o, "timespan");
} | [
"public",
"static",
"TimeSpan",
"toTimespan",
"(",
"Object",
"o",
")",
"throws",
"PageException",
"{",
"TimeSpan",
"ts",
"=",
"toTimespan",
"(",
"o",
",",
"null",
")",
";",
"if",
"(",
"ts",
"!=",
"null",
")",
"return",
"ts",
";",
"throw",
"new",
"CasterException",
"(",
"o",
",",
"\"timespan\"",
")",
";",
"}"
] | cast a Object to a TimeSpan Object (alias for toTimeSpan)
@param o Object to cast
@return casted TimeSpan Object
@throws PageException | [
"cast",
"a",
"Object",
"to",
"a",
"TimeSpan",
"Object",
"(",
"alias",
"for",
"toTimeSpan",
")"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/op/Caster.java#L3224-L3229 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Short.java | Short.parseShort | public static short parseShort(String s, int radix)
throws NumberFormatException {
"""
Parses the string argument as a signed {@code short} in the
radix specified by the second argument. The characters in the
string must all be digits, of the specified radix (as
determined by whether {@link java.lang.Character#digit(char,
int)} returns a nonnegative value) except that the first
character may be an ASCII minus sign {@code '-'}
({@code '\u005Cu002D'}) to indicate a negative value or an
ASCII plus sign {@code '+'} ({@code '\u005Cu002B'}) to
indicate a positive value. The resulting {@code short} value
is returned.
<p>An exception of type {@code NumberFormatException} is
thrown if any of the following situations occurs:
<ul>
<li> The first argument is {@code null} or is a string of
length zero.
<li> The radix is either smaller than {@link
java.lang.Character#MIN_RADIX} or larger than {@link
java.lang.Character#MAX_RADIX}.
<li> Any character of the string is not a digit of the
specified radix, except that the first character may be a minus
sign {@code '-'} ({@code '\u005Cu002D'}) or plus sign
{@code '+'} ({@code '\u005Cu002B'}) provided that the
string is longer than length 1.
<li> The value represented by the string is not a value of type
{@code short}.
</ul>
@param s the {@code String} containing the
{@code short} representation to be parsed
@param radix the radix to be used while parsing {@code s}
@return the {@code short} represented by the string
argument in the specified radix.
@throws NumberFormatException If the {@code String}
does not contain a parsable {@code short}.
"""
int i = Integer.parseInt(s, radix);
if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException(
"Value out of range. Value:\"" + s + "\" Radix:" + radix);
return (short)i;
} | java | public static short parseShort(String s, int radix)
throws NumberFormatException {
int i = Integer.parseInt(s, radix);
if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException(
"Value out of range. Value:\"" + s + "\" Radix:" + radix);
return (short)i;
} | [
"public",
"static",
"short",
"parseShort",
"(",
"String",
"s",
",",
"int",
"radix",
")",
"throws",
"NumberFormatException",
"{",
"int",
"i",
"=",
"Integer",
".",
"parseInt",
"(",
"s",
",",
"radix",
")",
";",
"if",
"(",
"i",
"<",
"MIN_VALUE",
"||",
"i",
">",
"MAX_VALUE",
")",
"throw",
"new",
"NumberFormatException",
"(",
"\"Value out of range. Value:\\\"\"",
"+",
"s",
"+",
"\"\\\" Radix:\"",
"+",
"radix",
")",
";",
"return",
"(",
"short",
")",
"i",
";",
"}"
] | Parses the string argument as a signed {@code short} in the
radix specified by the second argument. The characters in the
string must all be digits, of the specified radix (as
determined by whether {@link java.lang.Character#digit(char,
int)} returns a nonnegative value) except that the first
character may be an ASCII minus sign {@code '-'}
({@code '\u005Cu002D'}) to indicate a negative value or an
ASCII plus sign {@code '+'} ({@code '\u005Cu002B'}) to
indicate a positive value. The resulting {@code short} value
is returned.
<p>An exception of type {@code NumberFormatException} is
thrown if any of the following situations occurs:
<ul>
<li> The first argument is {@code null} or is a string of
length zero.
<li> The radix is either smaller than {@link
java.lang.Character#MIN_RADIX} or larger than {@link
java.lang.Character#MAX_RADIX}.
<li> Any character of the string is not a digit of the
specified radix, except that the first character may be a minus
sign {@code '-'} ({@code '\u005Cu002D'}) or plus sign
{@code '+'} ({@code '\u005Cu002B'}) provided that the
string is longer than length 1.
<li> The value represented by the string is not a value of type
{@code short}.
</ul>
@param s the {@code String} containing the
{@code short} representation to be parsed
@param radix the radix to be used while parsing {@code s}
@return the {@code short} represented by the string
argument in the specified radix.
@throws NumberFormatException If the {@code String}
does not contain a parsable {@code short}. | [
"Parses",
"the",
"string",
"argument",
"as",
"a",
"signed",
"{",
"@code",
"short",
"}",
"in",
"the",
"radix",
"specified",
"by",
"the",
"second",
"argument",
".",
"The",
"characters",
"in",
"the",
"string",
"must",
"all",
"be",
"digits",
"of",
"the",
"specified",
"radix",
"(",
"as",
"determined",
"by",
"whether",
"{",
"@link",
"java",
".",
"lang",
".",
"Character#digit",
"(",
"char",
"int",
")",
"}",
"returns",
"a",
"nonnegative",
"value",
")",
"except",
"that",
"the",
"first",
"character",
"may",
"be",
"an",
"ASCII",
"minus",
"sign",
"{",
"@code",
"-",
"}",
"(",
"{",
"@code",
"\\",
"u005Cu002D",
"}",
")",
"to",
"indicate",
"a",
"negative",
"value",
"or",
"an",
"ASCII",
"plus",
"sign",
"{",
"@code",
"+",
"}",
"(",
"{",
"@code",
"\\",
"u005Cu002B",
"}",
")",
"to",
"indicate",
"a",
"positive",
"value",
".",
"The",
"resulting",
"{",
"@code",
"short",
"}",
"value",
"is",
"returned",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Short.java#L117-L124 |
LGoodDatePicker/LGoodDatePicker | Project/src/main/java/com/github/lgooddatepicker/components/TimePickerSettings.java | TimePickerSettings.zApplyMinimumToggleTimeMenuButtonWidthInPixels | void zApplyMinimumToggleTimeMenuButtonWidthInPixels() {
"""
zApplyMinimumToggleTimeMenuButtonWidthInPixels, This applies the specified setting to the
time picker.
"""
if (parent == null) {
return;
}
Dimension menuButtonPreferredSize = parent.getComponentToggleTimeMenuButton().getPreferredSize();
int width = menuButtonPreferredSize.width;
int height = menuButtonPreferredSize.height;
int minimumWidth = minimumToggleTimeMenuButtonWidthInPixels;
width = (width < minimumWidth) ? minimumWidth : width;
Dimension newSize = new Dimension(width, height);
parent.getComponentToggleTimeMenuButton().setPreferredSize(newSize);
} | java | void zApplyMinimumToggleTimeMenuButtonWidthInPixels() {
if (parent == null) {
return;
}
Dimension menuButtonPreferredSize = parent.getComponentToggleTimeMenuButton().getPreferredSize();
int width = menuButtonPreferredSize.width;
int height = menuButtonPreferredSize.height;
int minimumWidth = minimumToggleTimeMenuButtonWidthInPixels;
width = (width < minimumWidth) ? minimumWidth : width;
Dimension newSize = new Dimension(width, height);
parent.getComponentToggleTimeMenuButton().setPreferredSize(newSize);
} | [
"void",
"zApplyMinimumToggleTimeMenuButtonWidthInPixels",
"(",
")",
"{",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Dimension",
"menuButtonPreferredSize",
"=",
"parent",
".",
"getComponentToggleTimeMenuButton",
"(",
")",
".",
"getPreferredSize",
"(",
")",
";",
"int",
"width",
"=",
"menuButtonPreferredSize",
".",
"width",
";",
"int",
"height",
"=",
"menuButtonPreferredSize",
".",
"height",
";",
"int",
"minimumWidth",
"=",
"minimumToggleTimeMenuButtonWidthInPixels",
";",
"width",
"=",
"(",
"width",
"<",
"minimumWidth",
")",
"?",
"minimumWidth",
":",
"width",
";",
"Dimension",
"newSize",
"=",
"new",
"Dimension",
"(",
"width",
",",
"height",
")",
";",
"parent",
".",
"getComponentToggleTimeMenuButton",
"(",
")",
".",
"setPreferredSize",
"(",
"newSize",
")",
";",
"}"
] | zApplyMinimumToggleTimeMenuButtonWidthInPixels, This applies the specified setting to the
time picker. | [
"zApplyMinimumToggleTimeMenuButtonWidthInPixels",
"This",
"applies",
"the",
"specified",
"setting",
"to",
"the",
"time",
"picker",
"."
] | train | https://github.com/LGoodDatePicker/LGoodDatePicker/blob/c7df05a5fe382e1e08a6237e9391d8dc5fd48692/Project/src/main/java/com/github/lgooddatepicker/components/TimePickerSettings.java#L980-L991 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/util/DateUtil.java | DateUtil.fromISO8601 | public static Date fromISO8601(String pDateString) {
"""
Parse an ISO-8601 string into an date object
@param pDateString date string to parse
@return the parse date
@throws IllegalArgumentException if the provided string does not conform to ISO-8601
"""
if (datatypeFactory != null) {
return datatypeFactory.newXMLGregorianCalendar(pDateString.trim()).toGregorianCalendar().getTime();
} else {
try {
// Try on our own, works for most cases
String date = pDateString.replaceFirst("([+-])(0\\d)\\:(\\d{2})$", "$1$2$3");
date = date.replaceFirst("Z$","+0000");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
return dateFormat.parse(date);
} catch (ParseException e) {
throw new IllegalArgumentException("Cannot parse date '" + pDateString + "': " +e,e);
}
}
} | java | public static Date fromISO8601(String pDateString) {
if (datatypeFactory != null) {
return datatypeFactory.newXMLGregorianCalendar(pDateString.trim()).toGregorianCalendar().getTime();
} else {
try {
// Try on our own, works for most cases
String date = pDateString.replaceFirst("([+-])(0\\d)\\:(\\d{2})$", "$1$2$3");
date = date.replaceFirst("Z$","+0000");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
return dateFormat.parse(date);
} catch (ParseException e) {
throw new IllegalArgumentException("Cannot parse date '" + pDateString + "': " +e,e);
}
}
} | [
"public",
"static",
"Date",
"fromISO8601",
"(",
"String",
"pDateString",
")",
"{",
"if",
"(",
"datatypeFactory",
"!=",
"null",
")",
"{",
"return",
"datatypeFactory",
".",
"newXMLGregorianCalendar",
"(",
"pDateString",
".",
"trim",
"(",
")",
")",
".",
"toGregorianCalendar",
"(",
")",
".",
"getTime",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"// Try on our own, works for most cases",
"String",
"date",
"=",
"pDateString",
".",
"replaceFirst",
"(",
"\"([+-])(0\\\\d)\\\\:(\\\\d{2})$\"",
",",
"\"$1$2$3\"",
")",
";",
"date",
"=",
"date",
".",
"replaceFirst",
"(",
"\"Z$\"",
",",
"\"+0000\"",
")",
";",
"SimpleDateFormat",
"dateFormat",
"=",
"new",
"SimpleDateFormat",
"(",
"\"yyyy-MM-dd'T'HH:mm:ssZ\"",
")",
";",
"return",
"dateFormat",
".",
"parse",
"(",
"date",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot parse date '\"",
"+",
"pDateString",
"+",
"\"': \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Parse an ISO-8601 string into an date object
@param pDateString date string to parse
@return the parse date
@throws IllegalArgumentException if the provided string does not conform to ISO-8601 | [
"Parse",
"an",
"ISO",
"-",
"8601",
"string",
"into",
"an",
"date",
"object"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/util/DateUtil.java#L55-L69 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java | DefaultInternalConfiguration.getSubProperties | public Properties getSubProperties(final String prefix, final boolean truncate) {
"""
Returns a sub-set of the parameters contained in this configuration.
@param prefix the prefix of the parameter keys which should be included.
@param truncate if true, the prefix is truncated in the returned properties.
@return the properties sub-set, may be empty.
"""
String cacheKey = truncate + prefix;
Properties sub = subcontextCache.get(cacheKey);
if (sub != null) {
// make a copy so users can't change.
Properties copy = new Properties();
copy.putAll(sub);
return copy;
}
sub = new Properties();
int length = prefix.length();
for (Map.Entry<String, Object> entry : backing.entrySet()) {
String key = entry.getKey();
if (key.startsWith(prefix)) {
// If we are truncating, remove the prefix
String newKey = key;
if (truncate) {
newKey = key.substring(length);
}
sub.setProperty(newKey, (String) entry.getValue());
}
}
subcontextCache.put(cacheKey, sub);
// Make a copy so users can't change.
Properties copy = new Properties();
copy.putAll(sub);
return copy;
} | java | public Properties getSubProperties(final String prefix, final boolean truncate) {
String cacheKey = truncate + prefix;
Properties sub = subcontextCache.get(cacheKey);
if (sub != null) {
// make a copy so users can't change.
Properties copy = new Properties();
copy.putAll(sub);
return copy;
}
sub = new Properties();
int length = prefix.length();
for (Map.Entry<String, Object> entry : backing.entrySet()) {
String key = entry.getKey();
if (key.startsWith(prefix)) {
// If we are truncating, remove the prefix
String newKey = key;
if (truncate) {
newKey = key.substring(length);
}
sub.setProperty(newKey, (String) entry.getValue());
}
}
subcontextCache.put(cacheKey, sub);
// Make a copy so users can't change.
Properties copy = new Properties();
copy.putAll(sub);
return copy;
} | [
"public",
"Properties",
"getSubProperties",
"(",
"final",
"String",
"prefix",
",",
"final",
"boolean",
"truncate",
")",
"{",
"String",
"cacheKey",
"=",
"truncate",
"+",
"prefix",
";",
"Properties",
"sub",
"=",
"subcontextCache",
".",
"get",
"(",
"cacheKey",
")",
";",
"if",
"(",
"sub",
"!=",
"null",
")",
"{",
"// make a copy so users can't change.",
"Properties",
"copy",
"=",
"new",
"Properties",
"(",
")",
";",
"copy",
".",
"putAll",
"(",
"sub",
")",
";",
"return",
"copy",
";",
"}",
"sub",
"=",
"new",
"Properties",
"(",
")",
";",
"int",
"length",
"=",
"prefix",
".",
"length",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"backing",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"key",
".",
"startsWith",
"(",
"prefix",
")",
")",
"{",
"// If we are truncating, remove the prefix",
"String",
"newKey",
"=",
"key",
";",
"if",
"(",
"truncate",
")",
"{",
"newKey",
"=",
"key",
".",
"substring",
"(",
"length",
")",
";",
"}",
"sub",
".",
"setProperty",
"(",
"newKey",
",",
"(",
"String",
")",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"subcontextCache",
".",
"put",
"(",
"cacheKey",
",",
"sub",
")",
";",
"// Make a copy so users can't change.",
"Properties",
"copy",
"=",
"new",
"Properties",
"(",
")",
";",
"copy",
".",
"putAll",
"(",
"sub",
")",
";",
"return",
"copy",
";",
"}"
] | Returns a sub-set of the parameters contained in this configuration.
@param prefix the prefix of the parameter keys which should be included.
@param truncate if true, the prefix is truncated in the returned properties.
@return the properties sub-set, may be empty. | [
"Returns",
"a",
"sub",
"-",
"set",
"of",
"the",
"parameters",
"contained",
"in",
"this",
"configuration",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/DefaultInternalConfiguration.java#L633-L671 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfSigGenericPKCS.java | PdfSigGenericPKCS.setExternalDigest | public void setExternalDigest(byte digest[], byte RSAdata[], String digestEncryptionAlgorithm) {
"""
Sets the digest/signature to an external calculated value.
@param digest the digest. This is the actual signature
@param RSAdata the extra data that goes into the data tag in PKCS#7
@param digestEncryptionAlgorithm the encryption algorithm. It may must be <CODE>null</CODE> if the <CODE>digest</CODE>
is also <CODE>null</CODE>. If the <CODE>digest</CODE> is not <CODE>null</CODE>
then it may be "RSA" or "DSA"
"""
externalDigest = digest;
externalRSAdata = RSAdata;
this.digestEncryptionAlgorithm = digestEncryptionAlgorithm;
} | java | public void setExternalDigest(byte digest[], byte RSAdata[], String digestEncryptionAlgorithm) {
externalDigest = digest;
externalRSAdata = RSAdata;
this.digestEncryptionAlgorithm = digestEncryptionAlgorithm;
} | [
"public",
"void",
"setExternalDigest",
"(",
"byte",
"digest",
"[",
"]",
",",
"byte",
"RSAdata",
"[",
"]",
",",
"String",
"digestEncryptionAlgorithm",
")",
"{",
"externalDigest",
"=",
"digest",
";",
"externalRSAdata",
"=",
"RSAdata",
";",
"this",
".",
"digestEncryptionAlgorithm",
"=",
"digestEncryptionAlgorithm",
";",
"}"
] | Sets the digest/signature to an external calculated value.
@param digest the digest. This is the actual signature
@param RSAdata the extra data that goes into the data tag in PKCS#7
@param digestEncryptionAlgorithm the encryption algorithm. It may must be <CODE>null</CODE> if the <CODE>digest</CODE>
is also <CODE>null</CODE>. If the <CODE>digest</CODE> is not <CODE>null</CODE>
then it may be "RSA" or "DSA" | [
"Sets",
"the",
"digest",
"/",
"signature",
"to",
"an",
"external",
"calculated",
"value",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfSigGenericPKCS.java#L130-L134 |
cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/persist/TransactionEdit.java | TransactionEdit.createCheckpoint | public static TransactionEdit createCheckpoint(long writePointer, long parentWritePointer) {
"""
Creates a new instance in the {@link State#CHECKPOINT} state.
"""
return new TransactionEdit(writePointer, 0L, State.CHECKPOINT, 0L, null, 0L, false, null, null, 0L,
parentWritePointer, null);
} | java | public static TransactionEdit createCheckpoint(long writePointer, long parentWritePointer) {
return new TransactionEdit(writePointer, 0L, State.CHECKPOINT, 0L, null, 0L, false, null, null, 0L,
parentWritePointer, null);
} | [
"public",
"static",
"TransactionEdit",
"createCheckpoint",
"(",
"long",
"writePointer",
",",
"long",
"parentWritePointer",
")",
"{",
"return",
"new",
"TransactionEdit",
"(",
"writePointer",
",",
"0L",
",",
"State",
".",
"CHECKPOINT",
",",
"0L",
",",
"null",
",",
"0L",
",",
"false",
",",
"null",
",",
"null",
",",
"0L",
",",
"parentWritePointer",
",",
"null",
")",
";",
"}"
] | Creates a new instance in the {@link State#CHECKPOINT} state. | [
"Creates",
"a",
"new",
"instance",
"in",
"the",
"{"
] | train | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/persist/TransactionEdit.java#L294-L297 |
dbracewell/hermes | hermes-core/src/main/java/com/davidbracewell/hermes/DocumentFactory.java | DocumentFactory.createRaw | public Document createRaw(@NonNull String content, @NonNull Language language) {
"""
Creates a document with the given content written in the given language. This method does not apply any {@link
TextNormalizer}
@param content the content
@param language the language
@return the document
"""
return createRaw("", content, language, Collections.emptyMap());
} | java | public Document createRaw(@NonNull String content, @NonNull Language language) {
return createRaw("", content, language, Collections.emptyMap());
} | [
"public",
"Document",
"createRaw",
"(",
"@",
"NonNull",
"String",
"content",
",",
"@",
"NonNull",
"Language",
"language",
")",
"{",
"return",
"createRaw",
"(",
"\"\"",
",",
"content",
",",
"language",
",",
"Collections",
".",
"emptyMap",
"(",
")",
")",
";",
"}"
] | Creates a document with the given content written in the given language. This method does not apply any {@link
TextNormalizer}
@param content the content
@param language the language
@return the document | [
"Creates",
"a",
"document",
"with",
"the",
"given",
"content",
"written",
"in",
"the",
"given",
"language",
".",
"This",
"method",
"does",
"not",
"apply",
"any",
"{",
"@link",
"TextNormalizer",
"}"
] | train | https://github.com/dbracewell/hermes/blob/9ebefe7ad5dea1b731ae6931a30771eb75325ea3/hermes-core/src/main/java/com/davidbracewell/hermes/DocumentFactory.java#L205-L207 |
UrielCh/ovh-java-sdk | ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java | ApiOvhHostingweb.serviceName_envVar_key_PUT | public void serviceName_envVar_key_PUT(String serviceName, String key, OvhEnvVar body) throws IOException {
"""
Alter this object properties
REST: PUT /hosting/web/{serviceName}/envVar/{key}
@param body [required] New object properties
@param serviceName [required] The internal name of your hosting
@param key [required] Name of the variable
"""
String qPath = "/hosting/web/{serviceName}/envVar/{key}";
StringBuilder sb = path(qPath, serviceName, key);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_envVar_key_PUT(String serviceName, String key, OvhEnvVar body) throws IOException {
String qPath = "/hosting/web/{serviceName}/envVar/{key}";
StringBuilder sb = path(qPath, serviceName, key);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_envVar_key_PUT",
"(",
"String",
"serviceName",
",",
"String",
"key",
",",
"OvhEnvVar",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/hosting/web/{serviceName}/envVar/{key}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"key",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /hosting/web/{serviceName}/envVar/{key}
@param body [required] New object properties
@param serviceName [required] The internal name of your hosting
@param key [required] Name of the variable | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java#L1787-L1791 |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.symmLowerToFull | public static void symmLowerToFull( DMatrixSparseCSC A , DMatrixSparseCSC B , @Nullable IGrowArray gw ) {
"""
Given a symmetric matrix, which is represented by a lower triangular matrix, convert it back into
a full symmetric matrix
@param A (Input) Lower triangular matrix
@param B (Output) Symmetric matrix.
@param gw (Optional) Workspace. Can be null.
"""
ImplCommonOps_DSCC.symmLowerToFull(A, B, gw);
} | java | public static void symmLowerToFull( DMatrixSparseCSC A , DMatrixSparseCSC B , @Nullable IGrowArray gw )
{
ImplCommonOps_DSCC.symmLowerToFull(A, B, gw);
} | [
"public",
"static",
"void",
"symmLowerToFull",
"(",
"DMatrixSparseCSC",
"A",
",",
"DMatrixSparseCSC",
"B",
",",
"@",
"Nullable",
"IGrowArray",
"gw",
")",
"{",
"ImplCommonOps_DSCC",
".",
"symmLowerToFull",
"(",
"A",
",",
"B",
",",
"gw",
")",
";",
"}"
] | Given a symmetric matrix, which is represented by a lower triangular matrix, convert it back into
a full symmetric matrix
@param A (Input) Lower triangular matrix
@param B (Output) Symmetric matrix.
@param gw (Optional) Workspace. Can be null. | [
"Given",
"a",
"symmetric",
"matrix",
"which",
"is",
"represented",
"by",
"a",
"lower",
"triangular",
"matrix",
"convert",
"it",
"back",
"into",
"a",
"full",
"symmetric",
"matrix"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L323-L326 |
codelibs/jcifs | src/main/java/jcifs/smb1/netbios/NbtAddress.java | NbtAddress.getAllByAddress | public static NbtAddress[] getAllByAddress( String host,
int type,
String scope )
throws UnknownHostException {
"""
Retrieve all addresses of a host by it's address. NetBIOS hosts can
have many names for a given IP address. The name and IP address make
the NetBIOS address. This provides a way to retrieve the other names
for a host with the same IP address. See {@link #getByName}
for a description of <code>type</code>
and <code>scope</code>.
@param host hostname to lookup all addresses for
@param type the hexcode of the name
@param scope the scope of the name
@throws java.net.UnknownHostException if there is an error resolving the name
"""
return getAllByAddress( getByName( host, type, scope ));
} | java | public static NbtAddress[] getAllByAddress( String host,
int type,
String scope )
throws UnknownHostException {
return getAllByAddress( getByName( host, type, scope ));
} | [
"public",
"static",
"NbtAddress",
"[",
"]",
"getAllByAddress",
"(",
"String",
"host",
",",
"int",
"type",
",",
"String",
"scope",
")",
"throws",
"UnknownHostException",
"{",
"return",
"getAllByAddress",
"(",
"getByName",
"(",
"host",
",",
"type",
",",
"scope",
")",
")",
";",
"}"
] | Retrieve all addresses of a host by it's address. NetBIOS hosts can
have many names for a given IP address. The name and IP address make
the NetBIOS address. This provides a way to retrieve the other names
for a host with the same IP address. See {@link #getByName}
for a description of <code>type</code>
and <code>scope</code>.
@param host hostname to lookup all addresses for
@param type the hexcode of the name
@param scope the scope of the name
@throws java.net.UnknownHostException if there is an error resolving the name | [
"Retrieve",
"all",
"addresses",
"of",
"a",
"host",
"by",
"it",
"s",
"address",
".",
"NetBIOS",
"hosts",
"can",
"have",
"many",
"names",
"for",
"a",
"given",
"IP",
"address",
".",
"The",
"name",
"and",
"IP",
"address",
"make",
"the",
"NetBIOS",
"address",
".",
"This",
"provides",
"a",
"way",
"to",
"retrieve",
"the",
"other",
"names",
"for",
"a",
"host",
"with",
"the",
"same",
"IP",
"address",
".",
"See",
"{",
"@link",
"#getByName",
"}",
"for",
"a",
"description",
"of",
"<code",
">",
"type<",
"/",
"code",
">",
"and",
"<code",
">",
"scope<",
"/",
"code",
">",
"."
] | train | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/netbios/NbtAddress.java#L499-L504 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreException.java | DatastoreException.translateAndThrow | static DatastoreException translateAndThrow(RetryHelperException ex) {
"""
Translate RetryHelperException to the DatastoreException that caused the error. This method
will always throw an exception.
@throws DatastoreException when {@code ex} was caused by a {@code DatastoreException}
"""
BaseServiceException.translate(ex);
throw new DatastoreException(UNKNOWN_CODE, ex.getMessage(), null, ex.getCause());
} | java | static DatastoreException translateAndThrow(RetryHelperException ex) {
BaseServiceException.translate(ex);
throw new DatastoreException(UNKNOWN_CODE, ex.getMessage(), null, ex.getCause());
} | [
"static",
"DatastoreException",
"translateAndThrow",
"(",
"RetryHelperException",
"ex",
")",
"{",
"BaseServiceException",
".",
"translate",
"(",
"ex",
")",
";",
"throw",
"new",
"DatastoreException",
"(",
"UNKNOWN_CODE",
",",
"ex",
".",
"getMessage",
"(",
")",
",",
"null",
",",
"ex",
".",
"getCause",
"(",
")",
")",
";",
"}"
] | Translate RetryHelperException to the DatastoreException that caused the error. This method
will always throw an exception.
@throws DatastoreException when {@code ex} was caused by a {@code DatastoreException} | [
"Translate",
"RetryHelperException",
"to",
"the",
"DatastoreException",
"that",
"caused",
"the",
"error",
".",
"This",
"method",
"will",
"always",
"throw",
"an",
"exception",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreException.java#L65-L68 |
JodaOrg/joda-convert | src/main/java/org/joda/convert/StringConvert.java | StringConvert.tryRegister | private void tryRegister(String className, String fromStringMethodName) throws ClassNotFoundException {
"""
Tries to register a class using the standard toString/parse pattern.
@param className the class name, not null
@throws ClassNotFoundException if the class does not exist
"""
Class<?> cls = loadType(className);
registerMethods(cls, "toString", fromStringMethodName);
} | java | private void tryRegister(String className, String fromStringMethodName) throws ClassNotFoundException {
Class<?> cls = loadType(className);
registerMethods(cls, "toString", fromStringMethodName);
} | [
"private",
"void",
"tryRegister",
"(",
"String",
"className",
",",
"String",
"fromStringMethodName",
")",
"throws",
"ClassNotFoundException",
"{",
"Class",
"<",
"?",
">",
"cls",
"=",
"loadType",
"(",
"className",
")",
";",
"registerMethods",
"(",
"cls",
",",
"\"toString\"",
",",
"fromStringMethodName",
")",
";",
"}"
] | Tries to register a class using the standard toString/parse pattern.
@param className the class name, not null
@throws ClassNotFoundException if the class does not exist | [
"Tries",
"to",
"register",
"a",
"class",
"using",
"the",
"standard",
"toString",
"/",
"parse",
"pattern",
"."
] | train | https://github.com/JodaOrg/joda-convert/blob/266bd825f4550590d5dafdf4225c548559e0633b/src/main/java/org/joda/convert/StringConvert.java#L387-L390 |
joniles/mpxj | src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java | ProjectTreeController.addCalendar | private void addCalendar(MpxjTreeNode parentNode, final ProjectCalendar calendar) {
"""
Add a calendar node.
@param parentNode parent node
@param calendar calendar
"""
MpxjTreeNode calendarNode = new MpxjTreeNode(calendar, CALENDAR_EXCLUDED_METHODS)
{
@Override public String toString()
{
return calendar.getName();
}
};
parentNode.add(calendarNode);
MpxjTreeNode daysFolder = new MpxjTreeNode("Days");
calendarNode.add(daysFolder);
for (Day day : Day.values())
{
addCalendarDay(daysFolder, calendar, day);
}
MpxjTreeNode exceptionsFolder = new MpxjTreeNode("Exceptions");
calendarNode.add(exceptionsFolder);
for (ProjectCalendarException exception : calendar.getCalendarExceptions())
{
addCalendarException(exceptionsFolder, exception);
}
} | java | private void addCalendar(MpxjTreeNode parentNode, final ProjectCalendar calendar)
{
MpxjTreeNode calendarNode = new MpxjTreeNode(calendar, CALENDAR_EXCLUDED_METHODS)
{
@Override public String toString()
{
return calendar.getName();
}
};
parentNode.add(calendarNode);
MpxjTreeNode daysFolder = new MpxjTreeNode("Days");
calendarNode.add(daysFolder);
for (Day day : Day.values())
{
addCalendarDay(daysFolder, calendar, day);
}
MpxjTreeNode exceptionsFolder = new MpxjTreeNode("Exceptions");
calendarNode.add(exceptionsFolder);
for (ProjectCalendarException exception : calendar.getCalendarExceptions())
{
addCalendarException(exceptionsFolder, exception);
}
} | [
"private",
"void",
"addCalendar",
"(",
"MpxjTreeNode",
"parentNode",
",",
"final",
"ProjectCalendar",
"calendar",
")",
"{",
"MpxjTreeNode",
"calendarNode",
"=",
"new",
"MpxjTreeNode",
"(",
"calendar",
",",
"CALENDAR_EXCLUDED_METHODS",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"calendar",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"calendarNode",
")",
";",
"MpxjTreeNode",
"daysFolder",
"=",
"new",
"MpxjTreeNode",
"(",
"\"Days\"",
")",
";",
"calendarNode",
".",
"add",
"(",
"daysFolder",
")",
";",
"for",
"(",
"Day",
"day",
":",
"Day",
".",
"values",
"(",
")",
")",
"{",
"addCalendarDay",
"(",
"daysFolder",
",",
"calendar",
",",
"day",
")",
";",
"}",
"MpxjTreeNode",
"exceptionsFolder",
"=",
"new",
"MpxjTreeNode",
"(",
"\"Exceptions\"",
")",
";",
"calendarNode",
".",
"add",
"(",
"exceptionsFolder",
")",
";",
"for",
"(",
"ProjectCalendarException",
"exception",
":",
"calendar",
".",
"getCalendarExceptions",
"(",
")",
")",
"{",
"addCalendarException",
"(",
"exceptionsFolder",
",",
"exception",
")",
";",
"}",
"}"
] | Add a calendar node.
@param parentNode parent node
@param calendar calendar | [
"Add",
"a",
"calendar",
"node",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L257-L283 |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/PropertyImpl.java | PropertyImpl.compare | public double compare(String v1, String v2) {
"""
Returns the probability that the records v1 and v2 came from
represent the same entity, based on high and low probability
settings etc.
"""
// FIXME: it should be possible here to say that, actually, we
// didn't learn anything from comparing these two values, so that
// probability is set to 0.5.
if (comparator == null)
return 0.5; // we ignore properties with no comparator
// first, we call the comparator, to get a measure of how similar
// these two values are. note that this is not the same as what we
// are going to return, which is a probability.
double sim = comparator.compare(v1, v2);
// we have been configured with a high probability (for equal
// values) and a low probability (for different values). given
// sim, which is a measure of the similarity somewhere in between
// equal and different, we now compute our estimate of the
// probability.
// if sim = 1.0, we return high. if sim = 0.0, we return low. for
// values in between we need to compute a little. the obvious
// formula to use would be (sim * (high - low)) + low, which
// spreads the values out equally spaced between high and low.
// however, if the similarity is higher than 0.5 we don't want to
// consider this negative evidence, and so there's a threshold
// there. also, users felt Duke was too eager to merge records,
// and wanted probabilities to fall off faster with lower
// probabilities, and so we square sim in order to achieve this.
if (sim >= 0.5)
return ((high - 0.5) * (sim * sim)) + 0.5;
else
return low;
} | java | public double compare(String v1, String v2) {
// FIXME: it should be possible here to say that, actually, we
// didn't learn anything from comparing these two values, so that
// probability is set to 0.5.
if (comparator == null)
return 0.5; // we ignore properties with no comparator
// first, we call the comparator, to get a measure of how similar
// these two values are. note that this is not the same as what we
// are going to return, which is a probability.
double sim = comparator.compare(v1, v2);
// we have been configured with a high probability (for equal
// values) and a low probability (for different values). given
// sim, which is a measure of the similarity somewhere in between
// equal and different, we now compute our estimate of the
// probability.
// if sim = 1.0, we return high. if sim = 0.0, we return low. for
// values in between we need to compute a little. the obvious
// formula to use would be (sim * (high - low)) + low, which
// spreads the values out equally spaced between high and low.
// however, if the similarity is higher than 0.5 we don't want to
// consider this negative evidence, and so there's a threshold
// there. also, users felt Duke was too eager to merge records,
// and wanted probabilities to fall off faster with lower
// probabilities, and so we square sim in order to achieve this.
if (sim >= 0.5)
return ((high - 0.5) * (sim * sim)) + 0.5;
else
return low;
} | [
"public",
"double",
"compare",
"(",
"String",
"v1",
",",
"String",
"v2",
")",
"{",
"// FIXME: it should be possible here to say that, actually, we",
"// didn't learn anything from comparing these two values, so that",
"// probability is set to 0.5.",
"if",
"(",
"comparator",
"==",
"null",
")",
"return",
"0.5",
";",
"// we ignore properties with no comparator",
"// first, we call the comparator, to get a measure of how similar",
"// these two values are. note that this is not the same as what we",
"// are going to return, which is a probability.",
"double",
"sim",
"=",
"comparator",
".",
"compare",
"(",
"v1",
",",
"v2",
")",
";",
"// we have been configured with a high probability (for equal",
"// values) and a low probability (for different values). given",
"// sim, which is a measure of the similarity somewhere in between",
"// equal and different, we now compute our estimate of the",
"// probability.",
"// if sim = 1.0, we return high. if sim = 0.0, we return low. for",
"// values in between we need to compute a little. the obvious",
"// formula to use would be (sim * (high - low)) + low, which",
"// spreads the values out equally spaced between high and low.",
"// however, if the similarity is higher than 0.5 we don't want to",
"// consider this negative evidence, and so there's a threshold",
"// there. also, users felt Duke was too eager to merge records,",
"// and wanted probabilities to fall off faster with lower",
"// probabilities, and so we square sim in order to achieve this.",
"if",
"(",
"sim",
">=",
"0.5",
")",
"return",
"(",
"(",
"high",
"-",
"0.5",
")",
"*",
"(",
"sim",
"*",
"sim",
")",
")",
"+",
"0.5",
";",
"else",
"return",
"low",
";",
"}"
] | Returns the probability that the records v1 and v2 came from
represent the same entity, based on high and low probability
settings etc. | [
"Returns",
"the",
"probability",
"that",
"the",
"records",
"v1",
"and",
"v2",
"came",
"from",
"represent",
"the",
"same",
"entity",
"based",
"on",
"high",
"and",
"low",
"probability",
"settings",
"etc",
"."
] | train | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/PropertyImpl.java#L121-L155 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/Mapper.java | Mapper.keyAndValueNotNull | @SuppressWarnings("unchecked")
public Mapper<K, V> keyAndValueNotNull() {
"""
Add a constraint that verifies that neither the key nor the value is
null. If either is null, a {@link NullPointerException} is thrown.
@return
"""
return addConstraint((MapConstraint<K, V>) MapConstraints.notNull());
} | java | @SuppressWarnings("unchecked")
public Mapper<K, V> keyAndValueNotNull() {
return addConstraint((MapConstraint<K, V>) MapConstraints.notNull());
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Mapper",
"<",
"K",
",",
"V",
">",
"keyAndValueNotNull",
"(",
")",
"{",
"return",
"addConstraint",
"(",
"(",
"MapConstraint",
"<",
"K",
",",
"V",
">",
")",
"MapConstraints",
".",
"notNull",
"(",
")",
")",
";",
"}"
] | Add a constraint that verifies that neither the key nor the value is
null. If either is null, a {@link NullPointerException} is thrown.
@return | [
"Add",
"a",
"constraint",
"that",
"verifies",
"that",
"neither",
"the",
"key",
"nor",
"the",
"value",
"is",
"null",
".",
"If",
"either",
"is",
"null",
"a",
"{",
"@link",
"NullPointerException",
"}",
"is",
"thrown",
"."
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/Mapper.java#L113-L116 |
puniverse/galaxy | src/main/java/co/paralleluniverse/galaxy/Grid.java | Grid.getInstance | public static Grid getInstance(String configFile, Properties properties) throws InterruptedException {
"""
Retrieves the grid instance, as defined in the given configuration file.
@param configFile The name of the configuration file containing the grid definition.
@param properties A {@link Properties Properties} object containing the grid's properties to be injected into placeholders
in the configuration file.
This parameter is helpful when you want to use the same xml configuration with different properties for different
instances.
@return The grid instance.
"""
return getInstance(configFile == null ? null : new FileSystemResource(configFile), (Object) properties);
} | java | public static Grid getInstance(String configFile, Properties properties) throws InterruptedException {
return getInstance(configFile == null ? null : new FileSystemResource(configFile), (Object) properties);
} | [
"public",
"static",
"Grid",
"getInstance",
"(",
"String",
"configFile",
",",
"Properties",
"properties",
")",
"throws",
"InterruptedException",
"{",
"return",
"getInstance",
"(",
"configFile",
"==",
"null",
"?",
"null",
":",
"new",
"FileSystemResource",
"(",
"configFile",
")",
",",
"(",
"Object",
")",
"properties",
")",
";",
"}"
] | Retrieves the grid instance, as defined in the given configuration file.
@param configFile The name of the configuration file containing the grid definition.
@param properties A {@link Properties Properties} object containing the grid's properties to be injected into placeholders
in the configuration file.
This parameter is helpful when you want to use the same xml configuration with different properties for different
instances.
@return The grid instance. | [
"Retrieves",
"the",
"grid",
"instance",
"as",
"defined",
"in",
"the",
"given",
"configuration",
"file",
"."
] | train | https://github.com/puniverse/galaxy/blob/1d077532c4a5bcd6c52ff670770c31e98420ff63/src/main/java/co/paralleluniverse/galaxy/Grid.java#L73-L75 |
aws/aws-sdk-java | aws-java-sdk-cognitoidentity/src/main/java/com/amazonaws/services/cognitoidentity/model/DescribeIdentityPoolResult.java | DescribeIdentityPoolResult.withSupportedLoginProviders | public DescribeIdentityPoolResult withSupportedLoginProviders(java.util.Map<String, String> supportedLoginProviders) {
"""
<p>
Optional key:value pairs mapping provider names to provider app IDs.
</p>
@param supportedLoginProviders
Optional key:value pairs mapping provider names to provider app IDs.
@return Returns a reference to this object so that method calls can be chained together.
"""
setSupportedLoginProviders(supportedLoginProviders);
return this;
} | java | public DescribeIdentityPoolResult withSupportedLoginProviders(java.util.Map<String, String> supportedLoginProviders) {
setSupportedLoginProviders(supportedLoginProviders);
return this;
} | [
"public",
"DescribeIdentityPoolResult",
"withSupportedLoginProviders",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"supportedLoginProviders",
")",
"{",
"setSupportedLoginProviders",
"(",
"supportedLoginProviders",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Optional key:value pairs mapping provider names to provider app IDs.
</p>
@param supportedLoginProviders
Optional key:value pairs mapping provider names to provider app IDs.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Optional",
"key",
":",
"value",
"pairs",
"mapping",
"provider",
"names",
"to",
"provider",
"app",
"IDs",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cognitoidentity/src/main/java/com/amazonaws/services/cognitoidentity/model/DescribeIdentityPoolResult.java#L252-L255 |
microfocus-idol/java-parametric-databases | hod/src/main/java/com/hp/autonomy/hod/databases/AbstractResourceMapper.java | AbstractResourceMapper.databaseForResource | protected Database databaseForResource(final TokenProxy<?, TokenType.Simple> tokenProxy, final Resource resource, final String domain) throws HodErrorException {
"""
Converts the given resource name to a database
@param tokenProxy The token proxy to use to retrieve parametric fields
@param resource The resource
@param domain The domain of the resource
@return A database representation of the resource
@throws HodErrorException
"""
final ResourceIdentifier resourceIdentifier = new ResourceIdentifier(domain, resource.getResource());
final Set<String> parametricFields;
if (tokenProxy == null) {
parametricFields = indexFieldsService.getParametricFields(resourceIdentifier);
}
else {
parametricFields = indexFieldsService.getParametricFields(tokenProxy, resourceIdentifier);
}
return new Database.Builder()
.setName(resource.getResource())
.setDisplayName(resource.getDisplayName())
.setIsPublic(ResourceIdentifier.PUBLIC_INDEXES_DOMAIN.equals(domain))
.setDomain(domain)
.setIndexFields(parametricFields)
.build();
} | java | protected Database databaseForResource(final TokenProxy<?, TokenType.Simple> tokenProxy, final Resource resource, final String domain) throws HodErrorException {
final ResourceIdentifier resourceIdentifier = new ResourceIdentifier(domain, resource.getResource());
final Set<String> parametricFields;
if (tokenProxy == null) {
parametricFields = indexFieldsService.getParametricFields(resourceIdentifier);
}
else {
parametricFields = indexFieldsService.getParametricFields(tokenProxy, resourceIdentifier);
}
return new Database.Builder()
.setName(resource.getResource())
.setDisplayName(resource.getDisplayName())
.setIsPublic(ResourceIdentifier.PUBLIC_INDEXES_DOMAIN.equals(domain))
.setDomain(domain)
.setIndexFields(parametricFields)
.build();
} | [
"protected",
"Database",
"databaseForResource",
"(",
"final",
"TokenProxy",
"<",
"?",
",",
"TokenType",
".",
"Simple",
">",
"tokenProxy",
",",
"final",
"Resource",
"resource",
",",
"final",
"String",
"domain",
")",
"throws",
"HodErrorException",
"{",
"final",
"ResourceIdentifier",
"resourceIdentifier",
"=",
"new",
"ResourceIdentifier",
"(",
"domain",
",",
"resource",
".",
"getResource",
"(",
")",
")",
";",
"final",
"Set",
"<",
"String",
">",
"parametricFields",
";",
"if",
"(",
"tokenProxy",
"==",
"null",
")",
"{",
"parametricFields",
"=",
"indexFieldsService",
".",
"getParametricFields",
"(",
"resourceIdentifier",
")",
";",
"}",
"else",
"{",
"parametricFields",
"=",
"indexFieldsService",
".",
"getParametricFields",
"(",
"tokenProxy",
",",
"resourceIdentifier",
")",
";",
"}",
"return",
"new",
"Database",
".",
"Builder",
"(",
")",
".",
"setName",
"(",
"resource",
".",
"getResource",
"(",
")",
")",
".",
"setDisplayName",
"(",
"resource",
".",
"getDisplayName",
"(",
")",
")",
".",
"setIsPublic",
"(",
"ResourceIdentifier",
".",
"PUBLIC_INDEXES_DOMAIN",
".",
"equals",
"(",
"domain",
")",
")",
".",
"setDomain",
"(",
"domain",
")",
".",
"setIndexFields",
"(",
"parametricFields",
")",
".",
"build",
"(",
")",
";",
"}"
] | Converts the given resource name to a database
@param tokenProxy The token proxy to use to retrieve parametric fields
@param resource The resource
@param domain The domain of the resource
@return A database representation of the resource
@throws HodErrorException | [
"Converts",
"the",
"given",
"resource",
"name",
"to",
"a",
"database"
] | train | https://github.com/microfocus-idol/java-parametric-databases/blob/378a246a1857f911587106241712d16c2e118af2/hod/src/main/java/com/hp/autonomy/hod/databases/AbstractResourceMapper.java#L36-L54 |
netty/netty | codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2ConnectionHandlerBuilder.java | AbstractHttp2ConnectionHandlerBuilder.codec | protected B codec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder) {
"""
Sets the {@link Http2ConnectionDecoder} and {@link Http2ConnectionEncoder} to use.
"""
enforceConstraint("codec", "server", isServer);
enforceConstraint("codec", "maxReservedStreams", maxReservedStreams);
enforceConstraint("codec", "connection", connection);
enforceConstraint("codec", "frameLogger", frameLogger);
enforceConstraint("codec", "validateHeaders", validateHeaders);
enforceConstraint("codec", "headerSensitivityDetector", headerSensitivityDetector);
enforceConstraint("codec", "encoderEnforceMaxConcurrentStreams", encoderEnforceMaxConcurrentStreams);
checkNotNull(decoder, "decoder");
checkNotNull(encoder, "encoder");
if (decoder.connection() != encoder.connection()) {
throw new IllegalArgumentException("The specified encoder and decoder have different connections.");
}
this.decoder = decoder;
this.encoder = encoder;
return self();
} | java | protected B codec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder) {
enforceConstraint("codec", "server", isServer);
enforceConstraint("codec", "maxReservedStreams", maxReservedStreams);
enforceConstraint("codec", "connection", connection);
enforceConstraint("codec", "frameLogger", frameLogger);
enforceConstraint("codec", "validateHeaders", validateHeaders);
enforceConstraint("codec", "headerSensitivityDetector", headerSensitivityDetector);
enforceConstraint("codec", "encoderEnforceMaxConcurrentStreams", encoderEnforceMaxConcurrentStreams);
checkNotNull(decoder, "decoder");
checkNotNull(encoder, "encoder");
if (decoder.connection() != encoder.connection()) {
throw new IllegalArgumentException("The specified encoder and decoder have different connections.");
}
this.decoder = decoder;
this.encoder = encoder;
return self();
} | [
"protected",
"B",
"codec",
"(",
"Http2ConnectionDecoder",
"decoder",
",",
"Http2ConnectionEncoder",
"encoder",
")",
"{",
"enforceConstraint",
"(",
"\"codec\"",
",",
"\"server\"",
",",
"isServer",
")",
";",
"enforceConstraint",
"(",
"\"codec\"",
",",
"\"maxReservedStreams\"",
",",
"maxReservedStreams",
")",
";",
"enforceConstraint",
"(",
"\"codec\"",
",",
"\"connection\"",
",",
"connection",
")",
";",
"enforceConstraint",
"(",
"\"codec\"",
",",
"\"frameLogger\"",
",",
"frameLogger",
")",
";",
"enforceConstraint",
"(",
"\"codec\"",
",",
"\"validateHeaders\"",
",",
"validateHeaders",
")",
";",
"enforceConstraint",
"(",
"\"codec\"",
",",
"\"headerSensitivityDetector\"",
",",
"headerSensitivityDetector",
")",
";",
"enforceConstraint",
"(",
"\"codec\"",
",",
"\"encoderEnforceMaxConcurrentStreams\"",
",",
"encoderEnforceMaxConcurrentStreams",
")",
";",
"checkNotNull",
"(",
"decoder",
",",
"\"decoder\"",
")",
";",
"checkNotNull",
"(",
"encoder",
",",
"\"encoder\"",
")",
";",
"if",
"(",
"decoder",
".",
"connection",
"(",
")",
"!=",
"encoder",
".",
"connection",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The specified encoder and decoder have different connections.\"",
")",
";",
"}",
"this",
".",
"decoder",
"=",
"decoder",
";",
"this",
".",
"encoder",
"=",
"encoder",
";",
"return",
"self",
"(",
")",
";",
"}"
] | Sets the {@link Http2ConnectionDecoder} and {@link Http2ConnectionEncoder} to use. | [
"Sets",
"the",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2ConnectionHandlerBuilder.java#L254-L274 |
pandzel/RobotsTxt | src/main/java/com/panforge/robotstxt/RobotsTxtReader.java | RobotsTxtReader.parseEntry | private Entry parseEntry(String line) throws IOException {
"""
Parses line into entry.
<p>
Skip empty lines. Skip comments. Skip invalid lines.
@param line line to parse
@return entry or <code>null</code> if skipped
@throws IOException parsing line fails
"""
line = StringUtils.trimToEmpty(line);
if (line.startsWith("#")) {
return null;
}
int colonIndex = line.indexOf(":");
if (colonIndex < 0) {
return null;
}
String key = StringUtils.trimToNull(line.substring(0, colonIndex));
if (key == null) {
return null;
}
String rest = line.substring(colonIndex + 1, line.length());
int hashIndex = rest.indexOf("#");
String value = StringUtils.trimToEmpty(hashIndex >= 0 ? rest.substring(0, hashIndex) : rest);
value = decode(value);
return new Entry(line, key, value);
} | java | private Entry parseEntry(String line) throws IOException {
line = StringUtils.trimToEmpty(line);
if (line.startsWith("#")) {
return null;
}
int colonIndex = line.indexOf(":");
if (colonIndex < 0) {
return null;
}
String key = StringUtils.trimToNull(line.substring(0, colonIndex));
if (key == null) {
return null;
}
String rest = line.substring(colonIndex + 1, line.length());
int hashIndex = rest.indexOf("#");
String value = StringUtils.trimToEmpty(hashIndex >= 0 ? rest.substring(0, hashIndex) : rest);
value = decode(value);
return new Entry(line, key, value);
} | [
"private",
"Entry",
"parseEntry",
"(",
"String",
"line",
")",
"throws",
"IOException",
"{",
"line",
"=",
"StringUtils",
".",
"trimToEmpty",
"(",
"line",
")",
";",
"if",
"(",
"line",
".",
"startsWith",
"(",
"\"#\"",
")",
")",
"{",
"return",
"null",
";",
"}",
"int",
"colonIndex",
"=",
"line",
".",
"indexOf",
"(",
"\":\"",
")",
";",
"if",
"(",
"colonIndex",
"<",
"0",
")",
"{",
"return",
"null",
";",
"}",
"String",
"key",
"=",
"StringUtils",
".",
"trimToNull",
"(",
"line",
".",
"substring",
"(",
"0",
",",
"colonIndex",
")",
")",
";",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"rest",
"=",
"line",
".",
"substring",
"(",
"colonIndex",
"+",
"1",
",",
"line",
".",
"length",
"(",
")",
")",
";",
"int",
"hashIndex",
"=",
"rest",
".",
"indexOf",
"(",
"\"#\"",
")",
";",
"String",
"value",
"=",
"StringUtils",
".",
"trimToEmpty",
"(",
"hashIndex",
">=",
"0",
"?",
"rest",
".",
"substring",
"(",
"0",
",",
"hashIndex",
")",
":",
"rest",
")",
";",
"value",
"=",
"decode",
"(",
"value",
")",
";",
"return",
"new",
"Entry",
"(",
"line",
",",
"key",
",",
"value",
")",
";",
"}"
] | Parses line into entry.
<p>
Skip empty lines. Skip comments. Skip invalid lines.
@param line line to parse
@return entry or <code>null</code> if skipped
@throws IOException parsing line fails | [
"Parses",
"line",
"into",
"entry",
".",
"<p",
">",
"Skip",
"empty",
"lines",
".",
"Skip",
"comments",
".",
"Skip",
"invalid",
"lines",
"."
] | train | https://github.com/pandzel/RobotsTxt/blob/f5291d21675c87a97c0e77c37453cc112f8a12a9/src/main/java/com/panforge/robotstxt/RobotsTxtReader.java#L156-L180 |
ios-driver/ios-driver | server/src/main/java/org/uiautomation/ios/utils/SimulatorSettings.java | SimulatorSettings.setVariation | public void setVariation(DeviceType device, DeviceVariation variation, String desiredSDKVersion)
throws WebDriverException {
"""
update the preference to have the simulator start in the correct mode ( ie retina vs normal,
iphone screen size ).
"""
deviceName = AppleMagicString.getSimulateDeviceValue(device, variation, desiredSDKVersion, instrumentsVersion);
setDefaultSimulatorPreference("SimulateDevice", deviceName);
String subfolder = getSDKSubfolder(desiredSDKVersion);
File sdk = new File(info.getXCodeInstall(), subfolder);
if (!sdk.exists()) {
throw new WebDriverException(
"Cannot point simulator to requested sdk version " + sdk.getAbsolutePath());
}
setDefaultSimulatorPreference("currentSDKRoot", sdk.getAbsolutePath());
} | java | public void setVariation(DeviceType device, DeviceVariation variation, String desiredSDKVersion)
throws WebDriverException {
deviceName = AppleMagicString.getSimulateDeviceValue(device, variation, desiredSDKVersion, instrumentsVersion);
setDefaultSimulatorPreference("SimulateDevice", deviceName);
String subfolder = getSDKSubfolder(desiredSDKVersion);
File sdk = new File(info.getXCodeInstall(), subfolder);
if (!sdk.exists()) {
throw new WebDriverException(
"Cannot point simulator to requested sdk version " + sdk.getAbsolutePath());
}
setDefaultSimulatorPreference("currentSDKRoot", sdk.getAbsolutePath());
} | [
"public",
"void",
"setVariation",
"(",
"DeviceType",
"device",
",",
"DeviceVariation",
"variation",
",",
"String",
"desiredSDKVersion",
")",
"throws",
"WebDriverException",
"{",
"deviceName",
"=",
"AppleMagicString",
".",
"getSimulateDeviceValue",
"(",
"device",
",",
"variation",
",",
"desiredSDKVersion",
",",
"instrumentsVersion",
")",
";",
"setDefaultSimulatorPreference",
"(",
"\"SimulateDevice\"",
",",
"deviceName",
")",
";",
"String",
"subfolder",
"=",
"getSDKSubfolder",
"(",
"desiredSDKVersion",
")",
";",
"File",
"sdk",
"=",
"new",
"File",
"(",
"info",
".",
"getXCodeInstall",
"(",
")",
",",
"subfolder",
")",
";",
"if",
"(",
"!",
"sdk",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"WebDriverException",
"(",
"\"Cannot point simulator to requested sdk version \"",
"+",
"sdk",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"setDefaultSimulatorPreference",
"(",
"\"currentSDKRoot\"",
",",
"sdk",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}"
] | update the preference to have the simulator start in the correct mode ( ie retina vs normal,
iphone screen size ). | [
"update",
"the",
"preference",
"to",
"have",
"the",
"simulator",
"start",
"in",
"the",
"correct",
"mode",
"(",
"ie",
"retina",
"vs",
"normal",
"iphone",
"screen",
"size",
")",
"."
] | train | https://github.com/ios-driver/ios-driver/blob/a9744419508d970fbb1ce18e4326cc624b237c8b/server/src/main/java/org/uiautomation/ios/utils/SimulatorSettings.java#L178-L191 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachineScaleSetRollingUpgradesInner.java | VirtualMachineScaleSetRollingUpgradesInner.startOSUpgrade | public OperationStatusResponseInner startOSUpgrade(String resourceGroupName, String vmScaleSetName) {
"""
Starts a rolling upgrade to move all virtual machine scale set instances to the latest available Platform Image OS version. Instances which are already running the latest available OS version are not affected.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set.
@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 OperationStatusResponseInner object if successful.
"""
return startOSUpgradeWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().last().body();
} | java | public OperationStatusResponseInner startOSUpgrade(String resourceGroupName, String vmScaleSetName) {
return startOSUpgradeWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().last().body();
} | [
"public",
"OperationStatusResponseInner",
"startOSUpgrade",
"(",
"String",
"resourceGroupName",
",",
"String",
"vmScaleSetName",
")",
"{",
"return",
"startOSUpgradeWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vmScaleSetName",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Starts a rolling upgrade to move all virtual machine scale set instances to the latest available Platform Image OS version. Instances which are already running the latest available OS version are not affected.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set.
@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 OperationStatusResponseInner object if successful. | [
"Starts",
"a",
"rolling",
"upgrade",
"to",
"move",
"all",
"virtual",
"machine",
"scale",
"set",
"instances",
"to",
"the",
"latest",
"available",
"Platform",
"Image",
"OS",
"version",
".",
"Instances",
"which",
"are",
"already",
"running",
"the",
"latest",
"available",
"OS",
"version",
"are",
"not",
"affected",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachineScaleSetRollingUpgradesInner.java#L243-L245 |
hazelcast/hazelcast | hazelcast-client/src/main/java/com/hazelcast/client/config/ClientConfig.java | ClientConfig.setProperty | public ClientConfig setProperty(String name, String value) {
"""
Sets the value of a named property.
@param name property name
@param value value of the property
@return configured {@link com.hazelcast.client.config.ClientConfig} for chaining
"""
properties.put(name, value);
return this;
} | java | public ClientConfig setProperty(String name, String value) {
properties.put(name, value);
return this;
} | [
"public",
"ClientConfig",
"setProperty",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"properties",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Sets the value of a named property.
@param name property name
@param value value of the property
@return configured {@link com.hazelcast.client.config.ClientConfig} for chaining | [
"Sets",
"the",
"value",
"of",
"a",
"named",
"property",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/config/ClientConfig.java#L218-L221 |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/currency/CurrencyHelper.java | CurrencyHelper.getRounded | @Nonnull
public static BigDecimal getRounded (@Nullable final ECurrency eCurrency, @Nonnull final BigDecimal aValue) {
"""
Get the passed value rounded to the appropriate number of fraction digits,
based on this currencies default fraction digits.<br>
The default scaling of this currency is used.
@param eCurrency
The currency it is about. If <code>null</code> is provided
{@link #DEFAULT_CURRENCY} is used instead.
@param aValue
The value to be rounded. May not be <code>null</code>.
@return The rounded value. Never <code>null</code>.
"""
ValueEnforcer.notNull (aValue, "Value");
final PerCurrencySettings aPCS = getSettings (eCurrency);
return aValue.setScale (aPCS.getScale (), aPCS.getRoundingMode ());
} | java | @Nonnull
public static BigDecimal getRounded (@Nullable final ECurrency eCurrency, @Nonnull final BigDecimal aValue)
{
ValueEnforcer.notNull (aValue, "Value");
final PerCurrencySettings aPCS = getSettings (eCurrency);
return aValue.setScale (aPCS.getScale (), aPCS.getRoundingMode ());
} | [
"@",
"Nonnull",
"public",
"static",
"BigDecimal",
"getRounded",
"(",
"@",
"Nullable",
"final",
"ECurrency",
"eCurrency",
",",
"@",
"Nonnull",
"final",
"BigDecimal",
"aValue",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aValue",
",",
"\"Value\"",
")",
";",
"final",
"PerCurrencySettings",
"aPCS",
"=",
"getSettings",
"(",
"eCurrency",
")",
";",
"return",
"aValue",
".",
"setScale",
"(",
"aPCS",
".",
"getScale",
"(",
")",
",",
"aPCS",
".",
"getRoundingMode",
"(",
")",
")",
";",
"}"
] | Get the passed value rounded to the appropriate number of fraction digits,
based on this currencies default fraction digits.<br>
The default scaling of this currency is used.
@param eCurrency
The currency it is about. If <code>null</code> is provided
{@link #DEFAULT_CURRENCY} is used instead.
@param aValue
The value to be rounded. May not be <code>null</code>.
@return The rounded value. Never <code>null</code>. | [
"Get",
"the",
"passed",
"value",
"rounded",
"to",
"the",
"appropriate",
"number",
"of",
"fraction",
"digits",
"based",
"on",
"this",
"currencies",
"default",
"fraction",
"digits",
".",
"<br",
">",
"The",
"default",
"scaling",
"of",
"this",
"currency",
"is",
"used",
"."
] | train | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/currency/CurrencyHelper.java#L661-L667 |
Inbot/inbot-utils | src/main/java/io/inbot/utils/SimpleStringTrie.java | SimpleStringTrie.from | public static SimpleStringTrie from(Map<String,?> map) {
"""
Useful if you want to build a trie for an existing map so you can figure out a matching prefix that has an entry
@param map a map
@return a SimpleStringTrie for the map.
"""
SimpleStringTrie st = new SimpleStringTrie();
map.keySet().forEach(key -> st.add(key));
return st;
} | java | public static SimpleStringTrie from(Map<String,?> map) {
SimpleStringTrie st = new SimpleStringTrie();
map.keySet().forEach(key -> st.add(key));
return st;
} | [
"public",
"static",
"SimpleStringTrie",
"from",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"map",
")",
"{",
"SimpleStringTrie",
"st",
"=",
"new",
"SimpleStringTrie",
"(",
")",
";",
"map",
".",
"keySet",
"(",
")",
".",
"forEach",
"(",
"key",
"->",
"st",
".",
"add",
"(",
"key",
")",
")",
";",
"return",
"st",
";",
"}"
] | Useful if you want to build a trie for an existing map so you can figure out a matching prefix that has an entry
@param map a map
@return a SimpleStringTrie for the map. | [
"Useful",
"if",
"you",
"want",
"to",
"build",
"a",
"trie",
"for",
"an",
"existing",
"map",
"so",
"you",
"can",
"figure",
"out",
"a",
"matching",
"prefix",
"that",
"has",
"an",
"entry"
] | train | https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/SimpleStringTrie.java#L55-L59 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/view/facelets/tag/ui/DebugPhaseListener.java | DebugPhaseListener.createFieldDebugInfo | public static void createFieldDebugInfo(FacesContext facesContext,
final String field, Object oldValue,
Object newValue, String clientId) {
"""
Creates the field debug-info for the given field, which changed
from oldValue to newValue in the given component.
ATTENTION: this method is duplicate in UIInput.
@param facesContext
@param field
@param oldValue
@param newValue
@param clientId
"""
if ((oldValue == null && newValue == null)
|| (oldValue != null && oldValue.equals(newValue)))
{
// nothing changed - NOTE that this is a difference to the method in
// UIInput, because in UIInput every call to this method comes from
// setSubmittedValue or setLocalValue and here every call comes
// from the VisitCallback of the PhaseListener.
return;
}
// convert Array values into a more readable format
if (oldValue != null && oldValue.getClass().isArray())
{
oldValue = Arrays.deepToString((Object[]) oldValue);
}
if (newValue != null && newValue.getClass().isArray())
{
newValue = Arrays.deepToString((Object[]) newValue);
}
// NOTE that the call stack does not make much sence here
// create the debug-info array
// structure:
// - 0: phase
// - 1: old value
// - 2: new value
// - 3: StackTraceElement List
// NOTE that we cannot create a class here to encapsulate this data,
// because this is not on the spec and the class would not be available in impl.
Object[] debugInfo = new Object[4];
debugInfo[0] = facesContext.getCurrentPhaseId();
debugInfo[1] = oldValue;
debugInfo[2] = newValue;
debugInfo[3] = null; // here we have no call stack (only in UIInput)
// add the debug info
getFieldDebugInfos(field, clientId).add(debugInfo);
} | java | public static void createFieldDebugInfo(FacesContext facesContext,
final String field, Object oldValue,
Object newValue, String clientId)
{
if ((oldValue == null && newValue == null)
|| (oldValue != null && oldValue.equals(newValue)))
{
// nothing changed - NOTE that this is a difference to the method in
// UIInput, because in UIInput every call to this method comes from
// setSubmittedValue or setLocalValue and here every call comes
// from the VisitCallback of the PhaseListener.
return;
}
// convert Array values into a more readable format
if (oldValue != null && oldValue.getClass().isArray())
{
oldValue = Arrays.deepToString((Object[]) oldValue);
}
if (newValue != null && newValue.getClass().isArray())
{
newValue = Arrays.deepToString((Object[]) newValue);
}
// NOTE that the call stack does not make much sence here
// create the debug-info array
// structure:
// - 0: phase
// - 1: old value
// - 2: new value
// - 3: StackTraceElement List
// NOTE that we cannot create a class here to encapsulate this data,
// because this is not on the spec and the class would not be available in impl.
Object[] debugInfo = new Object[4];
debugInfo[0] = facesContext.getCurrentPhaseId();
debugInfo[1] = oldValue;
debugInfo[2] = newValue;
debugInfo[3] = null; // here we have no call stack (only in UIInput)
// add the debug info
getFieldDebugInfos(field, clientId).add(debugInfo);
} | [
"public",
"static",
"void",
"createFieldDebugInfo",
"(",
"FacesContext",
"facesContext",
",",
"final",
"String",
"field",
",",
"Object",
"oldValue",
",",
"Object",
"newValue",
",",
"String",
"clientId",
")",
"{",
"if",
"(",
"(",
"oldValue",
"==",
"null",
"&&",
"newValue",
"==",
"null",
")",
"||",
"(",
"oldValue",
"!=",
"null",
"&&",
"oldValue",
".",
"equals",
"(",
"newValue",
")",
")",
")",
"{",
"// nothing changed - NOTE that this is a difference to the method in ",
"// UIInput, because in UIInput every call to this method comes from",
"// setSubmittedValue or setLocalValue and here every call comes",
"// from the VisitCallback of the PhaseListener.",
"return",
";",
"}",
"// convert Array values into a more readable format",
"if",
"(",
"oldValue",
"!=",
"null",
"&&",
"oldValue",
".",
"getClass",
"(",
")",
".",
"isArray",
"(",
")",
")",
"{",
"oldValue",
"=",
"Arrays",
".",
"deepToString",
"(",
"(",
"Object",
"[",
"]",
")",
"oldValue",
")",
";",
"}",
"if",
"(",
"newValue",
"!=",
"null",
"&&",
"newValue",
".",
"getClass",
"(",
")",
".",
"isArray",
"(",
")",
")",
"{",
"newValue",
"=",
"Arrays",
".",
"deepToString",
"(",
"(",
"Object",
"[",
"]",
")",
"newValue",
")",
";",
"}",
"// NOTE that the call stack does not make much sence here",
"// create the debug-info array",
"// structure:",
"// - 0: phase",
"// - 1: old value",
"// - 2: new value",
"// - 3: StackTraceElement List",
"// NOTE that we cannot create a class here to encapsulate this data,",
"// because this is not on the spec and the class would not be available in impl.",
"Object",
"[",
"]",
"debugInfo",
"=",
"new",
"Object",
"[",
"4",
"]",
";",
"debugInfo",
"[",
"0",
"]",
"=",
"facesContext",
".",
"getCurrentPhaseId",
"(",
")",
";",
"debugInfo",
"[",
"1",
"]",
"=",
"oldValue",
";",
"debugInfo",
"[",
"2",
"]",
"=",
"newValue",
";",
"debugInfo",
"[",
"3",
"]",
"=",
"null",
";",
"// here we have no call stack (only in UIInput)",
"// add the debug info",
"getFieldDebugInfos",
"(",
"field",
",",
"clientId",
")",
".",
"add",
"(",
"debugInfo",
")",
";",
"}"
] | Creates the field debug-info for the given field, which changed
from oldValue to newValue in the given component.
ATTENTION: this method is duplicate in UIInput.
@param facesContext
@param field
@param oldValue
@param newValue
@param clientId | [
"Creates",
"the",
"field",
"debug",
"-",
"info",
"for",
"the",
"given",
"field",
"which",
"changed",
"from",
"oldValue",
"to",
"newValue",
"in",
"the",
"given",
"component",
".",
"ATTENTION",
":",
"this",
"method",
"is",
"duplicate",
"in",
"UIInput",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/view/facelets/tag/ui/DebugPhaseListener.java#L112-L154 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/xml/XmlIO.java | XmlIO.load | public static AnnotationMappingInfo load(final Reader reader) throws XmlOperateException {
"""
XMLを読み込み、{@link AnnotationMappingInfo}として取得する。
@since 0.5
@param reader
@return
@throws XmlOperateException XMLの読み込みに失敗した場合。
@throws IllegalArgumentException in is null.
"""
ArgUtils.notNull(reader, "reader");
final AnnotationMappingInfo xmlInfo;
try {
xmlInfo = JAXB.unmarshal(reader, AnnotationMappingInfo.class);
} catch (DataBindingException e) {
throw new XmlOperateException("fail load xml with JAXB.", e);
}
return xmlInfo;
} | java | public static AnnotationMappingInfo load(final Reader reader) throws XmlOperateException {
ArgUtils.notNull(reader, "reader");
final AnnotationMappingInfo xmlInfo;
try {
xmlInfo = JAXB.unmarshal(reader, AnnotationMappingInfo.class);
} catch (DataBindingException e) {
throw new XmlOperateException("fail load xml with JAXB.", e);
}
return xmlInfo;
} | [
"public",
"static",
"AnnotationMappingInfo",
"load",
"(",
"final",
"Reader",
"reader",
")",
"throws",
"XmlOperateException",
"{",
"ArgUtils",
".",
"notNull",
"(",
"reader",
",",
"\"reader\"",
")",
";",
"final",
"AnnotationMappingInfo",
"xmlInfo",
";",
"try",
"{",
"xmlInfo",
"=",
"JAXB",
".",
"unmarshal",
"(",
"reader",
",",
"AnnotationMappingInfo",
".",
"class",
")",
";",
"}",
"catch",
"(",
"DataBindingException",
"e",
")",
"{",
"throw",
"new",
"XmlOperateException",
"(",
"\"fail load xml with JAXB.\"",
",",
"e",
")",
";",
"}",
"return",
"xmlInfo",
";",
"}"
] | XMLを読み込み、{@link AnnotationMappingInfo}として取得する。
@since 0.5
@param reader
@return
@throws XmlOperateException XMLの読み込みに失敗した場合。
@throws IllegalArgumentException in is null. | [
"XMLを読み込み、",
"{"
] | train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/xml/XmlIO.java#L62-L74 |
Appendium/objectlabkit | utils/src/main/java/net/objectlab/kit/console/ConsoleMenu.java | ConsoleMenu.addMenuItem | public void addMenuItem(final String menuDisplay, final String methodName, final boolean repeat) {
"""
add an entry in the menu, sequentially
@param menuDisplay
how the entry will be displayed in the menu
@param methodName
name of the public method
@param repeat call back for repeat
"""
menu.add(menuDisplay);
methods.add(methodName);
askForRepeat.add(Boolean.valueOf(repeat));
} | java | public void addMenuItem(final String menuDisplay, final String methodName, final boolean repeat) {
menu.add(menuDisplay);
methods.add(methodName);
askForRepeat.add(Boolean.valueOf(repeat));
} | [
"public",
"void",
"addMenuItem",
"(",
"final",
"String",
"menuDisplay",
",",
"final",
"String",
"methodName",
",",
"final",
"boolean",
"repeat",
")",
"{",
"menu",
".",
"add",
"(",
"menuDisplay",
")",
";",
"methods",
".",
"add",
"(",
"methodName",
")",
";",
"askForRepeat",
".",
"add",
"(",
"Boolean",
".",
"valueOf",
"(",
"repeat",
")",
")",
";",
"}"
] | add an entry in the menu, sequentially
@param menuDisplay
how the entry will be displayed in the menu
@param methodName
name of the public method
@param repeat call back for repeat | [
"add",
"an",
"entry",
"in",
"the",
"menu",
"sequentially"
] | train | https://github.com/Appendium/objectlabkit/blob/cd649bce7a32e4e926520e62cb765f3b1d451594/utils/src/main/java/net/objectlab/kit/console/ConsoleMenu.java#L94-L98 |
foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java | DirectoryServiceClient.updateServiceInstanceInternalStatus | public void updateServiceInstanceInternalStatus(String serviceName, String instanceId, OperationalStatus status) {
"""
Update ServiceInstance internal status.
@param serviceName
the service name.
@param instanceId
the instanceId.
@param status
the OeperationalStatus.
"""
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceInternalStatus);
UpdateServiceInstanceInternalStatusProtocol protocol = new UpdateServiceInstanceInternalStatusProtocol(serviceName, instanceId, status);
connection.submitRequest(header, protocol, null);
} | java | public void updateServiceInstanceInternalStatus(String serviceName, String instanceId, OperationalStatus status){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceInternalStatus);
UpdateServiceInstanceInternalStatusProtocol protocol = new UpdateServiceInstanceInternalStatusProtocol(serviceName, instanceId, status);
connection.submitRequest(header, protocol, null);
} | [
"public",
"void",
"updateServiceInstanceInternalStatus",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
",",
"OperationalStatus",
"status",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstanceInternalStatus",
")",
";",
"UpdateServiceInstanceInternalStatusProtocol",
"protocol",
"=",
"new",
"UpdateServiceInstanceInternalStatusProtocol",
"(",
"serviceName",
",",
"instanceId",
",",
"status",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"protocol",
",",
"null",
")",
";",
"}"
] | Update ServiceInstance internal status.
@param serviceName
the service name.
@param instanceId
the instanceId.
@param status
the OeperationalStatus. | [
"Update",
"ServiceInstance",
"internal",
"status",
"."
] | train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L452-L458 |
line/armeria | core/src/main/java/com/linecorp/armeria/server/ServerBuilder.java | ServerBuilder.annotatedService | public ServerBuilder annotatedService(String pathPrefix, Object service,
Iterable<?> exceptionHandlersAndConverters) {
"""
Binds the specified annotated service object under the specified path prefix.
@param exceptionHandlersAndConverters an iterable object of {@link ExceptionHandlerFunction},
{@link RequestConverterFunction} and/or
{@link ResponseConverterFunction}
"""
return annotatedService(pathPrefix, service, Function.identity(), exceptionHandlersAndConverters);
} | java | public ServerBuilder annotatedService(String pathPrefix, Object service,
Iterable<?> exceptionHandlersAndConverters) {
return annotatedService(pathPrefix, service, Function.identity(), exceptionHandlersAndConverters);
} | [
"public",
"ServerBuilder",
"annotatedService",
"(",
"String",
"pathPrefix",
",",
"Object",
"service",
",",
"Iterable",
"<",
"?",
">",
"exceptionHandlersAndConverters",
")",
"{",
"return",
"annotatedService",
"(",
"pathPrefix",
",",
"service",
",",
"Function",
".",
"identity",
"(",
")",
",",
"exceptionHandlersAndConverters",
")",
";",
"}"
] | Binds the specified annotated service object under the specified path prefix.
@param exceptionHandlersAndConverters an iterable object of {@link ExceptionHandlerFunction},
{@link RequestConverterFunction} and/or
{@link ResponseConverterFunction} | [
"Binds",
"the",
"specified",
"annotated",
"service",
"object",
"under",
"the",
"specified",
"path",
"prefix",
"."
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/ServerBuilder.java#L1067-L1070 |
apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveUtils.java | HiveUtils.getPartitions | public static List<Partition> getPartitions(IMetaStoreClient client, Table table, Optional<String> filter)
throws IOException {
"""
For backward compatibility when PathFilter is injected as a parameter.
@param client
@param table
@param filter
@return
@throws IOException
"""
return getPartitions(client, table, filter, Optional.<HivePartitionExtendedFilter>absent());
} | java | public static List<Partition> getPartitions(IMetaStoreClient client, Table table, Optional<String> filter)
throws IOException {
return getPartitions(client, table, filter, Optional.<HivePartitionExtendedFilter>absent());
} | [
"public",
"static",
"List",
"<",
"Partition",
">",
"getPartitions",
"(",
"IMetaStoreClient",
"client",
",",
"Table",
"table",
",",
"Optional",
"<",
"String",
">",
"filter",
")",
"throws",
"IOException",
"{",
"return",
"getPartitions",
"(",
"client",
",",
"table",
",",
"filter",
",",
"Optional",
".",
"<",
"HivePartitionExtendedFilter",
">",
"absent",
"(",
")",
")",
";",
"}"
] | For backward compatibility when PathFilter is injected as a parameter.
@param client
@param table
@param filter
@return
@throws IOException | [
"For",
"backward",
"compatibility",
"when",
"PathFilter",
"is",
"injected",
"as",
"a",
"parameter",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveUtils.java#L116-L119 |
btrplace/scheduler | choco/src/main/java/org/btrplace/scheduler/choco/constraint/CSpread.java | CSpread.precedenceIfOverlap | private static void precedenceIfOverlap(ReconfigurationProblem rp, Slice d, Slice c) {
"""
Establish the precedence constraint {@code c.getEnd() <= d.getStart()} if the two slices may overlap.
"""
Model csp = rp.getModel();
//No need to place the constraints if the slices do not have a chance to overlap
if (!(c.getHoster().isInstantiated() && !d.getHoster().contains(c.getHoster().getValue()))
&& !(d.getHoster().isInstantiated() && !c.getHoster().contains(d.getHoster().getValue()))
) {
BoolVar eq = csp.boolVar(rp.makeVarLabel(d.getHoster(), "", c.getHoster(), "?"));
rp.getModel().arithm(d.getHoster(), "=", c.getHoster()).reifyWith(eq);
org.chocosolver.solver.constraints.Constraint leqCstr = rp.getModel().arithm(c.getEnd(), "<=", d.getStart());
ChocoUtils.postImplies(rp, eq, leqCstr);
}
} | java | private static void precedenceIfOverlap(ReconfigurationProblem rp, Slice d, Slice c) {
Model csp = rp.getModel();
//No need to place the constraints if the slices do not have a chance to overlap
if (!(c.getHoster().isInstantiated() && !d.getHoster().contains(c.getHoster().getValue()))
&& !(d.getHoster().isInstantiated() && !c.getHoster().contains(d.getHoster().getValue()))
) {
BoolVar eq = csp.boolVar(rp.makeVarLabel(d.getHoster(), "", c.getHoster(), "?"));
rp.getModel().arithm(d.getHoster(), "=", c.getHoster()).reifyWith(eq);
org.chocosolver.solver.constraints.Constraint leqCstr = rp.getModel().arithm(c.getEnd(), "<=", d.getStart());
ChocoUtils.postImplies(rp, eq, leqCstr);
}
} | [
"private",
"static",
"void",
"precedenceIfOverlap",
"(",
"ReconfigurationProblem",
"rp",
",",
"Slice",
"d",
",",
"Slice",
"c",
")",
"{",
"Model",
"csp",
"=",
"rp",
".",
"getModel",
"(",
")",
";",
"//No need to place the constraints if the slices do not have a chance to overlap",
"if",
"(",
"!",
"(",
"c",
".",
"getHoster",
"(",
")",
".",
"isInstantiated",
"(",
")",
"&&",
"!",
"d",
".",
"getHoster",
"(",
")",
".",
"contains",
"(",
"c",
".",
"getHoster",
"(",
")",
".",
"getValue",
"(",
")",
")",
")",
"&&",
"!",
"(",
"d",
".",
"getHoster",
"(",
")",
".",
"isInstantiated",
"(",
")",
"&&",
"!",
"c",
".",
"getHoster",
"(",
")",
".",
"contains",
"(",
"d",
".",
"getHoster",
"(",
")",
".",
"getValue",
"(",
")",
")",
")",
")",
"{",
"BoolVar",
"eq",
"=",
"csp",
".",
"boolVar",
"(",
"rp",
".",
"makeVarLabel",
"(",
"d",
".",
"getHoster",
"(",
")",
",",
"\"\"",
",",
"c",
".",
"getHoster",
"(",
")",
",",
"\"?\"",
")",
")",
";",
"rp",
".",
"getModel",
"(",
")",
".",
"arithm",
"(",
"d",
".",
"getHoster",
"(",
")",
",",
"\"=\"",
",",
"c",
".",
"getHoster",
"(",
")",
")",
".",
"reifyWith",
"(",
"eq",
")",
";",
"org",
".",
"chocosolver",
".",
"solver",
".",
"constraints",
".",
"Constraint",
"leqCstr",
"=",
"rp",
".",
"getModel",
"(",
")",
".",
"arithm",
"(",
"c",
".",
"getEnd",
"(",
")",
",",
"\"<=\"",
",",
"d",
".",
"getStart",
"(",
")",
")",
";",
"ChocoUtils",
".",
"postImplies",
"(",
"rp",
",",
"eq",
",",
"leqCstr",
")",
";",
"}",
"}"
] | Establish the precedence constraint {@code c.getEnd() <= d.getStart()} if the two slices may overlap. | [
"Establish",
"the",
"precedence",
"constraint",
"{"
] | train | https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/constraint/CSpread.java#L118-L129 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.deposit_depositId_details_depositDetailId_GET | public OvhDepositDetail deposit_depositId_details_depositDetailId_GET(String depositId, String depositDetailId) throws IOException {
"""
Get this object properties
REST: GET /me/deposit/{depositId}/details/{depositDetailId}
@param depositId [required]
@param depositDetailId [required]
"""
String qPath = "/me/deposit/{depositId}/details/{depositDetailId}";
StringBuilder sb = path(qPath, depositId, depositDetailId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDepositDetail.class);
} | java | public OvhDepositDetail deposit_depositId_details_depositDetailId_GET(String depositId, String depositDetailId) throws IOException {
String qPath = "/me/deposit/{depositId}/details/{depositDetailId}";
StringBuilder sb = path(qPath, depositId, depositDetailId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDepositDetail.class);
} | [
"public",
"OvhDepositDetail",
"deposit_depositId_details_depositDetailId_GET",
"(",
"String",
"depositId",
",",
"String",
"depositDetailId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/deposit/{depositId}/details/{depositDetailId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"depositId",
",",
"depositDetailId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDepositDetail",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /me/deposit/{depositId}/details/{depositDetailId}
@param depositId [required]
@param depositDetailId [required] | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L3278-L3283 |
SnappyDataInc/snappydata | launcher/src/main/java/io/snappydata/tools/QuickLauncher.java | QuickLauncher.readStatus | private void readStatus(boolean emptyForMissing, final Path statusFile) {
"""
Returns the <code>Status</code> of the node. An empty status is returned
if status file is missing and <code>emptyForMissing</code> argument is true
else null is returned.
"""
this.status = null;
if (Files.exists(statusFile)) {
// try some number of times if dsMsg is null
for (int i = 1; i <= 3; i++) {
this.status = Status.spinRead(baseName, statusFile);
if (this.status.dsMsg != null) break;
}
}
if (this.status == null && emptyForMissing) {
this.status = Status.create(baseName, Status.SHUTDOWN, 0, statusFile);
}
} | java | private void readStatus(boolean emptyForMissing, final Path statusFile) {
this.status = null;
if (Files.exists(statusFile)) {
// try some number of times if dsMsg is null
for (int i = 1; i <= 3; i++) {
this.status = Status.spinRead(baseName, statusFile);
if (this.status.dsMsg != null) break;
}
}
if (this.status == null && emptyForMissing) {
this.status = Status.create(baseName, Status.SHUTDOWN, 0, statusFile);
}
} | [
"private",
"void",
"readStatus",
"(",
"boolean",
"emptyForMissing",
",",
"final",
"Path",
"statusFile",
")",
"{",
"this",
".",
"status",
"=",
"null",
";",
"if",
"(",
"Files",
".",
"exists",
"(",
"statusFile",
")",
")",
"{",
"// try some number of times if dsMsg is null",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"3",
";",
"i",
"++",
")",
"{",
"this",
".",
"status",
"=",
"Status",
".",
"spinRead",
"(",
"baseName",
",",
"statusFile",
")",
";",
"if",
"(",
"this",
".",
"status",
".",
"dsMsg",
"!=",
"null",
")",
"break",
";",
"}",
"}",
"if",
"(",
"this",
".",
"status",
"==",
"null",
"&&",
"emptyForMissing",
")",
"{",
"this",
".",
"status",
"=",
"Status",
".",
"create",
"(",
"baseName",
",",
"Status",
".",
"SHUTDOWN",
",",
"0",
",",
"statusFile",
")",
";",
"}",
"}"
] | Returns the <code>Status</code> of the node. An empty status is returned
if status file is missing and <code>emptyForMissing</code> argument is true
else null is returned. | [
"Returns",
"the",
"<code",
">",
"Status<",
"/",
"code",
">",
"of",
"the",
"node",
".",
"An",
"empty",
"status",
"is",
"returned",
"if",
"status",
"file",
"is",
"missing",
"and",
"<code",
">",
"emptyForMissing<",
"/",
"code",
">",
"argument",
"is",
"true",
"else",
"null",
"is",
"returned",
"."
] | train | https://github.com/SnappyDataInc/snappydata/blob/96fe3e37e9f8d407ab68ef9e394083960acad21d/launcher/src/main/java/io/snappydata/tools/QuickLauncher.java#L440-L452 |
jmurty/java-xmlbuilder | src/main/java/com/jamesmurty/utils/BaseXMLBuilder.java | BaseXMLBuilder.toWriter | public void toWriter(Writer writer, Properties outputProperties)
throws TransformerException {
"""
Serialize the XML document to the given writer using the default
{@link TransformerFactory} and {@link Transformer} classes. If output
options are provided, these options are provided to the
{@link Transformer} serializer.
@param writer
a writer to which the serialized document is written.
@param outputProperties
settings for the {@link Transformer} serializer. This parameter may be
null or an empty Properties object, in which case the default output
properties will be applied.
@throws TransformerException
"""
this.toWriter(true, writer, outputProperties);
} | java | public void toWriter(Writer writer, Properties outputProperties)
throws TransformerException {
this.toWriter(true, writer, outputProperties);
} | [
"public",
"void",
"toWriter",
"(",
"Writer",
"writer",
",",
"Properties",
"outputProperties",
")",
"throws",
"TransformerException",
"{",
"this",
".",
"toWriter",
"(",
"true",
",",
"writer",
",",
"outputProperties",
")",
";",
"}"
] | Serialize the XML document to the given writer using the default
{@link TransformerFactory} and {@link Transformer} classes. If output
options are provided, these options are provided to the
{@link Transformer} serializer.
@param writer
a writer to which the serialized document is written.
@param outputProperties
settings for the {@link Transformer} serializer. This parameter may be
null or an empty Properties object, in which case the default output
properties will be applied.
@throws TransformerException | [
"Serialize",
"the",
"XML",
"document",
"to",
"the",
"given",
"writer",
"using",
"the",
"default",
"{",
"@link",
"TransformerFactory",
"}",
"and",
"{",
"@link",
"Transformer",
"}",
"classes",
".",
"If",
"output",
"options",
"are",
"provided",
"these",
"options",
"are",
"provided",
"to",
"the",
"{",
"@link",
"Transformer",
"}",
"serializer",
"."
] | train | https://github.com/jmurty/java-xmlbuilder/blob/7c224b8e8ed79808509322cb141dab5a88dd3cec/src/main/java/com/jamesmurty/utils/BaseXMLBuilder.java#L1342-L1345 |
apache/spark | sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeMapData.java | UnsafeMapData.pointTo | public void pointTo(Object baseObject, long baseOffset, int sizeInBytes) {
"""
Update this UnsafeMapData to point to different backing data.
@param baseObject the base object
@param baseOffset the offset within the base object
@param sizeInBytes the size of this map's backing data, in bytes
"""
// Read the numBytes of key array from the first 8 bytes.
final long keyArraySize = Platform.getLong(baseObject, baseOffset);
assert keyArraySize >= 0 : "keyArraySize (" + keyArraySize + ") should >= 0";
assert keyArraySize <= Integer.MAX_VALUE :
"keyArraySize (" + keyArraySize + ") should <= Integer.MAX_VALUE";
final int valueArraySize = sizeInBytes - (int)keyArraySize - 8;
assert valueArraySize >= 0 : "valueArraySize (" + valueArraySize + ") should >= 0";
keys.pointTo(baseObject, baseOffset + 8, (int)keyArraySize);
values.pointTo(baseObject, baseOffset + 8 + keyArraySize, valueArraySize);
assert keys.numElements() == values.numElements();
this.baseObject = baseObject;
this.baseOffset = baseOffset;
this.sizeInBytes = sizeInBytes;
} | java | public void pointTo(Object baseObject, long baseOffset, int sizeInBytes) {
// Read the numBytes of key array from the first 8 bytes.
final long keyArraySize = Platform.getLong(baseObject, baseOffset);
assert keyArraySize >= 0 : "keyArraySize (" + keyArraySize + ") should >= 0";
assert keyArraySize <= Integer.MAX_VALUE :
"keyArraySize (" + keyArraySize + ") should <= Integer.MAX_VALUE";
final int valueArraySize = sizeInBytes - (int)keyArraySize - 8;
assert valueArraySize >= 0 : "valueArraySize (" + valueArraySize + ") should >= 0";
keys.pointTo(baseObject, baseOffset + 8, (int)keyArraySize);
values.pointTo(baseObject, baseOffset + 8 + keyArraySize, valueArraySize);
assert keys.numElements() == values.numElements();
this.baseObject = baseObject;
this.baseOffset = baseOffset;
this.sizeInBytes = sizeInBytes;
} | [
"public",
"void",
"pointTo",
"(",
"Object",
"baseObject",
",",
"long",
"baseOffset",
",",
"int",
"sizeInBytes",
")",
"{",
"// Read the numBytes of key array from the first 8 bytes.",
"final",
"long",
"keyArraySize",
"=",
"Platform",
".",
"getLong",
"(",
"baseObject",
",",
"baseOffset",
")",
";",
"assert",
"keyArraySize",
">=",
"0",
":",
"\"keyArraySize (\"",
"+",
"keyArraySize",
"+",
"\") should >= 0\"",
";",
"assert",
"keyArraySize",
"<=",
"Integer",
".",
"MAX_VALUE",
":",
"\"keyArraySize (\"",
"+",
"keyArraySize",
"+",
"\") should <= Integer.MAX_VALUE\"",
";",
"final",
"int",
"valueArraySize",
"=",
"sizeInBytes",
"-",
"(",
"int",
")",
"keyArraySize",
"-",
"8",
";",
"assert",
"valueArraySize",
">=",
"0",
":",
"\"valueArraySize (\"",
"+",
"valueArraySize",
"+",
"\") should >= 0\"",
";",
"keys",
".",
"pointTo",
"(",
"baseObject",
",",
"baseOffset",
"+",
"8",
",",
"(",
"int",
")",
"keyArraySize",
")",
";",
"values",
".",
"pointTo",
"(",
"baseObject",
",",
"baseOffset",
"+",
"8",
"+",
"keyArraySize",
",",
"valueArraySize",
")",
";",
"assert",
"keys",
".",
"numElements",
"(",
")",
"==",
"values",
".",
"numElements",
"(",
")",
";",
"this",
".",
"baseObject",
"=",
"baseObject",
";",
"this",
".",
"baseOffset",
"=",
"baseOffset",
";",
"this",
".",
"sizeInBytes",
"=",
"sizeInBytes",
";",
"}"
] | Update this UnsafeMapData to point to different backing data.
@param baseObject the base object
@param baseOffset the offset within the base object
@param sizeInBytes the size of this map's backing data, in bytes | [
"Update",
"this",
"UnsafeMapData",
"to",
"point",
"to",
"different",
"backing",
"data",
"."
] | train | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeMapData.java#L81-L98 |
VoltDB/voltdb | src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java | JDBC4CallableStatement.setRowId | @Override
public void setRowId(String parameterName, RowId x) throws SQLException {
"""
Sets the designated parameter to the given java.sql.RowId object.
"""
checkClosed();
throw SQLError.noSupport();
} | java | @Override
public void setRowId(String parameterName, RowId x) throws SQLException
{
checkClosed();
throw SQLError.noSupport();
} | [
"@",
"Override",
"public",
"void",
"setRowId",
"(",
"String",
"parameterName",
",",
"RowId",
"x",
")",
"throws",
"SQLException",
"{",
"checkClosed",
"(",
")",
";",
"throw",
"SQLError",
".",
"noSupport",
"(",
")",
";",
"}"
] | Sets the designated parameter to the given java.sql.RowId object. | [
"Sets",
"the",
"designated",
"parameter",
"to",
"the",
"given",
"java",
".",
"sql",
".",
"RowId",
"object",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java#L855-L860 |
VoltDB/voltdb | src/frontend/org/voltdb/types/GeographyPointValue.java | GeographyPointValue.unflattenFromBuffer | public static GeographyPointValue unflattenFromBuffer(ByteBuffer inBuffer, int offset) {
"""
Deserializes a point from a ByteBuffer, at an absolute offset.
@param inBuffer The ByteBuffer from which to read the bytes for a point.
@param offset Absolute offset of point data in buffer.
@return A new instance of GeographyPointValue.
"""
double lng = inBuffer.getDouble(offset);
double lat = inBuffer.getDouble(offset + BYTES_IN_A_COORD);
if (lat == 360.0 && lng == 360.0) {
// This is a null point.
return null;
}
return new GeographyPointValue(lng, lat);
} | java | public static GeographyPointValue unflattenFromBuffer(ByteBuffer inBuffer, int offset) {
double lng = inBuffer.getDouble(offset);
double lat = inBuffer.getDouble(offset + BYTES_IN_A_COORD);
if (lat == 360.0 && lng == 360.0) {
// This is a null point.
return null;
}
return new GeographyPointValue(lng, lat);
} | [
"public",
"static",
"GeographyPointValue",
"unflattenFromBuffer",
"(",
"ByteBuffer",
"inBuffer",
",",
"int",
"offset",
")",
"{",
"double",
"lng",
"=",
"inBuffer",
".",
"getDouble",
"(",
"offset",
")",
";",
"double",
"lat",
"=",
"inBuffer",
".",
"getDouble",
"(",
"offset",
"+",
"BYTES_IN_A_COORD",
")",
";",
"if",
"(",
"lat",
"==",
"360.0",
"&&",
"lng",
"==",
"360.0",
")",
"{",
"// This is a null point.",
"return",
"null",
";",
"}",
"return",
"new",
"GeographyPointValue",
"(",
"lng",
",",
"lat",
")",
";",
"}"
] | Deserializes a point from a ByteBuffer, at an absolute offset.
@param inBuffer The ByteBuffer from which to read the bytes for a point.
@param offset Absolute offset of point data in buffer.
@return A new instance of GeographyPointValue. | [
"Deserializes",
"a",
"point",
"from",
"a",
"ByteBuffer",
"at",
"an",
"absolute",
"offset",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/types/GeographyPointValue.java#L230-L239 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/KeyStore.java | KeyStore.getKey | public final Key getKey(String alias, char[] password)
throws KeyStoreException, NoSuchAlgorithmException,
UnrecoverableKeyException {
"""
Returns the key associated with the given alias, using the given
password to recover it. The key must have been associated with
the alias by a call to <code>setKeyEntry</code>,
or by a call to <code>setEntry</code> with a
<code>PrivateKeyEntry</code> or <code>SecretKeyEntry</code>.
@param alias the alias name
@param password the password for recovering the key
@return the requested key, or null if the given alias does not exist
or does not identify a key-related entry.
@exception KeyStoreException if the keystore has not been initialized
(loaded).
@exception NoSuchAlgorithmException if the algorithm for recovering the
key cannot be found
@exception UnrecoverableKeyException if the key cannot be recovered
(e.g., the given password is wrong).
"""
if (!initialized) {
throw new KeyStoreException("Uninitialized keystore");
}
return keyStoreSpi.engineGetKey(alias, password);
} | java | public final Key getKey(String alias, char[] password)
throws KeyStoreException, NoSuchAlgorithmException,
UnrecoverableKeyException
{
if (!initialized) {
throw new KeyStoreException("Uninitialized keystore");
}
return keyStoreSpi.engineGetKey(alias, password);
} | [
"public",
"final",
"Key",
"getKey",
"(",
"String",
"alias",
",",
"char",
"[",
"]",
"password",
")",
"throws",
"KeyStoreException",
",",
"NoSuchAlgorithmException",
",",
"UnrecoverableKeyException",
"{",
"if",
"(",
"!",
"initialized",
")",
"{",
"throw",
"new",
"KeyStoreException",
"(",
"\"Uninitialized keystore\"",
")",
";",
"}",
"return",
"keyStoreSpi",
".",
"engineGetKey",
"(",
"alias",
",",
"password",
")",
";",
"}"
] | Returns the key associated with the given alias, using the given
password to recover it. The key must have been associated with
the alias by a call to <code>setKeyEntry</code>,
or by a call to <code>setEntry</code> with a
<code>PrivateKeyEntry</code> or <code>SecretKeyEntry</code>.
@param alias the alias name
@param password the password for recovering the key
@return the requested key, or null if the given alias does not exist
or does not identify a key-related entry.
@exception KeyStoreException if the keystore has not been initialized
(loaded).
@exception NoSuchAlgorithmException if the algorithm for recovering the
key cannot be found
@exception UnrecoverableKeyException if the key cannot be recovered
(e.g., the given password is wrong). | [
"Returns",
"the",
"key",
"associated",
"with",
"the",
"given",
"alias",
"using",
"the",
"given",
"password",
"to",
"recover",
"it",
".",
"The",
"key",
"must",
"have",
"been",
"associated",
"with",
"the",
"alias",
"by",
"a",
"call",
"to",
"<code",
">",
"setKeyEntry<",
"/",
"code",
">",
"or",
"by",
"a",
"call",
"to",
"<code",
">",
"setEntry<",
"/",
"code",
">",
"with",
"a",
"<code",
">",
"PrivateKeyEntry<",
"/",
"code",
">",
"or",
"<code",
">",
"SecretKeyEntry<",
"/",
"code",
">",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/KeyStore.java#L827-L835 |
apache/incubator-gobblin | gobblin-modules/gobblin-http/src/main/java/org/apache/gobblin/writer/AsyncHttpWriter.java | AsyncHttpWriter.onFailure | @Deprecated
protected void onFailure(AsyncRequest<D, RQ> asyncRequest, Throwable throwable) {
"""
Callback on failing to send the asyncRequest
@deprecated Use {@link #onFailure(AsyncRequest, DispatchException)}
"""
for (AsyncRequest.Thunk thunk: asyncRequest.getThunks()) {
thunk.callback.onFailure(throwable);
}
} | java | @Deprecated
protected void onFailure(AsyncRequest<D, RQ> asyncRequest, Throwable throwable) {
for (AsyncRequest.Thunk thunk: asyncRequest.getThunks()) {
thunk.callback.onFailure(throwable);
}
} | [
"@",
"Deprecated",
"protected",
"void",
"onFailure",
"(",
"AsyncRequest",
"<",
"D",
",",
"RQ",
">",
"asyncRequest",
",",
"Throwable",
"throwable",
")",
"{",
"for",
"(",
"AsyncRequest",
".",
"Thunk",
"thunk",
":",
"asyncRequest",
".",
"getThunks",
"(",
")",
")",
"{",
"thunk",
".",
"callback",
".",
"onFailure",
"(",
"throwable",
")",
";",
"}",
"}"
] | Callback on failing to send the asyncRequest
@deprecated Use {@link #onFailure(AsyncRequest, DispatchException)} | [
"Callback",
"on",
"failing",
"to",
"send",
"the",
"asyncRequest"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-http/src/main/java/org/apache/gobblin/writer/AsyncHttpWriter.java#L167-L172 |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/parse/ParameterParser.java | ParameterParser._getToken | @Nullable
private String _getToken (final boolean bQuoted) {
"""
A helper method to process the parsed token. This method removes leading
and trailing blanks as well as enclosing quotation marks, when necessary.
@param bQuoted
<tt>true</tt> if quotation marks are expected, <tt>false</tt>
otherwise.
@return the token
"""
// Trim leading white spaces
while (m_nIndex1 < m_nIndex2 && Character.isWhitespace (m_aChars[m_nIndex1]))
{
m_nIndex1++;
}
// Trim trailing white spaces
while (m_nIndex2 > m_nIndex1 && Character.isWhitespace (m_aChars[m_nIndex2 - 1]))
{
m_nIndex2--;
}
// Strip away quotation marks if necessary
if (bQuoted)
{
if ((m_nIndex2 - m_nIndex1) >= 2 && m_aChars[m_nIndex1] == '"' && m_aChars[m_nIndex2 - 1] == '"')
{
m_nIndex1++;
m_nIndex2--;
}
}
String ret = null;
if (m_nIndex2 > m_nIndex1)
{
ret = new String (m_aChars, m_nIndex1, m_nIndex2 - m_nIndex1);
}
return ret;
} | java | @Nullable
private String _getToken (final boolean bQuoted)
{
// Trim leading white spaces
while (m_nIndex1 < m_nIndex2 && Character.isWhitespace (m_aChars[m_nIndex1]))
{
m_nIndex1++;
}
// Trim trailing white spaces
while (m_nIndex2 > m_nIndex1 && Character.isWhitespace (m_aChars[m_nIndex2 - 1]))
{
m_nIndex2--;
}
// Strip away quotation marks if necessary
if (bQuoted)
{
if ((m_nIndex2 - m_nIndex1) >= 2 && m_aChars[m_nIndex1] == '"' && m_aChars[m_nIndex2 - 1] == '"')
{
m_nIndex1++;
m_nIndex2--;
}
}
String ret = null;
if (m_nIndex2 > m_nIndex1)
{
ret = new String (m_aChars, m_nIndex1, m_nIndex2 - m_nIndex1);
}
return ret;
} | [
"@",
"Nullable",
"private",
"String",
"_getToken",
"(",
"final",
"boolean",
"bQuoted",
")",
"{",
"// Trim leading white spaces",
"while",
"(",
"m_nIndex1",
"<",
"m_nIndex2",
"&&",
"Character",
".",
"isWhitespace",
"(",
"m_aChars",
"[",
"m_nIndex1",
"]",
")",
")",
"{",
"m_nIndex1",
"++",
";",
"}",
"// Trim trailing white spaces",
"while",
"(",
"m_nIndex2",
">",
"m_nIndex1",
"&&",
"Character",
".",
"isWhitespace",
"(",
"m_aChars",
"[",
"m_nIndex2",
"-",
"1",
"]",
")",
")",
"{",
"m_nIndex2",
"--",
";",
"}",
"// Strip away quotation marks if necessary",
"if",
"(",
"bQuoted",
")",
"{",
"if",
"(",
"(",
"m_nIndex2",
"-",
"m_nIndex1",
")",
">=",
"2",
"&&",
"m_aChars",
"[",
"m_nIndex1",
"]",
"==",
"'",
"'",
"&&",
"m_aChars",
"[",
"m_nIndex2",
"-",
"1",
"]",
"==",
"'",
"'",
")",
"{",
"m_nIndex1",
"++",
";",
"m_nIndex2",
"--",
";",
"}",
"}",
"String",
"ret",
"=",
"null",
";",
"if",
"(",
"m_nIndex2",
">",
"m_nIndex1",
")",
"{",
"ret",
"=",
"new",
"String",
"(",
"m_aChars",
",",
"m_nIndex1",
",",
"m_nIndex2",
"-",
"m_nIndex1",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | A helper method to process the parsed token. This method removes leading
and trailing blanks as well as enclosing quotation marks, when necessary.
@param bQuoted
<tt>true</tt> if quotation marks are expected, <tt>false</tt>
otherwise.
@return the token | [
"A",
"helper",
"method",
"to",
"process",
"the",
"parsed",
"token",
".",
"This",
"method",
"removes",
"leading",
"and",
"trailing",
"blanks",
"as",
"well",
"as",
"enclosing",
"quotation",
"marks",
"when",
"necessary",
"."
] | train | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/parse/ParameterParser.java#L102-L130 |
joachimvda/jtransfo | core/src/main/java/org/jtransfo/internal/ConverterHelper.java | ConverterHelper.getDefaultTypeConverter | TypeConverter getDefaultTypeConverter(Type toField, Type domainField) {
"""
Get the default type converter given the field types to convert between.
@param toField transfer object field class
@param domainField domain object field class
@return type converter
"""
for (TypeConverter typeConverter : typeConvertersInOrder) {
if (typeConverter.canConvert(toField, domainField)) {
return typeConverter;
}
}
return new NoConversionTypeConverter(); // default to no type conversion
} | java | TypeConverter getDefaultTypeConverter(Type toField, Type domainField) {
for (TypeConverter typeConverter : typeConvertersInOrder) {
if (typeConverter.canConvert(toField, domainField)) {
return typeConverter;
}
}
return new NoConversionTypeConverter(); // default to no type conversion
} | [
"TypeConverter",
"getDefaultTypeConverter",
"(",
"Type",
"toField",
",",
"Type",
"domainField",
")",
"{",
"for",
"(",
"TypeConverter",
"typeConverter",
":",
"typeConvertersInOrder",
")",
"{",
"if",
"(",
"typeConverter",
".",
"canConvert",
"(",
"toField",
",",
"domainField",
")",
")",
"{",
"return",
"typeConverter",
";",
"}",
"}",
"return",
"new",
"NoConversionTypeConverter",
"(",
")",
";",
"// default to no type conversion",
"}"
] | Get the default type converter given the field types to convert between.
@param toField transfer object field class
@param domainField domain object field class
@return type converter | [
"Get",
"the",
"default",
"type",
"converter",
"given",
"the",
"field",
"types",
"to",
"convert",
"between",
"."
] | train | https://github.com/joachimvda/jtransfo/blob/eb1c72b64b09d6f3b6212bd3f1579cac5c983ea8/core/src/main/java/org/jtransfo/internal/ConverterHelper.java#L400-L407 |
lightblueseas/file-worker | src/main/java/de/alpharogroup/file/copy/CopyFileExtensions.java | CopyFileExtensions.copyFileToDirectory | public static boolean copyFileToDirectory(final File source, final File destinationDir)
throws FileIsNotADirectoryException, IOException, FileIsADirectoryException {
"""
Copies the given source file to the given destination directory.
@param source
The source file to copy in the destination directory.
@param destinationDir
The destination directory.
@return 's true if the file is copied to the destination directory, otherwise false.
@throws FileIsNotADirectoryException
Is thrown if the source file is not a directory.
@throws IOException
Is thrown if an error occurs by reading or writing.
@throws FileIsADirectoryException
Is thrown if the destination file is a directory.
"""
return copyFileToDirectory(source, destinationDir, true);
} | java | public static boolean copyFileToDirectory(final File source, final File destinationDir)
throws FileIsNotADirectoryException, IOException, FileIsADirectoryException
{
return copyFileToDirectory(source, destinationDir, true);
} | [
"public",
"static",
"boolean",
"copyFileToDirectory",
"(",
"final",
"File",
"source",
",",
"final",
"File",
"destinationDir",
")",
"throws",
"FileIsNotADirectoryException",
",",
"IOException",
",",
"FileIsADirectoryException",
"{",
"return",
"copyFileToDirectory",
"(",
"source",
",",
"destinationDir",
",",
"true",
")",
";",
"}"
] | Copies the given source file to the given destination directory.
@param source
The source file to copy in the destination directory.
@param destinationDir
The destination directory.
@return 's true if the file is copied to the destination directory, otherwise false.
@throws FileIsNotADirectoryException
Is thrown if the source file is not a directory.
@throws IOException
Is thrown if an error occurs by reading or writing.
@throws FileIsADirectoryException
Is thrown if the destination file is a directory. | [
"Copies",
"the",
"given",
"source",
"file",
"to",
"the",
"given",
"destination",
"directory",
"."
] | train | https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/copy/CopyFileExtensions.java#L593-L597 |
Jasig/uPortal | uPortal-core/src/main/java/org/apereo/portal/properties/PropertiesManager.java | PropertiesManager.getPropertyUntrimmed | public static String getPropertyUntrimmed(String name) throws MissingPropertyException {
"""
Returns the value of a property for a given name including whitespace trailing the property
value, but not including whitespace leading the property value. An UndeclaredPortalException
is thrown if the property cannot be found. This method will never return null.
@param name the name of the requested property
@return value the value of the property matching the requested name
@throws MissingPropertyException - (undeclared) if the requested property is not found
"""
if (PropertiesManager.props == null) loadProps();
if (props == null) {
boolean alreadyReported = registerMissingProperty(name);
throw new MissingPropertyException(name, alreadyReported);
}
String val = props.getProperty(name);
if (val == null) {
boolean alreadyReported = registerMissingProperty(name);
throw new MissingPropertyException(name, alreadyReported);
}
return val;
} | java | public static String getPropertyUntrimmed(String name) throws MissingPropertyException {
if (PropertiesManager.props == null) loadProps();
if (props == null) {
boolean alreadyReported = registerMissingProperty(name);
throw new MissingPropertyException(name, alreadyReported);
}
String val = props.getProperty(name);
if (val == null) {
boolean alreadyReported = registerMissingProperty(name);
throw new MissingPropertyException(name, alreadyReported);
}
return val;
} | [
"public",
"static",
"String",
"getPropertyUntrimmed",
"(",
"String",
"name",
")",
"throws",
"MissingPropertyException",
"{",
"if",
"(",
"PropertiesManager",
".",
"props",
"==",
"null",
")",
"loadProps",
"(",
")",
";",
"if",
"(",
"props",
"==",
"null",
")",
"{",
"boolean",
"alreadyReported",
"=",
"registerMissingProperty",
"(",
"name",
")",
";",
"throw",
"new",
"MissingPropertyException",
"(",
"name",
",",
"alreadyReported",
")",
";",
"}",
"String",
"val",
"=",
"props",
".",
"getProperty",
"(",
"name",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"boolean",
"alreadyReported",
"=",
"registerMissingProperty",
"(",
"name",
")",
";",
"throw",
"new",
"MissingPropertyException",
"(",
"name",
",",
"alreadyReported",
")",
";",
"}",
"return",
"val",
";",
"}"
] | Returns the value of a property for a given name including whitespace trailing the property
value, but not including whitespace leading the property value. An UndeclaredPortalException
is thrown if the property cannot be found. This method will never return null.
@param name the name of the requested property
@return value the value of the property matching the requested name
@throws MissingPropertyException - (undeclared) if the requested property is not found | [
"Returns",
"the",
"value",
"of",
"a",
"property",
"for",
"a",
"given",
"name",
"including",
"whitespace",
"trailing",
"the",
"property",
"value",
"but",
"not",
"including",
"whitespace",
"leading",
"the",
"property",
"value",
".",
"An",
"UndeclaredPortalException",
"is",
"thrown",
"if",
"the",
"property",
"cannot",
"be",
"found",
".",
"This",
"method",
"will",
"never",
"return",
"null",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-core/src/main/java/org/apereo/portal/properties/PropertiesManager.java#L127-L141 |
apache/flink | flink-core/src/main/java/org/apache/flink/api/common/typeutils/TypeSerializerSerializationUtil.java | TypeSerializerSerializationUtil.tryReadSerializer | public static <T> TypeSerializer<T> tryReadSerializer(DataInputView in, ClassLoader userCodeClassLoader) throws IOException {
"""
Reads from a data input view a {@link TypeSerializer} that was previously
written using {@link #writeSerializer(DataOutputView, TypeSerializer)}.
<p>If deserialization fails for any reason (corrupted serializer bytes, serializer class
no longer in classpath, serializer class no longer valid, etc.), an {@link IOException} is thrown.
@param in the data input view.
@param userCodeClassLoader the user code class loader to use.
@param <T> Data type of the serializer.
@return the deserialized serializer.
"""
return tryReadSerializer(in, userCodeClassLoader, false);
} | java | public static <T> TypeSerializer<T> tryReadSerializer(DataInputView in, ClassLoader userCodeClassLoader) throws IOException {
return tryReadSerializer(in, userCodeClassLoader, false);
} | [
"public",
"static",
"<",
"T",
">",
"TypeSerializer",
"<",
"T",
">",
"tryReadSerializer",
"(",
"DataInputView",
"in",
",",
"ClassLoader",
"userCodeClassLoader",
")",
"throws",
"IOException",
"{",
"return",
"tryReadSerializer",
"(",
"in",
",",
"userCodeClassLoader",
",",
"false",
")",
";",
"}"
] | Reads from a data input view a {@link TypeSerializer} that was previously
written using {@link #writeSerializer(DataOutputView, TypeSerializer)}.
<p>If deserialization fails for any reason (corrupted serializer bytes, serializer class
no longer in classpath, serializer class no longer valid, etc.), an {@link IOException} is thrown.
@param in the data input view.
@param userCodeClassLoader the user code class loader to use.
@param <T> Data type of the serializer.
@return the deserialized serializer. | [
"Reads",
"from",
"a",
"data",
"input",
"view",
"a",
"{",
"@link",
"TypeSerializer",
"}",
"that",
"was",
"previously",
"written",
"using",
"{",
"@link",
"#writeSerializer",
"(",
"DataOutputView",
"TypeSerializer",
")",
"}",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/typeutils/TypeSerializerSerializationUtil.java#L86-L88 |
grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.hasProperty | public static boolean hasProperty(ClassNode classNode, String propertyName) {
"""
Returns whether a classNode has the specified property or not
@param classNode The ClassNode
@param propertyName The name of the property
@return true if the property exists in the ClassNode
"""
if (classNode == null || !StringUtils.hasText(propertyName)) {
return false;
}
final MethodNode method = classNode.getMethod(GrailsNameUtils.getGetterName(propertyName), Parameter.EMPTY_ARRAY);
if (method != null) return true;
// check read-only field with setter
if( classNode.getField(propertyName) != null && !classNode.getMethods(GrailsNameUtils.getSetterName(propertyName)).isEmpty()) {
return true;
}
for (PropertyNode pn : classNode.getProperties()) {
if (pn.getName().equals(propertyName) && !pn.isPrivate()) {
return true;
}
}
return false;
} | java | public static boolean hasProperty(ClassNode classNode, String propertyName) {
if (classNode == null || !StringUtils.hasText(propertyName)) {
return false;
}
final MethodNode method = classNode.getMethod(GrailsNameUtils.getGetterName(propertyName), Parameter.EMPTY_ARRAY);
if (method != null) return true;
// check read-only field with setter
if( classNode.getField(propertyName) != null && !classNode.getMethods(GrailsNameUtils.getSetterName(propertyName)).isEmpty()) {
return true;
}
for (PropertyNode pn : classNode.getProperties()) {
if (pn.getName().equals(propertyName) && !pn.isPrivate()) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasProperty",
"(",
"ClassNode",
"classNode",
",",
"String",
"propertyName",
")",
"{",
"if",
"(",
"classNode",
"==",
"null",
"||",
"!",
"StringUtils",
".",
"hasText",
"(",
"propertyName",
")",
")",
"{",
"return",
"false",
";",
"}",
"final",
"MethodNode",
"method",
"=",
"classNode",
".",
"getMethod",
"(",
"GrailsNameUtils",
".",
"getGetterName",
"(",
"propertyName",
")",
",",
"Parameter",
".",
"EMPTY_ARRAY",
")",
";",
"if",
"(",
"method",
"!=",
"null",
")",
"return",
"true",
";",
"// check read-only field with setter",
"if",
"(",
"classNode",
".",
"getField",
"(",
"propertyName",
")",
"!=",
"null",
"&&",
"!",
"classNode",
".",
"getMethods",
"(",
"GrailsNameUtils",
".",
"getSetterName",
"(",
"propertyName",
")",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"for",
"(",
"PropertyNode",
"pn",
":",
"classNode",
".",
"getProperties",
"(",
")",
")",
"{",
"if",
"(",
"pn",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"propertyName",
")",
"&&",
"!",
"pn",
".",
"isPrivate",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns whether a classNode has the specified property or not
@param classNode The ClassNode
@param propertyName The name of the property
@return true if the property exists in the ClassNode | [
"Returns",
"whether",
"a",
"classNode",
"has",
"the",
"specified",
"property",
"or",
"not"
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L118-L138 |
craftercms/deployer | src/main/java/org/craftercms/deployer/utils/ConfigUtils.java | ConfigUtils.getIntegerProperty | public static Integer getIntegerProperty(Configuration config, String key) throws DeployerConfigurationException {
"""
Returns the specified Integer property from the configuration
@param config the configuration
@param key the key of the property
@return the Integer value of the property, or null if not found
@throws DeployerConfigurationException if an error occurred
"""
return getIntegerProperty(config, key, null);
} | java | public static Integer getIntegerProperty(Configuration config, String key) throws DeployerConfigurationException {
return getIntegerProperty(config, key, null);
} | [
"public",
"static",
"Integer",
"getIntegerProperty",
"(",
"Configuration",
"config",
",",
"String",
"key",
")",
"throws",
"DeployerConfigurationException",
"{",
"return",
"getIntegerProperty",
"(",
"config",
",",
"key",
",",
"null",
")",
";",
"}"
] | Returns the specified Integer property from the configuration
@param config the configuration
@param key the key of the property
@return the Integer value of the property, or null if not found
@throws DeployerConfigurationException if an error occurred | [
"Returns",
"the",
"specified",
"Integer",
"property",
"from",
"the",
"configuration"
] | train | https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/utils/ConfigUtils.java#L170-L172 |
filosganga/geogson | core/src/main/java/com/github/filosganga/geogson/model/Polygon.java | Polygon.of | public static Polygon of(LinearRing perimeter, Stream<LinearRing> holes) {
"""
Creates a Polygon from the given perimeter and holes.
@param perimeter The perimeter {@link LinearRing}.
@param holes The holes {@link LinearRing} Stream.
@return Polygon
"""
return new Polygon(AreaPositions.builder()
.addLinearPosition(perimeter.positions())
.addLinearPositions(holes
.map(LinearRing::positions)::iterator)
.build());
} | java | public static Polygon of(LinearRing perimeter, Stream<LinearRing> holes) {
return new Polygon(AreaPositions.builder()
.addLinearPosition(perimeter.positions())
.addLinearPositions(holes
.map(LinearRing::positions)::iterator)
.build());
} | [
"public",
"static",
"Polygon",
"of",
"(",
"LinearRing",
"perimeter",
",",
"Stream",
"<",
"LinearRing",
">",
"holes",
")",
"{",
"return",
"new",
"Polygon",
"(",
"AreaPositions",
".",
"builder",
"(",
")",
".",
"addLinearPosition",
"(",
"perimeter",
".",
"positions",
"(",
")",
")",
".",
"addLinearPositions",
"(",
"holes",
".",
"map",
"(",
"LinearRing",
"::",
"positions",
")",
"::",
"iterator",
")",
".",
"build",
"(",
")",
")",
";",
"}"
] | Creates a Polygon from the given perimeter and holes.
@param perimeter The perimeter {@link LinearRing}.
@param holes The holes {@link LinearRing} Stream.
@return Polygon | [
"Creates",
"a",
"Polygon",
"from",
"the",
"given",
"perimeter",
"and",
"holes",
"."
] | train | https://github.com/filosganga/geogson/blob/f0c7b0adfecc174caa8a03a6c19d301c7a47d4a0/core/src/main/java/com/github/filosganga/geogson/model/Polygon.java#L76-L83 |
arquillian/arquillian-extension-warp | impl/src/main/java/org/jboss/arquillian/warp/impl/client/execution/SecurityActions.java | SecurityActions.newInstance | static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments,
final Class<T> expectedType) {
"""
Create a new instance by finding a constructor that matches the argumentTypes signature using the arguments for
instantiation.
@param className
Full classname of class to create
@param argumentTypes
The constructor argument types
@param arguments
The constructor arguments
@return a new instance
@throws IllegalArgumentException
if className, argumentTypes, or arguments are null
@throws RuntimeException
if any exceptions during creation
@author <a href="mailto:[email protected]">Aslak Knutsen</a>
@author <a href="mailto:[email protected]">ALR</a>
"""
if (className == null) {
throw new IllegalArgumentException("ClassName must be specified");
}
if (argumentTypes == null) {
throw new IllegalArgumentException("ArgumentTypes must be specified. Use empty array if no arguments");
}
if (arguments == null) {
throw new IllegalArgumentException("Arguments must be specified. Use empty array if no arguments");
}
final Object obj;
try {
final ClassLoader tccl = getThreadContextClassLoader();
final Class<?> implClass = Class.forName(className, false, tccl);
Constructor<?> constructor = getConstructor(implClass, argumentTypes);
obj = constructor.newInstance(arguments);
} catch (Exception e) {
throw new RuntimeException(
"Could not create new instance of " + className + ", missing package from classpath?", e);
}
// Cast
try {
return expectedType.cast(obj);
} catch (final ClassCastException cce) {
// Reconstruct so we get some useful information
throw new ClassCastException("Incorrect expected type, " + expectedType.getName() + ", defined for "
+ obj.getClass().getName());
}
} | java | static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments,
final Class<T> expectedType) {
if (className == null) {
throw new IllegalArgumentException("ClassName must be specified");
}
if (argumentTypes == null) {
throw new IllegalArgumentException("ArgumentTypes must be specified. Use empty array if no arguments");
}
if (arguments == null) {
throw new IllegalArgumentException("Arguments must be specified. Use empty array if no arguments");
}
final Object obj;
try {
final ClassLoader tccl = getThreadContextClassLoader();
final Class<?> implClass = Class.forName(className, false, tccl);
Constructor<?> constructor = getConstructor(implClass, argumentTypes);
obj = constructor.newInstance(arguments);
} catch (Exception e) {
throw new RuntimeException(
"Could not create new instance of " + className + ", missing package from classpath?", e);
}
// Cast
try {
return expectedType.cast(obj);
} catch (final ClassCastException cce) {
// Reconstruct so we get some useful information
throw new ClassCastException("Incorrect expected type, " + expectedType.getName() + ", defined for "
+ obj.getClass().getName());
}
} | [
"static",
"<",
"T",
">",
"T",
"newInstance",
"(",
"final",
"String",
"className",
",",
"final",
"Class",
"<",
"?",
">",
"[",
"]",
"argumentTypes",
",",
"final",
"Object",
"[",
"]",
"arguments",
",",
"final",
"Class",
"<",
"T",
">",
"expectedType",
")",
"{",
"if",
"(",
"className",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"ClassName must be specified\"",
")",
";",
"}",
"if",
"(",
"argumentTypes",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"ArgumentTypes must be specified. Use empty array if no arguments\"",
")",
";",
"}",
"if",
"(",
"arguments",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Arguments must be specified. Use empty array if no arguments\"",
")",
";",
"}",
"final",
"Object",
"obj",
";",
"try",
"{",
"final",
"ClassLoader",
"tccl",
"=",
"getThreadContextClassLoader",
"(",
")",
";",
"final",
"Class",
"<",
"?",
">",
"implClass",
"=",
"Class",
".",
"forName",
"(",
"className",
",",
"false",
",",
"tccl",
")",
";",
"Constructor",
"<",
"?",
">",
"constructor",
"=",
"getConstructor",
"(",
"implClass",
",",
"argumentTypes",
")",
";",
"obj",
"=",
"constructor",
".",
"newInstance",
"(",
"arguments",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not create new instance of \"",
"+",
"className",
"+",
"\", missing package from classpath?\"",
",",
"e",
")",
";",
"}",
"// Cast",
"try",
"{",
"return",
"expectedType",
".",
"cast",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"final",
"ClassCastException",
"cce",
")",
"{",
"// Reconstruct so we get some useful information",
"throw",
"new",
"ClassCastException",
"(",
"\"Incorrect expected type, \"",
"+",
"expectedType",
".",
"getName",
"(",
")",
"+",
"\", defined for \"",
"+",
"obj",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Create a new instance by finding a constructor that matches the argumentTypes signature using the arguments for
instantiation.
@param className
Full classname of class to create
@param argumentTypes
The constructor argument types
@param arguments
The constructor arguments
@return a new instance
@throws IllegalArgumentException
if className, argumentTypes, or arguments are null
@throws RuntimeException
if any exceptions during creation
@author <a href="mailto:[email protected]">Aslak Knutsen</a>
@author <a href="mailto:[email protected]">ALR</a> | [
"Create",
"a",
"new",
"instance",
"by",
"finding",
"a",
"constructor",
"that",
"matches",
"the",
"argumentTypes",
"signature",
"using",
"the",
"arguments",
"for",
"instantiation",
"."
] | train | https://github.com/arquillian/arquillian-extension-warp/blob/e958f4d782851baf7f40e39835d3d1ad185b74dd/impl/src/main/java/org/jboss/arquillian/warp/impl/client/execution/SecurityActions.java#L120-L150 |
Stratio/deep-spark | deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java | Utils.newTypeInstance | @SuppressWarnings("unchecked")
public static <T> T newTypeInstance(String className, Class<T> returnClass) {
"""
Creates a new instance of the given class name.
@param <T> the type parameter
@param className the class object for which a new instance should be created.
@param returnClass the return class
@return the new instance of class clazz.
"""
try {
Class<T> clazz = (Class<T>) Class.forName(className);
return clazz.newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new DeepGenericException(e);
}
} | java | @SuppressWarnings("unchecked")
public static <T> T newTypeInstance(String className, Class<T> returnClass) {
try {
Class<T> clazz = (Class<T>) Class.forName(className);
return clazz.newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new DeepGenericException(e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"newTypeInstance",
"(",
"String",
"className",
",",
"Class",
"<",
"T",
">",
"returnClass",
")",
"{",
"try",
"{",
"Class",
"<",
"T",
">",
"clazz",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"return",
"clazz",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"|",
"IllegalAccessException",
"|",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"DeepGenericException",
"(",
"e",
")",
";",
"}",
"}"
] | Creates a new instance of the given class name.
@param <T> the type parameter
@param className the class object for which a new instance should be created.
@param returnClass the return class
@return the new instance of class clazz. | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"given",
"class",
"name",
"."
] | train | https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L96-L104 |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/function/Actions.java | Actions.toFunc | public static <T1, T2, T3, T4, T5, R> Func5<T1, T2, T3, T4, T5, R> toFunc(
final Action5<T1, T2, T3, T4, T5> action, final R result) {
"""
Converts an {@link Action5} to a function that calls the action and returns a specified value.
@param action the {@link Action5} to convert
@param result the value to return from the function call
@return a {@link Func5} that calls {@code action} and returns {@code result}
"""
return new Func5<T1, T2, T3, T4, T5, R>() {
@Override
public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
action.call(t1, t2, t3, t4, t5);
return result;
}
};
} | java | public static <T1, T2, T3, T4, T5, R> Func5<T1, T2, T3, T4, T5, R> toFunc(
final Action5<T1, T2, T3, T4, T5> action, final R result) {
return new Func5<T1, T2, T3, T4, T5, R>() {
@Override
public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
action.call(t1, t2, t3, t4, t5);
return result;
}
};
} | [
"public",
"static",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
",",
"R",
">",
"Func5",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
",",
"R",
">",
"toFunc",
"(",
"final",
"Action5",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
">",
"action",
",",
"final",
"R",
"result",
")",
"{",
"return",
"new",
"Func5",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
",",
"R",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"R",
"call",
"(",
"T1",
"t1",
",",
"T2",
"t2",
",",
"T3",
"t3",
",",
"T4",
"t4",
",",
"T5",
"t5",
")",
"{",
"action",
".",
"call",
"(",
"t1",
",",
"t2",
",",
"t3",
",",
"t4",
",",
"t5",
")",
";",
"return",
"result",
";",
"}",
"}",
";",
"}"
] | Converts an {@link Action5} to a function that calls the action and returns a specified value.
@param action the {@link Action5} to convert
@param result the value to return from the function call
@return a {@link Func5} that calls {@code action} and returns {@code result} | [
"Converts",
"an",
"{",
"@link",
"Action5",
"}",
"to",
"a",
"function",
"that",
"calls",
"the",
"action",
"and",
"returns",
"a",
"specified",
"value",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/function/Actions.java#L287-L296 |
alkacon/opencms-core | src/org/opencms/jsp/CmsJspNavBuilder.java | CmsJspNavBuilder.getNavigationForResource | public CmsJspNavElement getNavigationForResource(String sitePath) {
"""
Returns a navigation element for the named resource.<p>
@param sitePath the resource name to get the navigation information for,
must be a full path name, e.g. "/docs/index.html"
@return a navigation element for the given resource
"""
CmsJspNavElement result = getNavigationForResource(sitePath, CmsResourceFilter.DEFAULT, false);
if ((result != null) && (result.getNavContext() == null)) {
result.setNavContext(new NavContext(this, Visibility.navigation, CmsResourceFilter.DEFAULT));
}
return result;
} | java | public CmsJspNavElement getNavigationForResource(String sitePath) {
CmsJspNavElement result = getNavigationForResource(sitePath, CmsResourceFilter.DEFAULT, false);
if ((result != null) && (result.getNavContext() == null)) {
result.setNavContext(new NavContext(this, Visibility.navigation, CmsResourceFilter.DEFAULT));
}
return result;
} | [
"public",
"CmsJspNavElement",
"getNavigationForResource",
"(",
"String",
"sitePath",
")",
"{",
"CmsJspNavElement",
"result",
"=",
"getNavigationForResource",
"(",
"sitePath",
",",
"CmsResourceFilter",
".",
"DEFAULT",
",",
"false",
")",
";",
"if",
"(",
"(",
"result",
"!=",
"null",
")",
"&&",
"(",
"result",
".",
"getNavContext",
"(",
")",
"==",
"null",
")",
")",
"{",
"result",
".",
"setNavContext",
"(",
"new",
"NavContext",
"(",
"this",
",",
"Visibility",
".",
"navigation",
",",
"CmsResourceFilter",
".",
"DEFAULT",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Returns a navigation element for the named resource.<p>
@param sitePath the resource name to get the navigation information for,
must be a full path name, e.g. "/docs/index.html"
@return a navigation element for the given resource | [
"Returns",
"a",
"navigation",
"element",
"for",
"the",
"named",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/CmsJspNavBuilder.java#L589-L596 |
MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java | ImageHandlerBuilder.cropToAspect | public ImageHandlerBuilder cropToAspect(int width, int height) {
"""
Crop the image to a given aspect.
<br>
The aspect is the desired proportions of the image, which will be kept when cropping.
<p>
The usecase for this method is when you have an image, that you want to crop into a certain proportion,
but want to keep the original dimensions as much as possible.
@param width
@param height
@return
"""
int original_width = image.getWidth();
int original_height = image.getHeight();
int bound_width = width;
int bound_height = height;
int new_width = original_width;
int new_height = original_height;
int x = 0, y = 0;
// We need these if any resizing is going to happen, as the precision factors
// are no longer sufficiently precise
double wfactor = (double)original_width/bound_width;
double hfactor = (double)original_height/bound_height;
// Calculating the factor between the original dimensions and the wanted dimensions
// Using precision down to two decimals.
double precision = 100d;
double wprecisionfactor = ((int)((wfactor) * precision)) / precision;
double hprecisionfactor = ((int)((hfactor) * precision)) / precision;
if (wprecisionfactor == hprecisionfactor) {
// they are (relatively) equal
// just use the original image dimensions
return this;
}
if (wprecisionfactor < hprecisionfactor) {
// keep the original width
// calculate the new height from the wfactor
new_height = (int) (bound_height * wfactor);
// calculate new coordinate to keep center
y = Math.abs(original_height - new_height) >> 1; // divide by 2
} else if (wprecisionfactor > hprecisionfactor) {
// keep the original height
// calculate the new width from the hfactor
new_width = (int) (bound_width * hfactor);
// calculate new coordinate to keep center
x = Math.abs(original_width - new_width) >> 1; // divide by 2
}
BufferedImage crop = Scalr.crop(image, x, y, new_width, new_height);
image.flush();// cannot throw
image = crop;
return this;
} | java | public ImageHandlerBuilder cropToAspect(int width, int height) {
int original_width = image.getWidth();
int original_height = image.getHeight();
int bound_width = width;
int bound_height = height;
int new_width = original_width;
int new_height = original_height;
int x = 0, y = 0;
// We need these if any resizing is going to happen, as the precision factors
// are no longer sufficiently precise
double wfactor = (double)original_width/bound_width;
double hfactor = (double)original_height/bound_height;
// Calculating the factor between the original dimensions and the wanted dimensions
// Using precision down to two decimals.
double precision = 100d;
double wprecisionfactor = ((int)((wfactor) * precision)) / precision;
double hprecisionfactor = ((int)((hfactor) * precision)) / precision;
if (wprecisionfactor == hprecisionfactor) {
// they are (relatively) equal
// just use the original image dimensions
return this;
}
if (wprecisionfactor < hprecisionfactor) {
// keep the original width
// calculate the new height from the wfactor
new_height = (int) (bound_height * wfactor);
// calculate new coordinate to keep center
y = Math.abs(original_height - new_height) >> 1; // divide by 2
} else if (wprecisionfactor > hprecisionfactor) {
// keep the original height
// calculate the new width from the hfactor
new_width = (int) (bound_width * hfactor);
// calculate new coordinate to keep center
x = Math.abs(original_width - new_width) >> 1; // divide by 2
}
BufferedImage crop = Scalr.crop(image, x, y, new_width, new_height);
image.flush();// cannot throw
image = crop;
return this;
} | [
"public",
"ImageHandlerBuilder",
"cropToAspect",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"int",
"original_width",
"=",
"image",
".",
"getWidth",
"(",
")",
";",
"int",
"original_height",
"=",
"image",
".",
"getHeight",
"(",
")",
";",
"int",
"bound_width",
"=",
"width",
";",
"int",
"bound_height",
"=",
"height",
";",
"int",
"new_width",
"=",
"original_width",
";",
"int",
"new_height",
"=",
"original_height",
";",
"int",
"x",
"=",
"0",
",",
"y",
"=",
"0",
";",
"// We need these if any resizing is going to happen, as the precision factors",
"// are no longer sufficiently precise",
"double",
"wfactor",
"=",
"(",
"double",
")",
"original_width",
"/",
"bound_width",
";",
"double",
"hfactor",
"=",
"(",
"double",
")",
"original_height",
"/",
"bound_height",
";",
"// Calculating the factor between the original dimensions and the wanted dimensions",
"// Using precision down to two decimals.",
"double",
"precision",
"=",
"100d",
";",
"double",
"wprecisionfactor",
"=",
"(",
"(",
"int",
")",
"(",
"(",
"wfactor",
")",
"*",
"precision",
")",
")",
"/",
"precision",
";",
"double",
"hprecisionfactor",
"=",
"(",
"(",
"int",
")",
"(",
"(",
"hfactor",
")",
"*",
"precision",
")",
")",
"/",
"precision",
";",
"if",
"(",
"wprecisionfactor",
"==",
"hprecisionfactor",
")",
"{",
"// they are (relatively) equal",
"// just use the original image dimensions",
"return",
"this",
";",
"}",
"if",
"(",
"wprecisionfactor",
"<",
"hprecisionfactor",
")",
"{",
"// keep the original width",
"// calculate the new height from the wfactor",
"new_height",
"=",
"(",
"int",
")",
"(",
"bound_height",
"*",
"wfactor",
")",
";",
"// calculate new coordinate to keep center",
"y",
"=",
"Math",
".",
"abs",
"(",
"original_height",
"-",
"new_height",
")",
">>",
"1",
";",
"// divide by 2",
"}",
"else",
"if",
"(",
"wprecisionfactor",
">",
"hprecisionfactor",
")",
"{",
"// keep the original height",
"// calculate the new width from the hfactor",
"new_width",
"=",
"(",
"int",
")",
"(",
"bound_width",
"*",
"hfactor",
")",
";",
"// calculate new coordinate to keep center",
"x",
"=",
"Math",
".",
"abs",
"(",
"original_width",
"-",
"new_width",
")",
">>",
"1",
";",
"// divide by 2",
"}",
"BufferedImage",
"crop",
"=",
"Scalr",
".",
"crop",
"(",
"image",
",",
"x",
",",
"y",
",",
"new_width",
",",
"new_height",
")",
";",
"image",
".",
"flush",
"(",
")",
";",
"// cannot throw",
"image",
"=",
"crop",
";",
"return",
"this",
";",
"}"
] | Crop the image to a given aspect.
<br>
The aspect is the desired proportions of the image, which will be kept when cropping.
<p>
The usecase for this method is when you have an image, that you want to crop into a certain proportion,
but want to keep the original dimensions as much as possible.
@param width
@param height
@return | [
"Crop",
"the",
"image",
"to",
"a",
"given",
"aspect",
".",
"<br",
">",
"The",
"aspect",
"is",
"the",
"desired",
"proportions",
"of",
"the",
"image",
"which",
"will",
"be",
"kept",
"when",
"cropping",
".",
"<p",
">",
"The",
"usecase",
"for",
"this",
"method",
"is",
"when",
"you",
"have",
"an",
"image",
"that",
"you",
"want",
"to",
"crop",
"into",
"a",
"certain",
"proportion",
"but",
"want",
"to",
"keep",
"the",
"original",
"dimensions",
"as",
"much",
"as",
"possible",
"."
] | train | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L123-L171 |
hector-client/hector | core/src/main/java/me/prettyprint/hector/api/factory/HFactory.java | HFactory.createKeyspace | public static Keyspace createKeyspace(String keyspace, Cluster cluster,
ConsistencyLevelPolicy consistencyLevelPolicy,
FailoverPolicy failoverPolicy) {
"""
Creates a Keyspace with the given consistency level. For a reference
to the consistency level, please refer to http://wiki.apache.org/cassandra/API.
@param keyspace
@param cluster
@param consistencyLevelPolicy
@param failoverPolicy
@return
"""
return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(),
consistencyLevelPolicy, failoverPolicy, cluster.getCredentials());
} | java | public static Keyspace createKeyspace(String keyspace, Cluster cluster,
ConsistencyLevelPolicy consistencyLevelPolicy,
FailoverPolicy failoverPolicy) {
return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(),
consistencyLevelPolicy, failoverPolicy, cluster.getCredentials());
} | [
"public",
"static",
"Keyspace",
"createKeyspace",
"(",
"String",
"keyspace",
",",
"Cluster",
"cluster",
",",
"ConsistencyLevelPolicy",
"consistencyLevelPolicy",
",",
"FailoverPolicy",
"failoverPolicy",
")",
"{",
"return",
"new",
"ExecutingKeyspace",
"(",
"keyspace",
",",
"cluster",
".",
"getConnectionManager",
"(",
")",
",",
"consistencyLevelPolicy",
",",
"failoverPolicy",
",",
"cluster",
".",
"getCredentials",
"(",
")",
")",
";",
"}"
] | Creates a Keyspace with the given consistency level. For a reference
to the consistency level, please refer to http://wiki.apache.org/cassandra/API.
@param keyspace
@param cluster
@param consistencyLevelPolicy
@param failoverPolicy
@return | [
"Creates",
"a",
"Keyspace",
"with",
"the",
"given",
"consistency",
"level",
".",
"For",
"a",
"reference",
"to",
"the",
"consistency",
"level",
"please",
"refer",
"to",
"http",
":",
"//",
"wiki",
".",
"apache",
".",
"org",
"/",
"cassandra",
"/",
"API",
"."
] | train | https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/hector/api/factory/HFactory.java#L271-L276 |
alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java | LogBuffer.getFullString | public final String getFullString(final int len, String charsetName) {
"""
Return next fix-length string from buffer without null-terminate
checking. Fix bug #17 {@link https
://github.com/AlibabaTech/canal/issues/17 }
"""
if (position + len > origin + limit) throw new IllegalArgumentException("limit excceed: "
+ (position + len - origin));
try {
String string = new String(buffer, position, len, charsetName);
position += len;
return string;
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("Unsupported encoding: " + charsetName, e);
}
} | java | public final String getFullString(final int len, String charsetName) {
if (position + len > origin + limit) throw new IllegalArgumentException("limit excceed: "
+ (position + len - origin));
try {
String string = new String(buffer, position, len, charsetName);
position += len;
return string;
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("Unsupported encoding: " + charsetName, e);
}
} | [
"public",
"final",
"String",
"getFullString",
"(",
"final",
"int",
"len",
",",
"String",
"charsetName",
")",
"{",
"if",
"(",
"position",
"+",
"len",
">",
"origin",
"+",
"limit",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"limit excceed: \"",
"+",
"(",
"position",
"+",
"len",
"-",
"origin",
")",
")",
";",
"try",
"{",
"String",
"string",
"=",
"new",
"String",
"(",
"buffer",
",",
"position",
",",
"len",
",",
"charsetName",
")",
";",
"position",
"+=",
"len",
";",
"return",
"string",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported encoding: \"",
"+",
"charsetName",
",",
"e",
")",
";",
"}",
"}"
] | Return next fix-length string from buffer without null-terminate
checking. Fix bug #17 {@link https
://github.com/AlibabaTech/canal/issues/17 } | [
"Return",
"next",
"fix",
"-",
"length",
"string",
"from",
"buffer",
"without",
"null",
"-",
"terminate",
"checking",
".",
"Fix",
"bug",
"#17",
"{"
] | train | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/LogBuffer.java#L1122-L1133 |
FedericoPecora/meta-csp-framework | src/main/java/org/metacsp/multi/spatial/DE9IM/DE9IMRelation.java | DE9IMRelation.getRCC8Relations | public static Type[] getRCC8Relations(GeometricShapeVariable gv1, GeometricShapeVariable gv2) {
"""
Get the RCC8 relation(s) existing between two {@link GeometricShapeVariable}s.
@param gv1 The first {@link GeometricShapeVariable} (the source of the directed edge).
@param gv2 The second {@link GeometricShapeVariable} (the destination of the directed edge).
@return The RCC8 relation(s) existing between the two given {@link GeometricShapeVariable}s.
"""
return getRelations(gv1, gv2, true);
} | java | public static Type[] getRCC8Relations(GeometricShapeVariable gv1, GeometricShapeVariable gv2) {
return getRelations(gv1, gv2, true);
} | [
"public",
"static",
"Type",
"[",
"]",
"getRCC8Relations",
"(",
"GeometricShapeVariable",
"gv1",
",",
"GeometricShapeVariable",
"gv2",
")",
"{",
"return",
"getRelations",
"(",
"gv1",
",",
"gv2",
",",
"true",
")",
";",
"}"
] | Get the RCC8 relation(s) existing between two {@link GeometricShapeVariable}s.
@param gv1 The first {@link GeometricShapeVariable} (the source of the directed edge).
@param gv2 The second {@link GeometricShapeVariable} (the destination of the directed edge).
@return The RCC8 relation(s) existing between the two given {@link GeometricShapeVariable}s. | [
"Get",
"the",
"RCC8",
"relation",
"(",
"s",
")",
"existing",
"between",
"two",
"{"
] | train | https://github.com/FedericoPecora/meta-csp-framework/blob/42aaef2e2b76d0f738427f0dd9653c4f62b40517/src/main/java/org/metacsp/multi/spatial/DE9IM/DE9IMRelation.java#L67-L69 |
acromusashi/acromusashi-stream-ml | src/main/java/acromusashi/stream/ml/anomaly/lof/LofCalculator.java | LofCalculator.calculateReachDistance | protected static double calculateReachDistance(LofPoint basePoint, LofPoint targetPoint) {
"""
basePointのtargetPointに関する到達可能距離(Reachability distance)を算出する。
@param basePoint 算出元対象点
@param targetPoint 算出先対象点
@return 到達可能距離
"""
double distance = MathUtils.distance(basePoint.getDataPoint(), targetPoint.getDataPoint());
double reachDistance = (double) ComparatorUtils.max(distance, targetPoint.getkDistance(),
ComparatorUtils.NATURAL_COMPARATOR);
return reachDistance;
} | java | protected static double calculateReachDistance(LofPoint basePoint, LofPoint targetPoint)
{
double distance = MathUtils.distance(basePoint.getDataPoint(), targetPoint.getDataPoint());
double reachDistance = (double) ComparatorUtils.max(distance, targetPoint.getkDistance(),
ComparatorUtils.NATURAL_COMPARATOR);
return reachDistance;
} | [
"protected",
"static",
"double",
"calculateReachDistance",
"(",
"LofPoint",
"basePoint",
",",
"LofPoint",
"targetPoint",
")",
"{",
"double",
"distance",
"=",
"MathUtils",
".",
"distance",
"(",
"basePoint",
".",
"getDataPoint",
"(",
")",
",",
"targetPoint",
".",
"getDataPoint",
"(",
")",
")",
";",
"double",
"reachDistance",
"=",
"(",
"double",
")",
"ComparatorUtils",
".",
"max",
"(",
"distance",
",",
"targetPoint",
".",
"getkDistance",
"(",
")",
",",
"ComparatorUtils",
".",
"NATURAL_COMPARATOR",
")",
";",
"return",
"reachDistance",
";",
"}"
] | basePointのtargetPointに関する到達可能距離(Reachability distance)を算出する。
@param basePoint 算出元対象点
@param targetPoint 算出先対象点
@return 到達可能距離 | [
"basePointのtargetPointに関する到達可能距離",
"(",
"Reachability",
"distance",
")",
"を算出する。"
] | train | https://github.com/acromusashi/acromusashi-stream-ml/blob/26d6799a917cacda68e21d506c75cfeb17d832a6/src/main/java/acromusashi/stream/ml/anomaly/lof/LofCalculator.java#L365-L372 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.checkIfMultipleOf8AndGT0 | public static void checkIfMultipleOf8AndGT0(final long v, final String argName) {
"""
Checks if parameter v is a multiple of 8 and greater than zero.
@param v The parameter to check
@param argName This name will be part of the error message if the check fails.
"""
if (((v & 0X7L) == 0L) && (v > 0L)) {
return;
}
throw new SketchesArgumentException("The value of the parameter \"" + argName
+ "\" must be a positive multiple of 8 and greater than zero: " + v);
} | java | public static void checkIfMultipleOf8AndGT0(final long v, final String argName) {
if (((v & 0X7L) == 0L) && (v > 0L)) {
return;
}
throw new SketchesArgumentException("The value of the parameter \"" + argName
+ "\" must be a positive multiple of 8 and greater than zero: " + v);
} | [
"public",
"static",
"void",
"checkIfMultipleOf8AndGT0",
"(",
"final",
"long",
"v",
",",
"final",
"String",
"argName",
")",
"{",
"if",
"(",
"(",
"(",
"v",
"&",
"0X7",
"L",
")",
"==",
"0L",
")",
"&&",
"(",
"v",
">",
"0L",
")",
")",
"{",
"return",
";",
"}",
"throw",
"new",
"SketchesArgumentException",
"(",
"\"The value of the parameter \\\"\"",
"+",
"argName",
"+",
"\"\\\" must be a positive multiple of 8 and greater than zero: \"",
"+",
"v",
")",
";",
"}"
] | Checks if parameter v is a multiple of 8 and greater than zero.
@param v The parameter to check
@param argName This name will be part of the error message if the check fails. | [
"Checks",
"if",
"parameter",
"v",
"is",
"a",
"multiple",
"of",
"8",
"and",
"greater",
"than",
"zero",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L330-L336 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/bos/BosClient.java | BosClient.getObjectMetadata | public ObjectMetadata getObjectMetadata(String bucketName, String key) {
"""
Gets the metadata for the specified Bos object without actually fetching the object itself.
This is useful in obtaining only the object metadata, and avoids wasting bandwidth on fetching
the object data.
<p>
The object metadata contains information such as content type, content disposition, etc.,
as well as custom user metadata that can be associated with an object in Bos.
@param bucketName The name of the bucket containing the object's whose metadata is being retrieved.
@param key The key of the object whose metadata is being retrieved.
@return All Bos object metadata for the specified object.
"""
return this.getObjectMetadata(new GetObjectMetadataRequest(bucketName, key));
} | java | public ObjectMetadata getObjectMetadata(String bucketName, String key) {
return this.getObjectMetadata(new GetObjectMetadataRequest(bucketName, key));
} | [
"public",
"ObjectMetadata",
"getObjectMetadata",
"(",
"String",
"bucketName",
",",
"String",
"key",
")",
"{",
"return",
"this",
".",
"getObjectMetadata",
"(",
"new",
"GetObjectMetadataRequest",
"(",
"bucketName",
",",
"key",
")",
")",
";",
"}"
] | Gets the metadata for the specified Bos object without actually fetching the object itself.
This is useful in obtaining only the object metadata, and avoids wasting bandwidth on fetching
the object data.
<p>
The object metadata contains information such as content type, content disposition, etc.,
as well as custom user metadata that can be associated with an object in Bos.
@param bucketName The name of the bucket containing the object's whose metadata is being retrieved.
@param key The key of the object whose metadata is being retrieved.
@return All Bos object metadata for the specified object. | [
"Gets",
"the",
"metadata",
"for",
"the",
"specified",
"Bos",
"object",
"without",
"actually",
"fetching",
"the",
"object",
"itself",
".",
"This",
"is",
"useful",
"in",
"obtaining",
"only",
"the",
"object",
"metadata",
"and",
"avoids",
"wasting",
"bandwidth",
"on",
"fetching",
"the",
"object",
"data",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bos/BosClient.java#L757-L759 |
FlyingHe/UtilsMaven | src/main/java/com/github/flyinghe/tools/WriteExcelUtils.java | WriteExcelUtils.writeWorkBook | public static <T> void writeWorkBook(File file, int excelType, List<T> beans) throws WriteExcelException {
"""
向工作簿中写入beans,所有bean写在一个Sheet中,默认以bean中的所有属性作为标题且写入第0行,0-based。
日期格式采用默认类型。并输出到指定file中
@param file 指定Excel输出文件
@param excelType 输出Excel文件类型{@link #XLSX}或者{@link #XLS},此类型必须与file文件名后缀匹配
@param beans 指定写入的Beans(或者泛型为Map)
@throws WriteExcelException
"""
WriteExcelUtils.writeWorkBook(file, excelType, beans, null);
} | java | public static <T> void writeWorkBook(File file, int excelType, List<T> beans) throws WriteExcelException {
WriteExcelUtils.writeWorkBook(file, excelType, beans, null);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"writeWorkBook",
"(",
"File",
"file",
",",
"int",
"excelType",
",",
"List",
"<",
"T",
">",
"beans",
")",
"throws",
"WriteExcelException",
"{",
"WriteExcelUtils",
".",
"writeWorkBook",
"(",
"file",
",",
"excelType",
",",
"beans",
",",
"null",
")",
";",
"}"
] | 向工作簿中写入beans,所有bean写在一个Sheet中,默认以bean中的所有属性作为标题且写入第0行,0-based。
日期格式采用默认类型。并输出到指定file中
@param file 指定Excel输出文件
@param excelType 输出Excel文件类型{@link #XLSX}或者{@link #XLS},此类型必须与file文件名后缀匹配
@param beans 指定写入的Beans(或者泛型为Map)
@throws WriteExcelException | [
"向工作簿中写入beans,所有bean写在一个Sheet中",
"默认以bean中的所有属性作为标题且写入第0行,0",
"-",
"based。",
"日期格式采用默认类型。并输出到指定file中"
] | train | https://github.com/FlyingHe/UtilsMaven/blob/d9605b7bfe0c28a05289252e12d163e114080b4a/src/main/java/com/github/flyinghe/tools/WriteExcelUtils.java#L269-L271 |
nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/JavaBean.java | JavaBean.getProperty | @SuppressWarnings("unchecked")
public static <T> T getProperty(Object bean, String name)
throws SystemException {
"""
Retrieve the bean property
@param bean the bean
@param name the property name
@param <T> the type class of the property for casting
@return the property
@throws SystemException the an unknown error occurs
"""
try
{
return (T)getNestedProperty(bean, name);
}
catch (Exception e)
{
throw new SystemException("Get property \""+name+"\" ERROR:"+e.getMessage(),e);
}
} | java | @SuppressWarnings("unchecked")
public static <T> T getProperty(Object bean, String name)
throws SystemException
{
try
{
return (T)getNestedProperty(bean, name);
}
catch (Exception e)
{
throw new SystemException("Get property \""+name+"\" ERROR:"+e.getMessage(),e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"getProperty",
"(",
"Object",
"bean",
",",
"String",
"name",
")",
"throws",
"SystemException",
"{",
"try",
"{",
"return",
"(",
"T",
")",
"getNestedProperty",
"(",
"bean",
",",
"name",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"Get property \\\"\"",
"+",
"name",
"+",
"\"\\\" ERROR:\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Retrieve the bean property
@param bean the bean
@param name the property name
@param <T> the type class of the property for casting
@return the property
@throws SystemException the an unknown error occurs | [
"Retrieve",
"the",
"bean",
"property"
] | train | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/JavaBean.java#L463-L475 |
selenide/selenide | src/main/java/com/codeborne/selenide/Condition.java | Condition.cssValue | public static Condition cssValue(final String propertyName, final String expectedValue) {
"""
Checks if css property (style) applies for the element.
Both explicit and computed properties are supported.
<p>
Note that if css property is missing {@link WebElement#getCssValue} return empty string.
In this case you should assert against empty string.
<p>
Sample:
<p>
{@code <input style="font-size: 12">}
<p>
{@code $("input").shouldHave(cssValue("font-size", "12"));}
<p>
{@code $("input").shouldHave(cssValue("display", "block"));}
@param propertyName the css property (style) name of the element
@param expectedValue expected value of css property
@see WebElement#getCssValue
"""
return new Condition("cssValue") {
@Override
public boolean apply(Driver driver, WebElement element) {
String actualValue = element.getCssValue(propertyName);
return defaultString(expectedValue).equalsIgnoreCase(defaultString(actualValue));
}
@Override
public String actualValue(Driver driver, WebElement element) {
return element.getCssValue(propertyName);
}
@Override
public String toString() {
return name + " " + propertyName + '=' + expectedValue;
}
};
} | java | public static Condition cssValue(final String propertyName, final String expectedValue) {
return new Condition("cssValue") {
@Override
public boolean apply(Driver driver, WebElement element) {
String actualValue = element.getCssValue(propertyName);
return defaultString(expectedValue).equalsIgnoreCase(defaultString(actualValue));
}
@Override
public String actualValue(Driver driver, WebElement element) {
return element.getCssValue(propertyName);
}
@Override
public String toString() {
return name + " " + propertyName + '=' + expectedValue;
}
};
} | [
"public",
"static",
"Condition",
"cssValue",
"(",
"final",
"String",
"propertyName",
",",
"final",
"String",
"expectedValue",
")",
"{",
"return",
"new",
"Condition",
"(",
"\"cssValue\"",
")",
"{",
"@",
"Override",
"public",
"boolean",
"apply",
"(",
"Driver",
"driver",
",",
"WebElement",
"element",
")",
"{",
"String",
"actualValue",
"=",
"element",
".",
"getCssValue",
"(",
"propertyName",
")",
";",
"return",
"defaultString",
"(",
"expectedValue",
")",
".",
"equalsIgnoreCase",
"(",
"defaultString",
"(",
"actualValue",
")",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"actualValue",
"(",
"Driver",
"driver",
",",
"WebElement",
"element",
")",
"{",
"return",
"element",
".",
"getCssValue",
"(",
"propertyName",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"name",
"+",
"\" \"",
"+",
"propertyName",
"+",
"'",
"'",
"+",
"expectedValue",
";",
"}",
"}",
";",
"}"
] | Checks if css property (style) applies for the element.
Both explicit and computed properties are supported.
<p>
Note that if css property is missing {@link WebElement#getCssValue} return empty string.
In this case you should assert against empty string.
<p>
Sample:
<p>
{@code <input style="font-size: 12">}
<p>
{@code $("input").shouldHave(cssValue("font-size", "12"));}
<p>
{@code $("input").shouldHave(cssValue("display", "block"));}
@param propertyName the css property (style) name of the element
@param expectedValue expected value of css property
@see WebElement#getCssValue | [
"Checks",
"if",
"css",
"property",
"(",
"style",
")",
"applies",
"for",
"the",
"element",
".",
"Both",
"explicit",
"and",
"computed",
"properties",
"are",
"supported",
".",
"<p",
">",
"Note",
"that",
"if",
"css",
"property",
"is",
"missing",
"{",
"@link",
"WebElement#getCssValue",
"}",
"return",
"empty",
"string",
".",
"In",
"this",
"case",
"you",
"should",
"assert",
"against",
"empty",
"string",
".",
"<p",
">",
"Sample",
":",
"<p",
">",
"{",
"@code",
"<input",
"style",
"=",
"font",
"-",
"size",
":",
"12",
">",
"}",
"<p",
">",
"{",
"@code",
"$",
"(",
"input",
")",
".",
"shouldHave",
"(",
"cssValue",
"(",
"font",
"-",
"size",
"12",
"))",
";",
"}",
"<p",
">",
"{",
"@code",
"$",
"(",
"input",
")",
".",
"shouldHave",
"(",
"cssValue",
"(",
"display",
"block",
"))",
";",
"}"
] | train | https://github.com/selenide/selenide/blob/b867baf171942cf07725d83a985237428569883f/src/main/java/com/codeborne/selenide/Condition.java#L401-L419 |
google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java | BytecodeUtils.newHashMap | public static Expression newHashMap(
Iterable<? extends Expression> keys, Iterable<? extends Expression> values) {
"""
Returns an expression that returns a new {@link HashMap} containing all the given entries.
"""
return newMap(keys, values, ConstructorRef.HASH_MAP_CAPACITY, HASH_MAP_TYPE);
} | java | public static Expression newHashMap(
Iterable<? extends Expression> keys, Iterable<? extends Expression> values) {
return newMap(keys, values, ConstructorRef.HASH_MAP_CAPACITY, HASH_MAP_TYPE);
} | [
"public",
"static",
"Expression",
"newHashMap",
"(",
"Iterable",
"<",
"?",
"extends",
"Expression",
">",
"keys",
",",
"Iterable",
"<",
"?",
"extends",
"Expression",
">",
"values",
")",
"{",
"return",
"newMap",
"(",
"keys",
",",
"values",
",",
"ConstructorRef",
".",
"HASH_MAP_CAPACITY",
",",
"HASH_MAP_TYPE",
")",
";",
"}"
] | Returns an expression that returns a new {@link HashMap} containing all the given entries. | [
"Returns",
"an",
"expression",
"that",
"returns",
"a",
"new",
"{"
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java#L898-L901 |
saxsys/SynchronizeFX | kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/KryoSerializer.java | KryoSerializer.registerSerializableClass | public <T> void registerSerializableClass(final Class<T> clazz, final Serializer<T> serializer) {
"""
Registers a class that may be send over the network.
Use this method only before the first invocation of either {@link KryoSerializer#serialize(List)} or
{@link KryoSerializer#deserialize(byte[])}. If you invoke it after these methods it is not guaranteed that the
{@link Kryo} used by these methods will actually use your serializers.
@param clazz The class that's maybe send.
@param serializer An optional serializer for this class. If it's null than the default serialization of kryo
is used.
@param <T> see clazz parameter.
"""
kryo.registerSerializableClass(clazz, serializer);
} | java | public <T> void registerSerializableClass(final Class<T> clazz, final Serializer<T> serializer) {
kryo.registerSerializableClass(clazz, serializer);
} | [
"public",
"<",
"T",
">",
"void",
"registerSerializableClass",
"(",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"Serializer",
"<",
"T",
">",
"serializer",
")",
"{",
"kryo",
".",
"registerSerializableClass",
"(",
"clazz",
",",
"serializer",
")",
";",
"}"
] | Registers a class that may be send over the network.
Use this method only before the first invocation of either {@link KryoSerializer#serialize(List)} or
{@link KryoSerializer#deserialize(byte[])}. If you invoke it after these methods it is not guaranteed that the
{@link Kryo} used by these methods will actually use your serializers.
@param clazz The class that's maybe send.
@param serializer An optional serializer for this class. If it's null than the default serialization of kryo
is used.
@param <T> see clazz parameter. | [
"Registers",
"a",
"class",
"that",
"may",
"be",
"send",
"over",
"the",
"network",
"."
] | train | https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/KryoSerializer.java#L52-L54 |
smartsheet-platform/smartsheet-java-sdk | src/main/java/com/smartsheet/api/internal/SheetResourcesImpl.java | SheetResourcesImpl.getSheetAsPDF | public void getSheetAsPDF(long id, OutputStream outputStream, PaperSize paperSize) throws SmartsheetException {
"""
Get a sheet as a PDF file.
It mirrors to the following Smartsheet REST API method: GET /sheet/{id} with "application/pdf" Accept HTTP
header
Exceptions:
IllegalArgumentException : if outputStream is null
InvalidRequestException : if there is any problem with the REST API request
AuthorizationException : if there is any problem with the REST API authorization(access token)
ResourceNotFoundException : if the resource can not be found
ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
SmartsheetRestException : if there is any other REST API related error occurred during the operation
SmartsheetException : if there is any other error occurred during the operation
@param id the id
@param outputStream the output stream to which the PDF file will be written.
@param paperSize the optional paper size
@return the sheet as pdf
@throws SmartsheetException the smartsheet exception
"""
getSheetAsFile(id, paperSize, outputStream, "application/pdf");
} | java | public void getSheetAsPDF(long id, OutputStream outputStream, PaperSize paperSize) throws SmartsheetException {
getSheetAsFile(id, paperSize, outputStream, "application/pdf");
} | [
"public",
"void",
"getSheetAsPDF",
"(",
"long",
"id",
",",
"OutputStream",
"outputStream",
",",
"PaperSize",
"paperSize",
")",
"throws",
"SmartsheetException",
"{",
"getSheetAsFile",
"(",
"id",
",",
"paperSize",
",",
"outputStream",
",",
"\"application/pdf\"",
")",
";",
"}"
] | Get a sheet as a PDF file.
It mirrors to the following Smartsheet REST API method: GET /sheet/{id} with "application/pdf" Accept HTTP
header
Exceptions:
IllegalArgumentException : if outputStream is null
InvalidRequestException : if there is any problem with the REST API request
AuthorizationException : if there is any problem with the REST API authorization(access token)
ResourceNotFoundException : if the resource can not be found
ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
SmartsheetRestException : if there is any other REST API related error occurred during the operation
SmartsheetException : if there is any other error occurred during the operation
@param id the id
@param outputStream the output stream to which the PDF file will be written.
@param paperSize the optional paper size
@return the sheet as pdf
@throws SmartsheetException the smartsheet exception | [
"Get",
"a",
"sheet",
"as",
"a",
"PDF",
"file",
"."
] | train | https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/f60e264412076271f83b65889ef9b891fad83df8/src/main/java/com/smartsheet/api/internal/SheetResourcesImpl.java#L363-L365 |
ibm-bluemix-mobile-services/bms-clientsdk-android-core | lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java | AuthorizationProcessManager.createRegistrationParams | private HashMap<String, String> createRegistrationParams() {
"""
Generate the params that will be used during the registration phase
@return Map with all the parameters
"""
registrationKeyPair = KeyPairUtility.generateRandomKeyPair();
JSONObject csrJSON = new JSONObject();
HashMap<String, String> params;
try {
DeviceIdentity deviceData = new BaseDeviceIdentity(preferences.deviceIdentity.getAsMap());
AppIdentity applicationData = new BaseAppIdentity(preferences.appIdentity.getAsMap());
csrJSON.put("deviceId", deviceData.getId());
csrJSON.put("deviceOs", "" + deviceData.getOS());
csrJSON.put("deviceModel", deviceData.getModel());
csrJSON.put("applicationId", applicationData.getId());
csrJSON.put("applicationVersion", applicationData.getVersion());
csrJSON.put("environment", "android");
String csrValue = jsonSigner.sign(registrationKeyPair, csrJSON);
params = new HashMap<>(1);
params.put("CSR", csrValue);
return params;
} catch (Exception e) {
throw new RuntimeException("Failed to create registration params", e);
}
} | java | private HashMap<String, String> createRegistrationParams() {
registrationKeyPair = KeyPairUtility.generateRandomKeyPair();
JSONObject csrJSON = new JSONObject();
HashMap<String, String> params;
try {
DeviceIdentity deviceData = new BaseDeviceIdentity(preferences.deviceIdentity.getAsMap());
AppIdentity applicationData = new BaseAppIdentity(preferences.appIdentity.getAsMap());
csrJSON.put("deviceId", deviceData.getId());
csrJSON.put("deviceOs", "" + deviceData.getOS());
csrJSON.put("deviceModel", deviceData.getModel());
csrJSON.put("applicationId", applicationData.getId());
csrJSON.put("applicationVersion", applicationData.getVersion());
csrJSON.put("environment", "android");
String csrValue = jsonSigner.sign(registrationKeyPair, csrJSON);
params = new HashMap<>(1);
params.put("CSR", csrValue);
return params;
} catch (Exception e) {
throw new RuntimeException("Failed to create registration params", e);
}
} | [
"private",
"HashMap",
"<",
"String",
",",
"String",
">",
"createRegistrationParams",
"(",
")",
"{",
"registrationKeyPair",
"=",
"KeyPairUtility",
".",
"generateRandomKeyPair",
"(",
")",
";",
"JSONObject",
"csrJSON",
"=",
"new",
"JSONObject",
"(",
")",
";",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
";",
"try",
"{",
"DeviceIdentity",
"deviceData",
"=",
"new",
"BaseDeviceIdentity",
"(",
"preferences",
".",
"deviceIdentity",
".",
"getAsMap",
"(",
")",
")",
";",
"AppIdentity",
"applicationData",
"=",
"new",
"BaseAppIdentity",
"(",
"preferences",
".",
"appIdentity",
".",
"getAsMap",
"(",
")",
")",
";",
"csrJSON",
".",
"put",
"(",
"\"deviceId\"",
",",
"deviceData",
".",
"getId",
"(",
")",
")",
";",
"csrJSON",
".",
"put",
"(",
"\"deviceOs\"",
",",
"\"\"",
"+",
"deviceData",
".",
"getOS",
"(",
")",
")",
";",
"csrJSON",
".",
"put",
"(",
"\"deviceModel\"",
",",
"deviceData",
".",
"getModel",
"(",
")",
")",
";",
"csrJSON",
".",
"put",
"(",
"\"applicationId\"",
",",
"applicationData",
".",
"getId",
"(",
")",
")",
";",
"csrJSON",
".",
"put",
"(",
"\"applicationVersion\"",
",",
"applicationData",
".",
"getVersion",
"(",
")",
")",
";",
"csrJSON",
".",
"put",
"(",
"\"environment\"",
",",
"\"android\"",
")",
";",
"String",
"csrValue",
"=",
"jsonSigner",
".",
"sign",
"(",
"registrationKeyPair",
",",
"csrJSON",
")",
";",
"params",
"=",
"new",
"HashMap",
"<>",
"(",
"1",
")",
";",
"params",
".",
"put",
"(",
"\"CSR\"",
",",
"csrValue",
")",
";",
"return",
"params",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to create registration params\"",
",",
"e",
")",
";",
"}",
"}"
] | Generate the params that will be used during the registration phase
@return Map with all the parameters | [
"Generate",
"the",
"params",
"that",
"will",
"be",
"used",
"during",
"the",
"registration",
"phase"
] | train | https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationProcessManager.java#L163-L189 |
czyzby/gdx-lml | kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/scene2d/Actors.java | Actors.setAlpha | public static void setAlpha(final Stage stage, final float alpha) {
"""
Null-safe alpha setting method.
@param stage its root actor's alpha will be modified, affecting all actors in the stage. Can be null.
@param alpha will replace current actor's alpha.
"""
if (stage != null) {
setAlpha(stage.getRoot(), alpha);
}
} | java | public static void setAlpha(final Stage stage, final float alpha) {
if (stage != null) {
setAlpha(stage.getRoot(), alpha);
}
} | [
"public",
"static",
"void",
"setAlpha",
"(",
"final",
"Stage",
"stage",
",",
"final",
"float",
"alpha",
")",
"{",
"if",
"(",
"stage",
"!=",
"null",
")",
"{",
"setAlpha",
"(",
"stage",
".",
"getRoot",
"(",
")",
",",
"alpha",
")",
";",
"}",
"}"
] | Null-safe alpha setting method.
@param stage its root actor's alpha will be modified, affecting all actors in the stage. Can be null.
@param alpha will replace current actor's alpha. | [
"Null",
"-",
"safe",
"alpha",
"setting",
"method",
"."
] | train | https://github.com/czyzby/gdx-lml/blob/7623b322e6afe49ad4dd636c80c230150a1cfa4e/kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/scene2d/Actors.java#L154-L158 |
jinahya/hex-codec | src/main/java/com/github/jinahya/codec/HexDecoder.java | HexDecoder.decodeToString | public String decodeToString(final byte[] input, final String outputCharset)
throws UnsupportedEncodingException {
"""
Decodes given sequence of nibbles into a string.
@param input the nibbles to decode
@param outputCharset the charset name to encode output string
@return the decoded string.
@throws UnsupportedEncodingException if outputCharset is not supported
"""
return new String(decode(input), outputCharset);
} | java | public String decodeToString(final byte[] input, final String outputCharset)
throws UnsupportedEncodingException {
return new String(decode(input), outputCharset);
} | [
"public",
"String",
"decodeToString",
"(",
"final",
"byte",
"[",
"]",
"input",
",",
"final",
"String",
"outputCharset",
")",
"throws",
"UnsupportedEncodingException",
"{",
"return",
"new",
"String",
"(",
"decode",
"(",
"input",
")",
",",
"outputCharset",
")",
";",
"}"
] | Decodes given sequence of nibbles into a string.
@param input the nibbles to decode
@param outputCharset the charset name to encode output string
@return the decoded string.
@throws UnsupportedEncodingException if outputCharset is not supported | [
"Decodes",
"given",
"sequence",
"of",
"nibbles",
"into",
"a",
"string",
"."
] | train | https://github.com/jinahya/hex-codec/blob/159aa54010821655496177e76a3ef35a49fbd433/src/main/java/com/github/jinahya/codec/HexDecoder.java#L218-L222 |
krummas/DrizzleJDBC | src/main/java/org/drizzle/jdbc/DrizzleResultSet.java | DrizzleResultSet.getDate | public Date getDate(final int columnIndex, final Calendar cal) throws SQLException {
"""
Retrieves the value of the designated column in the current row of this <code>ResultSet</code> object as a
<code>java.sql.Date</code> object in the Java programming language. This method uses the given calendar to
construct an appropriate millisecond value for the date if the underlying database does not store timezone
information.
@param columnIndex the first column is 1, the second is 2, ...
@param cal the <code>java.util.Calendar</code> object to use in constructing the date
@return the column value as a <code>java.sql.Date</code> object; if the value is SQL <code>NULL</code>, the value
returned is <code>null</code> in the Java programming language
@throws java.sql.SQLException if the columnIndex is not valid; if a database access error occurs or this method
is called on a closed result set
@since 1.2
"""
try {
return getValueObject(columnIndex).getDate(cal);
} catch (ParseException e) {
throw SQLExceptionMapper.getSQLException("Could not parse as date");
}
} | java | public Date getDate(final int columnIndex, final Calendar cal) throws SQLException {
try {
return getValueObject(columnIndex).getDate(cal);
} catch (ParseException e) {
throw SQLExceptionMapper.getSQLException("Could not parse as date");
}
} | [
"public",
"Date",
"getDate",
"(",
"final",
"int",
"columnIndex",
",",
"final",
"Calendar",
"cal",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"return",
"getValueObject",
"(",
"columnIndex",
")",
".",
"getDate",
"(",
"cal",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"throw",
"SQLExceptionMapper",
".",
"getSQLException",
"(",
"\"Could not parse as date\"",
")",
";",
"}",
"}"
] | Retrieves the value of the designated column in the current row of this <code>ResultSet</code> object as a
<code>java.sql.Date</code> object in the Java programming language. This method uses the given calendar to
construct an appropriate millisecond value for the date if the underlying database does not store timezone
information.
@param columnIndex the first column is 1, the second is 2, ...
@param cal the <code>java.util.Calendar</code> object to use in constructing the date
@return the column value as a <code>java.sql.Date</code> object; if the value is SQL <code>NULL</code>, the value
returned is <code>null</code> in the Java programming language
@throws java.sql.SQLException if the columnIndex is not valid; if a database access error occurs or this method
is called on a closed result set
@since 1.2 | [
"Retrieves",
"the",
"value",
"of",
"the",
"designated",
"column",
"in",
"the",
"current",
"row",
"of",
"this",
"<code",
">",
"ResultSet<",
"/",
"code",
">",
"object",
"as",
"a",
"<code",
">",
"java",
".",
"sql",
".",
"Date<",
"/",
"code",
">",
"object",
"in",
"the",
"Java",
"programming",
"language",
".",
"This",
"method",
"uses",
"the",
"given",
"calendar",
"to",
"construct",
"an",
"appropriate",
"millisecond",
"value",
"for",
"the",
"date",
"if",
"the",
"underlying",
"database",
"does",
"not",
"store",
"timezone",
"information",
"."
] | train | https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleResultSet.java#L2078-L2084 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/config/Config.java | Config.setDurableExecutorConfigs | public Config setDurableExecutorConfigs(Map<String, DurableExecutorConfig> durableExecutorConfigs) {
"""
Sets the map of durable executor configurations, mapped by config name.
The config name may be a pattern with which the configuration will be
obtained in the future.
@param durableExecutorConfigs the durable executor configuration map to set
@return this config instance
"""
this.durableExecutorConfigs.clear();
this.durableExecutorConfigs.putAll(durableExecutorConfigs);
for (Entry<String, DurableExecutorConfig> entry : durableExecutorConfigs.entrySet()) {
entry.getValue().setName(entry.getKey());
}
return this;
} | java | public Config setDurableExecutorConfigs(Map<String, DurableExecutorConfig> durableExecutorConfigs) {
this.durableExecutorConfigs.clear();
this.durableExecutorConfigs.putAll(durableExecutorConfigs);
for (Entry<String, DurableExecutorConfig> entry : durableExecutorConfigs.entrySet()) {
entry.getValue().setName(entry.getKey());
}
return this;
} | [
"public",
"Config",
"setDurableExecutorConfigs",
"(",
"Map",
"<",
"String",
",",
"DurableExecutorConfig",
">",
"durableExecutorConfigs",
")",
"{",
"this",
".",
"durableExecutorConfigs",
".",
"clear",
"(",
")",
";",
"this",
".",
"durableExecutorConfigs",
".",
"putAll",
"(",
"durableExecutorConfigs",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"DurableExecutorConfig",
">",
"entry",
":",
"durableExecutorConfigs",
".",
"entrySet",
"(",
")",
")",
"{",
"entry",
".",
"getValue",
"(",
")",
".",
"setName",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the map of durable executor configurations, mapped by config name.
The config name may be a pattern with which the configuration will be
obtained in the future.
@param durableExecutorConfigs the durable executor configuration map to set
@return this config instance | [
"Sets",
"the",
"map",
"of",
"durable",
"executor",
"configurations",
"mapped",
"by",
"config",
"name",
".",
"The",
"config",
"name",
"may",
"be",
"a",
"pattern",
"with",
"which",
"the",
"configuration",
"will",
"be",
"obtained",
"in",
"the",
"future",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/Config.java#L2181-L2188 |
rwl/CSparseJ | src/main/java/edu/emory/mathcs/csparsej/tdcomplex/DZcs_transpose.java | DZcs_transpose.cs_transpose | public static DZcs cs_transpose(DZcs A, boolean values) {
"""
Computes the transpose of a sparse matrix, C =A';
@param A
column-compressed matrix
@param values
pattern only if false, both pattern and values otherwise
@return C=A', null on error
"""
int p, q, j, Cp[], Ci[], n, m, Ap[], Ai[], w[] ;
DZcsa Cx = new DZcsa(), Ax = new DZcsa() ;
DZcs C ;
if (!CS_CSC (A)) return (null) ; /* check inputs */
m = A.m ; n = A.n ; Ap = A.p ; Ai = A.i ; Ax.x = A.x ;
C = cs_spalloc (n, m, Ap [n], values && (Ax.x != null), false) ; /* allocate result */
w = new int [m] ; /* get workspace */
Cp = C.p ; Ci = C.i ; Cx.x = C.x ;
for (p = 0 ; p < Ap [n] ; p++) w [Ai [p]]++ ; /* row counts */
cs_cumsum (Cp, w, m) ; /* row pointers */
for (j = 0 ; j < n ; j++)
{
for (p = Ap [j] ; p < Ap [j + 1] ; p++)
{
Ci [q = w [Ai [p]]++] = j ; /* place A(i,j) as entry C(j,i) */
if (Cx.x != null)
Cx.set(q, (values) ? cs_conj(Ax.get(p)) : Ax.get(p)) ;
}
}
return (C) ;
} | java | public static DZcs cs_transpose(DZcs A, boolean values)
{
int p, q, j, Cp[], Ci[], n, m, Ap[], Ai[], w[] ;
DZcsa Cx = new DZcsa(), Ax = new DZcsa() ;
DZcs C ;
if (!CS_CSC (A)) return (null) ; /* check inputs */
m = A.m ; n = A.n ; Ap = A.p ; Ai = A.i ; Ax.x = A.x ;
C = cs_spalloc (n, m, Ap [n], values && (Ax.x != null), false) ; /* allocate result */
w = new int [m] ; /* get workspace */
Cp = C.p ; Ci = C.i ; Cx.x = C.x ;
for (p = 0 ; p < Ap [n] ; p++) w [Ai [p]]++ ; /* row counts */
cs_cumsum (Cp, w, m) ; /* row pointers */
for (j = 0 ; j < n ; j++)
{
for (p = Ap [j] ; p < Ap [j + 1] ; p++)
{
Ci [q = w [Ai [p]]++] = j ; /* place A(i,j) as entry C(j,i) */
if (Cx.x != null)
Cx.set(q, (values) ? cs_conj(Ax.get(p)) : Ax.get(p)) ;
}
}
return (C) ;
} | [
"public",
"static",
"DZcs",
"cs_transpose",
"(",
"DZcs",
"A",
",",
"boolean",
"values",
")",
"{",
"int",
"p",
",",
"q",
",",
"j",
",",
"Cp",
"[",
"]",
",",
"Ci",
"[",
"]",
",",
"n",
",",
"m",
",",
"Ap",
"[",
"]",
",",
"Ai",
"[",
"]",
",",
"w",
"[",
"]",
";",
"DZcsa",
"Cx",
"=",
"new",
"DZcsa",
"(",
")",
",",
"Ax",
"=",
"new",
"DZcsa",
"(",
")",
";",
"DZcs",
"C",
";",
"if",
"(",
"!",
"CS_CSC",
"(",
"A",
")",
")",
"return",
"(",
"null",
")",
";",
"/* check inputs */",
"m",
"=",
"A",
".",
"m",
";",
"n",
"=",
"A",
".",
"n",
";",
"Ap",
"=",
"A",
".",
"p",
";",
"Ai",
"=",
"A",
".",
"i",
";",
"Ax",
".",
"x",
"=",
"A",
".",
"x",
";",
"C",
"=",
"cs_spalloc",
"(",
"n",
",",
"m",
",",
"Ap",
"[",
"n",
"]",
",",
"values",
"&&",
"(",
"Ax",
".",
"x",
"!=",
"null",
")",
",",
"false",
")",
";",
"/* allocate result */",
"w",
"=",
"new",
"int",
"[",
"m",
"]",
";",
"/* get workspace */",
"Cp",
"=",
"C",
".",
"p",
";",
"Ci",
"=",
"C",
".",
"i",
";",
"Cx",
".",
"x",
"=",
"C",
".",
"x",
";",
"for",
"(",
"p",
"=",
"0",
";",
"p",
"<",
"Ap",
"[",
"n",
"]",
";",
"p",
"++",
")",
"w",
"[",
"Ai",
"[",
"p",
"]",
"]",
"++",
";",
"/* row counts */",
"cs_cumsum",
"(",
"Cp",
",",
"w",
",",
"m",
")",
";",
"/* row pointers */",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"for",
"(",
"p",
"=",
"Ap",
"[",
"j",
"]",
";",
"p",
"<",
"Ap",
"[",
"j",
"+",
"1",
"]",
";",
"p",
"++",
")",
"{",
"Ci",
"[",
"q",
"=",
"w",
"[",
"Ai",
"[",
"p",
"]",
"]",
"++",
"]",
"=",
"j",
";",
"/* place A(i,j) as entry C(j,i) */",
"if",
"(",
"Cx",
".",
"x",
"!=",
"null",
")",
"Cx",
".",
"set",
"(",
"q",
",",
"(",
"values",
")",
"?",
"cs_conj",
"(",
"Ax",
".",
"get",
"(",
"p",
")",
")",
":",
"Ax",
".",
"get",
"(",
"p",
")",
")",
";",
"}",
"}",
"return",
"(",
"C",
")",
";",
"}"
] | Computes the transpose of a sparse matrix, C =A';
@param A
column-compressed matrix
@param values
pattern only if false, both pattern and values otherwise
@return C=A', null on error | [
"Computes",
"the",
"transpose",
"of",
"a",
"sparse",
"matrix",
"C",
"=",
"A",
";"
] | train | https://github.com/rwl/CSparseJ/blob/6a6f66bccce1558156a961494358952603b0ac84/src/main/java/edu/emory/mathcs/csparsej/tdcomplex/DZcs_transpose.java#L53-L75 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java | ElementsExceptionsFactory.newWriteOnlyException | public static WriteOnlyException newWriteOnlyException(Throwable cause, String message, Object... args) {
"""
Constructs and initializes a new {@link WriteOnlyException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link WriteOnlyException} was thrown.
@param message {@link String} describing the {@link WriteOnlyException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link WriteOnlyException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.util.WriteOnlyException
"""
return new WriteOnlyException(format(message, args), cause);
} | java | public static WriteOnlyException newWriteOnlyException(Throwable cause, String message, Object... args) {
return new WriteOnlyException(format(message, args), cause);
} | [
"public",
"static",
"WriteOnlyException",
"newWriteOnlyException",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"WriteOnlyException",
"(",
"format",
"(",
"message",
",",
"args",
")",
",",
"cause",
")",
";",
"}"
] | Constructs and initializes a new {@link WriteOnlyException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link WriteOnlyException} was thrown.
@param message {@link String} describing the {@link WriteOnlyException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link WriteOnlyException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.util.WriteOnlyException | [
"Constructs",
"and",
"initializes",
"a",
"new",
"{",
"@link",
"WriteOnlyException",
"}",
"with",
"the",
"given",
"{",
"@link",
"Throwable",
"cause",
"}",
"and",
"{",
"@link",
"String",
"message",
"}",
"formatted",
"with",
"the",
"given",
"{",
"@link",
"Object",
"[]",
"arguments",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java#L971-L973 |
line/armeria | core/src/main/java/com/linecorp/armeria/client/SessionProtocolNegotiationCache.java | SessionProtocolNegotiationCache.isUnsupported | public static boolean isUnsupported(SocketAddress remoteAddress, SessionProtocol protocol) {
"""
Returns {@code true} if the specified {@code remoteAddress} is known to have no support for
the specified {@link SessionProtocol}.
"""
final String key = key(remoteAddress);
final CacheEntry e;
final long stamp = lock.readLock();
try {
e = cache.get(key);
} finally {
lock.unlockRead(stamp);
}
if (e == null) {
// Can't tell if it's unsupported
return false;
}
return e.isUnsupported(protocol);
} | java | public static boolean isUnsupported(SocketAddress remoteAddress, SessionProtocol protocol) {
final String key = key(remoteAddress);
final CacheEntry e;
final long stamp = lock.readLock();
try {
e = cache.get(key);
} finally {
lock.unlockRead(stamp);
}
if (e == null) {
// Can't tell if it's unsupported
return false;
}
return e.isUnsupported(protocol);
} | [
"public",
"static",
"boolean",
"isUnsupported",
"(",
"SocketAddress",
"remoteAddress",
",",
"SessionProtocol",
"protocol",
")",
"{",
"final",
"String",
"key",
"=",
"key",
"(",
"remoteAddress",
")",
";",
"final",
"CacheEntry",
"e",
";",
"final",
"long",
"stamp",
"=",
"lock",
".",
"readLock",
"(",
")",
";",
"try",
"{",
"e",
"=",
"cache",
".",
"get",
"(",
"key",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlockRead",
"(",
"stamp",
")",
";",
"}",
"if",
"(",
"e",
"==",
"null",
")",
"{",
"// Can't tell if it's unsupported",
"return",
"false",
";",
"}",
"return",
"e",
".",
"isUnsupported",
"(",
"protocol",
")",
";",
"}"
] | Returns {@code true} if the specified {@code remoteAddress} is known to have no support for
the specified {@link SessionProtocol}. | [
"Returns",
"{"
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/client/SessionProtocolNegotiationCache.java#L63-L79 |
tvesalainen/util | util/src/main/java/org/vesalainen/ui/Transforms.java | Transforms.createScreenTransform | public static AffineTransform createScreenTransform(Rectangle2D userBounds, Rectangle2D screenBounds, boolean keepAspectRatio) {
"""
Creates translation that translates userBounds in Cartesian coordinates
to screenBound in screen coordinates.
<p>In Cartesian y grows up while in screen y grows down
@param userBounds
@param screenBounds
@param keepAspectRatio
@return
"""
return createScreenTransform(userBounds, screenBounds, keepAspectRatio, new AffineTransform());
} | java | public static AffineTransform createScreenTransform(Rectangle2D userBounds, Rectangle2D screenBounds, boolean keepAspectRatio)
{
return createScreenTransform(userBounds, screenBounds, keepAspectRatio, new AffineTransform());
} | [
"public",
"static",
"AffineTransform",
"createScreenTransform",
"(",
"Rectangle2D",
"userBounds",
",",
"Rectangle2D",
"screenBounds",
",",
"boolean",
"keepAspectRatio",
")",
"{",
"return",
"createScreenTransform",
"(",
"userBounds",
",",
"screenBounds",
",",
"keepAspectRatio",
",",
"new",
"AffineTransform",
"(",
")",
")",
";",
"}"
] | Creates translation that translates userBounds in Cartesian coordinates
to screenBound in screen coordinates.
<p>In Cartesian y grows up while in screen y grows down
@param userBounds
@param screenBounds
@param keepAspectRatio
@return | [
"Creates",
"translation",
"that",
"translates",
"userBounds",
"in",
"Cartesian",
"coordinates",
"to",
"screenBound",
"in",
"screen",
"coordinates",
".",
"<p",
">",
"In",
"Cartesian",
"y",
"grows",
"up",
"while",
"in",
"screen",
"y",
"grows",
"down"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/ui/Transforms.java#L43-L46 |
looly/hutool | hutool-aop/src/main/java/cn/hutool/aop/ProxyUtil.java | ProxyUtil.newProxyInstance | @SuppressWarnings("unchecked")
public static <T> T newProxyInstance(ClassLoader classloader, InvocationHandler invocationHandler, Class<?>... interfaces) {
"""
创建动态代理对象<br>
动态代理对象的创建原理是:<br>
假设创建的代理对象名为 $Proxy0<br>
1、根据传入的interfaces动态生成一个类,实现interfaces中的接口<br>
2、通过传入的classloder将刚生成的类加载到jvm中。即将$Proxy0类load<br>
3、调用$Proxy0的$Proxy0(InvocationHandler)构造函数 创建$Proxy0的对象,并且用interfaces参数遍历其所有接口的方法,这些实现方法的实现本质上是通过反射调用被代理对象的方法<br>
4、将$Proxy0的实例返回给客户端。 <br>
5、当调用代理类的相应方法时,相当于调用 {@link InvocationHandler#invoke(Object, java.lang.reflect.Method, Object[])} 方法
@param <T> 被代理对象类型
@param classloader 被代理类对应的ClassLoader
@param invocationHandler {@link InvocationHandler} ,被代理类通过实现此接口提供动态代理功能
@param interfaces 代理类中需要实现的被代理类的接口方法
@return 代理类
"""
return (T) Proxy.newProxyInstance(classloader, interfaces, invocationHandler);
} | java | @SuppressWarnings("unchecked")
public static <T> T newProxyInstance(ClassLoader classloader, InvocationHandler invocationHandler, Class<?>... interfaces) {
return (T) Proxy.newProxyInstance(classloader, interfaces, invocationHandler);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"newProxyInstance",
"(",
"ClassLoader",
"classloader",
",",
"InvocationHandler",
"invocationHandler",
",",
"Class",
"<",
"?",
">",
"...",
"interfaces",
")",
"{",
"return",
"(",
"T",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"classloader",
",",
"interfaces",
",",
"invocationHandler",
")",
";",
"}"
] | 创建动态代理对象<br>
动态代理对象的创建原理是:<br>
假设创建的代理对象名为 $Proxy0<br>
1、根据传入的interfaces动态生成一个类,实现interfaces中的接口<br>
2、通过传入的classloder将刚生成的类加载到jvm中。即将$Proxy0类load<br>
3、调用$Proxy0的$Proxy0(InvocationHandler)构造函数 创建$Proxy0的对象,并且用interfaces参数遍历其所有接口的方法,这些实现方法的实现本质上是通过反射调用被代理对象的方法<br>
4、将$Proxy0的实例返回给客户端。 <br>
5、当调用代理类的相应方法时,相当于调用 {@link InvocationHandler#invoke(Object, java.lang.reflect.Method, Object[])} 方法
@param <T> 被代理对象类型
@param classloader 被代理类对应的ClassLoader
@param invocationHandler {@link InvocationHandler} ,被代理类通过实现此接口提供动态代理功能
@param interfaces 代理类中需要实现的被代理类的接口方法
@return 代理类 | [
"创建动态代理对象<br",
">",
"动态代理对象的创建原理是:<br",
">",
"假设创建的代理对象名为",
"$Proxy0<br",
">",
"1、根据传入的interfaces动态生成一个类,实现interfaces中的接口<br",
">",
"2、通过传入的classloder将刚生成的类加载到jvm中。即将$Proxy0类load<br",
">",
"3、调用$Proxy0的$Proxy0",
"(",
"InvocationHandler",
")",
"构造函数",
"创建$Proxy0的对象,并且用interfaces参数遍历其所有接口的方法,这些实现方法的实现本质上是通过反射调用被代理对象的方法<br",
">",
"4、将$Proxy0的实例返回给客户端。",
"<br",
">",
"5、当调用代理类的相应方法时,相当于调用",
"{",
"@link",
"InvocationHandler#invoke",
"(",
"Object",
"java",
".",
"lang",
".",
"reflect",
".",
"Method",
"Object",
"[]",
")",
"}",
"方法"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-aop/src/main/java/cn/hutool/aop/ProxyUtil.java#L57-L60 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java | ApiOvhEmailexchange.organizationName_service_exchangeService_mailingList_mailingListAddress_member_account_GET | public ArrayList<Long> organizationName_service_exchangeService_mailingList_mailingListAddress_member_account_GET(String organizationName, String exchangeService, String mailingListAddress) throws IOException {
"""
Mailing list account member
REST: GET /email/exchange/{organizationName}/service/{exchangeService}/mailingList/{mailingListAddress}/member/account
@param organizationName [required] The internal name of your exchange organization
@param exchangeService [required] The internal name of your exchange service
@param mailingListAddress [required] The mailing list address
"""
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}/mailingList/{mailingListAddress}/member/account";
StringBuilder sb = path(qPath, organizationName, exchangeService, mailingListAddress);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
} | java | public ArrayList<Long> organizationName_service_exchangeService_mailingList_mailingListAddress_member_account_GET(String organizationName, String exchangeService, String mailingListAddress) throws IOException {
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}/mailingList/{mailingListAddress}/member/account";
StringBuilder sb = path(qPath, organizationName, exchangeService, mailingListAddress);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
} | [
"public",
"ArrayList",
"<",
"Long",
">",
"organizationName_service_exchangeService_mailingList_mailingListAddress_member_account_GET",
"(",
"String",
"organizationName",
",",
"String",
"exchangeService",
",",
"String",
"mailingListAddress",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/exchange/{organizationName}/service/{exchangeService}/mailingList/{mailingListAddress}/member/account\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"organizationName",
",",
"exchangeService",
",",
"mailingListAddress",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t2",
")",
";",
"}"
] | Mailing list account member
REST: GET /email/exchange/{organizationName}/service/{exchangeService}/mailingList/{mailingListAddress}/member/account
@param organizationName [required] The internal name of your exchange organization
@param exchangeService [required] The internal name of your exchange service
@param mailingListAddress [required] The mailing list address | [
"Mailing",
"list",
"account",
"member"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java#L1060-L1065 |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.getMatchingMessages | public Collection<Message> getMatchingMessages(final short id, boolean remove) {
"""
Removes and returns all messages which have a header with ID == id
"""
return map((msg, batch) -> {
if(msg != null && msg.getHeader(id) != null) {
if(remove)
batch.remove(msg);
return msg;
}
return null;
});
} | java | public Collection<Message> getMatchingMessages(final short id, boolean remove) {
return map((msg, batch) -> {
if(msg != null && msg.getHeader(id) != null) {
if(remove)
batch.remove(msg);
return msg;
}
return null;
});
} | [
"public",
"Collection",
"<",
"Message",
">",
"getMatchingMessages",
"(",
"final",
"short",
"id",
",",
"boolean",
"remove",
")",
"{",
"return",
"map",
"(",
"(",
"msg",
",",
"batch",
")",
"->",
"{",
"if",
"(",
"msg",
"!=",
"null",
"&&",
"msg",
".",
"getHeader",
"(",
"id",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"remove",
")",
"batch",
".",
"remove",
"(",
"msg",
")",
";",
"return",
"msg",
";",
"}",
"return",
"null",
";",
"}",
")",
";",
"}"
] | Removes and returns all messages which have a header with ID == id | [
"Removes",
"and",
"returns",
"all",
"messages",
"which",
"have",
"a",
"header",
"with",
"ID",
"==",
"id"
] | train | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L285-L294 |
redkale/redkale | src/org/redkale/net/http/HttpRequest.java | HttpRequest.getRequstURIPath | public float getRequstURIPath(String prefix, float defvalue) {
"""
获取请求URL分段中含prefix段的float值 <br>
例如请求URL /pipes/record/query/point:40.0 <br>
获取time参数: float point = request.getRequstURIPath("point:", 0.0f);
@param prefix prefix段前缀
@param defvalue 默认float值
@return float值
"""
String val = getRequstURIPath(prefix, null);
try {
return val == null ? defvalue : Float.parseFloat(val);
} catch (NumberFormatException e) {
return defvalue;
}
} | java | public float getRequstURIPath(String prefix, float defvalue) {
String val = getRequstURIPath(prefix, null);
try {
return val == null ? defvalue : Float.parseFloat(val);
} catch (NumberFormatException e) {
return defvalue;
}
} | [
"public",
"float",
"getRequstURIPath",
"(",
"String",
"prefix",
",",
"float",
"defvalue",
")",
"{",
"String",
"val",
"=",
"getRequstURIPath",
"(",
"prefix",
",",
"null",
")",
";",
"try",
"{",
"return",
"val",
"==",
"null",
"?",
"defvalue",
":",
"Float",
".",
"parseFloat",
"(",
"val",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"return",
"defvalue",
";",
"}",
"}"
] | 获取请求URL分段中含prefix段的float值 <br>
例如请求URL /pipes/record/query/point:40.0 <br>
获取time参数: float point = request.getRequstURIPath("point:", 0.0f);
@param prefix prefix段前缀
@param defvalue 默认float值
@return float值 | [
"获取请求URL分段中含prefix段的float值",
"<br",
">",
"例如请求URL",
"/",
"pipes",
"/",
"record",
"/",
"query",
"/",
"point",
":",
"40",
".",
"0",
"<br",
">",
"获取time参数",
":",
"float",
"point",
"=",
"request",
".",
"getRequstURIPath",
"(",
"point",
":",
"0",
".",
"0f",
")",
";"
] | train | https://github.com/redkale/redkale/blob/ea5169b5c5ea7412fd762331c0c497165832e901/src/org/redkale/net/http/HttpRequest.java#L897-L904 |
Azure/azure-sdk-for-java | logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/WorkflowRunActionRepetitionsInner.java | WorkflowRunActionRepetitionsInner.listAsync | public Observable<List<WorkflowRunActionRepetitionDefinitionInner>> listAsync(String resourceGroupName, String workflowName, String runName, String actionName) {
"""
Get all of a workflow run action repetitions.
@param resourceGroupName The resource group name.
@param workflowName The workflow name.
@param runName The workflow run name.
@param actionName The workflow action name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<WorkflowRunActionRepetitionDefinitionInner> object
"""
return listWithServiceResponseAsync(resourceGroupName, workflowName, runName, actionName).map(new Func1<ServiceResponse<List<WorkflowRunActionRepetitionDefinitionInner>>, List<WorkflowRunActionRepetitionDefinitionInner>>() {
@Override
public List<WorkflowRunActionRepetitionDefinitionInner> call(ServiceResponse<List<WorkflowRunActionRepetitionDefinitionInner>> response) {
return response.body();
}
});
} | java | public Observable<List<WorkflowRunActionRepetitionDefinitionInner>> listAsync(String resourceGroupName, String workflowName, String runName, String actionName) {
return listWithServiceResponseAsync(resourceGroupName, workflowName, runName, actionName).map(new Func1<ServiceResponse<List<WorkflowRunActionRepetitionDefinitionInner>>, List<WorkflowRunActionRepetitionDefinitionInner>>() {
@Override
public List<WorkflowRunActionRepetitionDefinitionInner> call(ServiceResponse<List<WorkflowRunActionRepetitionDefinitionInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"WorkflowRunActionRepetitionDefinitionInner",
">",
">",
"listAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"workflowName",
",",
"String",
"runName",
",",
"String",
"actionName",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"workflowName",
",",
"runName",
",",
"actionName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"WorkflowRunActionRepetitionDefinitionInner",
">",
">",
",",
"List",
"<",
"WorkflowRunActionRepetitionDefinitionInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"WorkflowRunActionRepetitionDefinitionInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"WorkflowRunActionRepetitionDefinitionInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get all of a workflow run action repetitions.
@param resourceGroupName The resource group name.
@param workflowName The workflow name.
@param runName The workflow run name.
@param actionName The workflow action name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<WorkflowRunActionRepetitionDefinitionInner> object | [
"Get",
"all",
"of",
"a",
"workflow",
"run",
"action",
"repetitions",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/WorkflowRunActionRepetitionsInner.java#L111-L118 |
igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java | MultiUserChat.changeSubject | public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
"""
Changes the subject within the room. As a default, only users with a role of "moderator"
are allowed to change the subject in a room. Although some rooms may be configured to
allow a mere participant or even a visitor to change the subject.
@param subject the new room's subject to set.
@throws XMPPErrorException if someone without appropriate privileges attempts to change the
room subject will throw an error with code 403 (i.e. Forbidden)
@throws NoResponseException if there was no response from the server.
@throws NotConnectedException
@throws InterruptedException
"""
Message message = createMessage();
message.setSubject(subject);
// Wait for an error or confirmation message back from the server.
StanzaFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() {
@Override
public boolean accept(Stanza packet) {
Message msg = (Message) packet;
return subject.equals(msg.getSubject());
}
});
StanzaCollector response = connection.createStanzaCollectorAndSend(responseFilter, message);
// Wait up to a certain number of seconds for a reply.
response.nextResultOrThrow();
} | java | public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Message message = createMessage();
message.setSubject(subject);
// Wait for an error or confirmation message back from the server.
StanzaFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() {
@Override
public boolean accept(Stanza packet) {
Message msg = (Message) packet;
return subject.equals(msg.getSubject());
}
});
StanzaCollector response = connection.createStanzaCollectorAndSend(responseFilter, message);
// Wait up to a certain number of seconds for a reply.
response.nextResultOrThrow();
} | [
"public",
"void",
"changeSubject",
"(",
"final",
"String",
"subject",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"Message",
"message",
"=",
"createMessage",
"(",
")",
";",
"message",
".",
"setSubject",
"(",
"subject",
")",
";",
"// Wait for an error or confirmation message back from the server.",
"StanzaFilter",
"responseFilter",
"=",
"new",
"AndFilter",
"(",
"fromRoomGroupchatFilter",
",",
"new",
"StanzaFilter",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"Stanza",
"packet",
")",
"{",
"Message",
"msg",
"=",
"(",
"Message",
")",
"packet",
";",
"return",
"subject",
".",
"equals",
"(",
"msg",
".",
"getSubject",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"StanzaCollector",
"response",
"=",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"responseFilter",
",",
"message",
")",
";",
"// Wait up to a certain number of seconds for a reply.",
"response",
".",
"nextResultOrThrow",
"(",
")",
";",
"}"
] | Changes the subject within the room. As a default, only users with a role of "moderator"
are allowed to change the subject in a room. Although some rooms may be configured to
allow a mere participant or even a visitor to change the subject.
@param subject the new room's subject to set.
@throws XMPPErrorException if someone without appropriate privileges attempts to change the
room subject will throw an error with code 403 (i.e. Forbidden)
@throws NoResponseException if there was no response from the server.
@throws NotConnectedException
@throws InterruptedException | [
"Changes",
"the",
"subject",
"within",
"the",
"room",
".",
"As",
"a",
"default",
"only",
"users",
"with",
"a",
"role",
"of",
"moderator",
"are",
"allowed",
"to",
"change",
"the",
"subject",
"in",
"a",
"room",
".",
"Although",
"some",
"rooms",
"may",
"be",
"configured",
"to",
"allow",
"a",
"mere",
"participant",
"or",
"even",
"a",
"visitor",
"to",
"change",
"the",
"subject",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L2026-L2040 |
apache/incubator-atlas | common/src/main/java/org/apache/atlas/utils/ParamChecker.java | ParamChecker.notEmpty | public static String notEmpty(String value, String name) {
"""
Check that a string is not null and not empty. If null or emtpy throws an IllegalArgumentException.
@param value value.
@param name parameter name for the exception message.
@return the given value.
"""
return notEmpty(value, name, null);
} | java | public static String notEmpty(String value, String name) {
return notEmpty(value, name, null);
} | [
"public",
"static",
"String",
"notEmpty",
"(",
"String",
"value",
",",
"String",
"name",
")",
"{",
"return",
"notEmpty",
"(",
"value",
",",
"name",
",",
"null",
")",
";",
"}"
] | Check that a string is not null and not empty. If null or emtpy throws an IllegalArgumentException.
@param value value.
@param name parameter name for the exception message.
@return the given value. | [
"Check",
"that",
"a",
"string",
"is",
"not",
"null",
"and",
"not",
"empty",
".",
"If",
"null",
"or",
"emtpy",
"throws",
"an",
"IllegalArgumentException",
"."
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/common/src/main/java/org/apache/atlas/utils/ParamChecker.java#L93-L95 |
threerings/playn | html/src/playn/html/HtmlGL20.java | HtmlGL20.getTypedArray | protected ArrayBufferView getTypedArray(Buffer buffer, int type, int byteSize) {
"""
Returns the typed array of the given native buffer.
Set byteSize to -1 to use remaining()
"""
if (!(buffer instanceof HasArrayBufferView)) {
throw new RuntimeException("Native buffer required " + buffer);
}
HasArrayBufferView arrayHolder = (HasArrayBufferView) buffer;
int bufferElementSize = arrayHolder.getElementSize();
ArrayBufferView webGLArray = arrayHolder.getTypedArray();
if (byteSize == -1) {
byteSize = buffer.remaining() * bufferElementSize;
}
if (byteSize == buffer.capacity() * bufferElementSize && type == arrayHolder.getElementType()) {
return webGLArray;
}
int byteOffset = webGLArray.byteOffset() + buffer.position() * bufferElementSize;
switch (type) {
case FLOAT:
return TypedArrays.createFloat32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
case UNSIGNED_BYTE:
return TypedArrays.createUint8Array(webGLArray.buffer(), byteOffset, byteSize);
case UNSIGNED_SHORT:
return TypedArrays.createUint16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
case INT:
return TypedArrays.createInt32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
case SHORT:
return TypedArrays.createInt16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
case BYTE:
return TypedArrays.createInt8Array(webGLArray.buffer(), byteOffset, byteSize);
default:
throw new IllegalArgumentException("Type: " + type);
}
} | java | protected ArrayBufferView getTypedArray(Buffer buffer, int type, int byteSize) {
if (!(buffer instanceof HasArrayBufferView)) {
throw new RuntimeException("Native buffer required " + buffer);
}
HasArrayBufferView arrayHolder = (HasArrayBufferView) buffer;
int bufferElementSize = arrayHolder.getElementSize();
ArrayBufferView webGLArray = arrayHolder.getTypedArray();
if (byteSize == -1) {
byteSize = buffer.remaining() * bufferElementSize;
}
if (byteSize == buffer.capacity() * bufferElementSize && type == arrayHolder.getElementType()) {
return webGLArray;
}
int byteOffset = webGLArray.byteOffset() + buffer.position() * bufferElementSize;
switch (type) {
case FLOAT:
return TypedArrays.createFloat32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
case UNSIGNED_BYTE:
return TypedArrays.createUint8Array(webGLArray.buffer(), byteOffset, byteSize);
case UNSIGNED_SHORT:
return TypedArrays.createUint16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
case INT:
return TypedArrays.createInt32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
case SHORT:
return TypedArrays.createInt16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
case BYTE:
return TypedArrays.createInt8Array(webGLArray.buffer(), byteOffset, byteSize);
default:
throw new IllegalArgumentException("Type: " + type);
}
} | [
"protected",
"ArrayBufferView",
"getTypedArray",
"(",
"Buffer",
"buffer",
",",
"int",
"type",
",",
"int",
"byteSize",
")",
"{",
"if",
"(",
"!",
"(",
"buffer",
"instanceof",
"HasArrayBufferView",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Native buffer required \"",
"+",
"buffer",
")",
";",
"}",
"HasArrayBufferView",
"arrayHolder",
"=",
"(",
"HasArrayBufferView",
")",
"buffer",
";",
"int",
"bufferElementSize",
"=",
"arrayHolder",
".",
"getElementSize",
"(",
")",
";",
"ArrayBufferView",
"webGLArray",
"=",
"arrayHolder",
".",
"getTypedArray",
"(",
")",
";",
"if",
"(",
"byteSize",
"==",
"-",
"1",
")",
"{",
"byteSize",
"=",
"buffer",
".",
"remaining",
"(",
")",
"*",
"bufferElementSize",
";",
"}",
"if",
"(",
"byteSize",
"==",
"buffer",
".",
"capacity",
"(",
")",
"*",
"bufferElementSize",
"&&",
"type",
"==",
"arrayHolder",
".",
"getElementType",
"(",
")",
")",
"{",
"return",
"webGLArray",
";",
"}",
"int",
"byteOffset",
"=",
"webGLArray",
".",
"byteOffset",
"(",
")",
"+",
"buffer",
".",
"position",
"(",
")",
"*",
"bufferElementSize",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"FLOAT",
":",
"return",
"TypedArrays",
".",
"createFloat32Array",
"(",
"webGLArray",
".",
"buffer",
"(",
")",
",",
"byteOffset",
",",
"byteSize",
"/",
"4",
")",
";",
"case",
"UNSIGNED_BYTE",
":",
"return",
"TypedArrays",
".",
"createUint8Array",
"(",
"webGLArray",
".",
"buffer",
"(",
")",
",",
"byteOffset",
",",
"byteSize",
")",
";",
"case",
"UNSIGNED_SHORT",
":",
"return",
"TypedArrays",
".",
"createUint16Array",
"(",
"webGLArray",
".",
"buffer",
"(",
")",
",",
"byteOffset",
",",
"byteSize",
"/",
"2",
")",
";",
"case",
"INT",
":",
"return",
"TypedArrays",
".",
"createInt32Array",
"(",
"webGLArray",
".",
"buffer",
"(",
")",
",",
"byteOffset",
",",
"byteSize",
"/",
"4",
")",
";",
"case",
"SHORT",
":",
"return",
"TypedArrays",
".",
"createInt16Array",
"(",
"webGLArray",
".",
"buffer",
"(",
")",
",",
"byteOffset",
",",
"byteSize",
"/",
"2",
")",
";",
"case",
"BYTE",
":",
"return",
"TypedArrays",
".",
"createInt8Array",
"(",
"webGLArray",
".",
"buffer",
"(",
")",
",",
"byteOffset",
",",
"byteSize",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Type: \"",
"+",
"type",
")",
";",
"}",
"}"
] | Returns the typed array of the given native buffer.
Set byteSize to -1 to use remaining() | [
"Returns",
"the",
"typed",
"array",
"of",
"the",
"given",
"native",
"buffer",
".",
"Set",
"byteSize",
"to",
"-",
"1",
"to",
"use",
"remaining",
"()"
] | train | https://github.com/threerings/playn/blob/c266eeb39188dcada4b00992a0d1199759e03d42/html/src/playn/html/HtmlGL20.java#L286-L319 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.