repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
di2e/Argo | clui/src/main/java/net/dharwin/common/tools/cli/api/CLIContext.java | CLIContext.getString | public String getString(String key, String defaultValue) {
Object o = getObject(key);
if (o == null) {
return defaultValue;
}
if (!(o instanceof String)) {
throw new IllegalArgumentException("Object ["+o+"] associated with key ["+key+"] is not of type String.");
}
return (String)o;
} | java | public String getString(String key, String defaultValue) {
Object o = getObject(key);
if (o == null) {
return defaultValue;
}
if (!(o instanceof String)) {
throw new IllegalArgumentException("Object ["+o+"] associated with key ["+key+"] is not of type String.");
}
return (String)o;
} | [
"public",
"String",
"getString",
"(",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"Object",
"o",
"=",
"getObject",
"(",
"key",
")",
";",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"if",
"(",
"!",
"(",
... | Get the string value, or the defaultValue if not found.
@param key The key to search for.
@return The value, or defaultValue if not found. | [
"Get",
"the",
"string",
"value",
"or",
"the",
"defaultValue",
"if",
"not",
"found",
"."
] | f537a03d2d25fdfecda7999ec10e1da67dc3b8f3 | https://github.com/di2e/Argo/blob/f537a03d2d25fdfecda7999ec10e1da67dc3b8f3/clui/src/main/java/net/dharwin/common/tools/cli/api/CLIContext.java#L156-L165 | train |
di2e/Argo | clui/src/main/java/net/dharwin/common/tools/cli/api/CLIContext.java | CLIContext.getBoolean | public boolean getBoolean(String key, boolean defaultValue) {
Object o = getObject(key);
if (o == null) {
return defaultValue;
}
boolean b = defaultValue;
try {
b = Boolean.parseBoolean(o.toString());
}
catch (Exception e) {
throw new IllegalArgumentException("Object ["+o+"] associated with key ["+key+"] is not of type Boolean.");
}
return b;
} | java | public boolean getBoolean(String key, boolean defaultValue) {
Object o = getObject(key);
if (o == null) {
return defaultValue;
}
boolean b = defaultValue;
try {
b = Boolean.parseBoolean(o.toString());
}
catch (Exception e) {
throw new IllegalArgumentException("Object ["+o+"] associated with key ["+key+"] is not of type Boolean.");
}
return b;
} | [
"public",
"boolean",
"getBoolean",
"(",
"String",
"key",
",",
"boolean",
"defaultValue",
")",
"{",
"Object",
"o",
"=",
"getObject",
"(",
"key",
")",
";",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"boolean",
"b",
"=",
... | Get the boolean value, or the defaultValue if not found.
@param key The key to search for.
@param defaultValue the default value
@return The value, or defaultValue if not found. | [
"Get",
"the",
"boolean",
"value",
"or",
"the",
"defaultValue",
"if",
"not",
"found",
"."
] | f537a03d2d25fdfecda7999ec10e1da67dc3b8f3 | https://github.com/di2e/Argo/blob/f537a03d2d25fdfecda7999ec10e1da67dc3b8f3/clui/src/main/java/net/dharwin/common/tools/cli/api/CLIContext.java#L182-L195 | train |
di2e/Argo | clui/src/main/java/net/dharwin/common/tools/cli/api/CLIContext.java | CLIContext.getInteger | public int getInteger(String key, int defaultValue) {
Object o = getObject(key);
if (o == null) {
return defaultValue;
}
int val = defaultValue;
try {
val = Integer.parseInt(o.toString());
}
catch (Exception e) {
throw new IllegalArgumentException("Object ["+o+"] associated with key ["+key+"] is not of type Integer.");
}
return val;
} | java | public int getInteger(String key, int defaultValue) {
Object o = getObject(key);
if (o == null) {
return defaultValue;
}
int val = defaultValue;
try {
val = Integer.parseInt(o.toString());
}
catch (Exception e) {
throw new IllegalArgumentException("Object ["+o+"] associated with key ["+key+"] is not of type Integer.");
}
return val;
} | [
"public",
"int",
"getInteger",
"(",
"String",
"key",
",",
"int",
"defaultValue",
")",
"{",
"Object",
"o",
"=",
"getObject",
"(",
"key",
")",
";",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"int",
"val",
"=",
"defaultV... | Get the integer value, or the defaultValue if not found.
@param key The key to search for.
@param defaultValue the default value
@return The value, or defaultValue if not found. | [
"Get",
"the",
"integer",
"value",
"or",
"the",
"defaultValue",
"if",
"not",
"found",
"."
] | f537a03d2d25fdfecda7999ec10e1da67dc3b8f3 | https://github.com/di2e/Argo/blob/f537a03d2d25fdfecda7999ec10e1da67dc3b8f3/clui/src/main/java/net/dharwin/common/tools/cli/api/CLIContext.java#L212-L225 | train |
mcdiae/kludje | kludje-experimental/src/main/java/uk/kludje/experimental/proxy/InvocationHandlers.java | InvocationHandlers.defaultMethodHandler | public static InvocationHandler defaultMethodHandler() {
return (proxy, method, args) -> {
if (method.isDefault()) {
return MethodHandles.lookup()
.in(method.getDeclaringClass())
.unreflectSpecial(method, method.getDeclaringClass())
.bindTo(proxy)
.invokeWithArguments(args);
} else {
throw new IllegalArgumentException(method.toString());
}
};
} | java | public static InvocationHandler defaultMethodHandler() {
return (proxy, method, args) -> {
if (method.isDefault()) {
return MethodHandles.lookup()
.in(method.getDeclaringClass())
.unreflectSpecial(method, method.getDeclaringClass())
.bindTo(proxy)
.invokeWithArguments(args);
} else {
throw new IllegalArgumentException(method.toString());
}
};
} | [
"public",
"static",
"InvocationHandler",
"defaultMethodHandler",
"(",
")",
"{",
"return",
"(",
"proxy",
",",
"method",
",",
"args",
")",
"->",
"{",
"if",
"(",
"method",
".",
"isDefault",
"(",
")",
")",
"{",
"return",
"MethodHandles",
".",
"lookup",
"(",
... | Handler for invoking interface default methods.
This handler will throw an exception if the method is not a default method.
@return handler for invoking interface default methods
@see java.lang.reflect.Method#isDefault() | [
"Handler",
"for",
"invoking",
"interface",
"default",
"methods",
".",
"This",
"handler",
"will",
"throw",
"an",
"exception",
"if",
"the",
"method",
"is",
"not",
"a",
"default",
"method",
"."
] | 9ed80cd183ebf162708d5922d784f79ac3841dfc | https://github.com/mcdiae/kludje/blob/9ed80cd183ebf162708d5922d784f79ac3841dfc/kludje-experimental/src/main/java/uk/kludje/experimental/proxy/InvocationHandlers.java#L51-L63 | train |
mcdiae/kludje | kludje-core/src/main/java/uk/kludje/ArrayMapper.java | ArrayMapper.concat | @SuppressWarnings("unchecked")
public <E extends T> T[] concat(T[] oldArray, E newElement) {
T[] arr = (T[]) Array.newInstance(type, oldArray.length + 1);
System.arraycopy(oldArray, 0, arr, 0, oldArray.length);
arr[oldArray.length] = newElement;
return arr;
} | java | @SuppressWarnings("unchecked")
public <E extends T> T[] concat(T[] oldArray, E newElement) {
T[] arr = (T[]) Array.newInstance(type, oldArray.length + 1);
System.arraycopy(oldArray, 0, arr, 0, oldArray.length);
arr[oldArray.length] = newElement;
return arr;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"E",
"extends",
"T",
">",
"T",
"[",
"]",
"concat",
"(",
"T",
"[",
"]",
"oldArray",
",",
"E",
"newElement",
")",
"{",
"T",
"[",
"]",
"arr",
"=",
"(",
"T",
"[",
"]",
")",
"Array",
... | Returns a new instance with the given element at the end.
@param oldArray the old array
@param newElement the element to contatenate
@param <E> the element type
@return a new array | [
"Returns",
"a",
"new",
"instance",
"with",
"the",
"given",
"element",
"at",
"the",
"end",
"."
] | 9ed80cd183ebf162708d5922d784f79ac3841dfc | https://github.com/mcdiae/kludje/blob/9ed80cd183ebf162708d5922d784f79ac3841dfc/kludje-core/src/main/java/uk/kludje/ArrayMapper.java#L59-L65 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/MapperWrapper.java | MapperWrapper.convert | @Override
@SuppressWarnings("unchecked")
protected T convert(JsonNode data) {
// The (T) cast prevents the commandline javac from choking "no unique maximal instance"
return (T)this.mapper.convertValue(data, this.resultType);
} | java | @Override
@SuppressWarnings("unchecked")
protected T convert(JsonNode data) {
// The (T) cast prevents the commandline javac from choking "no unique maximal instance"
return (T)this.mapper.convertValue(data, this.resultType);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"T",
"convert",
"(",
"JsonNode",
"data",
")",
"{",
"// The (T) cast prevents the commandline javac from choking \"no unique maximal instance\"",
"return",
"(",
"T",
")",
"this",
".",
"mapper... | Use Jackson to map from JsonNode to the type | [
"Use",
"Jackson",
"to",
"map",
"from",
"JsonNode",
"to",
"the",
"type"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/MapperWrapper.java#L48-L53 | train |
jspringbot/jspringbot | src/main/java/org/jspringbot/spring/SpringRobotLibrary.java | SpringRobotLibrary.runKeyword | @SuppressWarnings("unchecked")
public Object runKeyword(String keyword, final Object[] params) {
Map attributes = new HashMap();
attributes.put("args", params);
try {
ApplicationContextHolder.set(context);
startJSpringBotKeyword(keyword, attributes);
Object[] handledParams = argumentHandlers.handlerArguments(keyword, params);
Object returnedValue = ((Keyword) context.getBean(keywordToBeanMap.get(keyword))).execute(handledParams);
attributes.put("status", "PASS");
return returnedValue;
} catch(Exception e) {
attributes.put("exception", e);
attributes.put("status", "FAIL");
if(SoftAssertManager.INSTANCE.isEnable()) {
LOGGER.warn("[SOFT ASSERT]: (" + keyword + ") -> " + e.getMessage());
SoftAssertManager.INSTANCE.add(keyword, e);
return null;
} else {
throw new IllegalStateException(e.getMessage(), e);
}
} finally {
endJSpringBotKeyword(keyword, attributes);
ApplicationContextHolder.remove();
}
} | java | @SuppressWarnings("unchecked")
public Object runKeyword(String keyword, final Object[] params) {
Map attributes = new HashMap();
attributes.put("args", params);
try {
ApplicationContextHolder.set(context);
startJSpringBotKeyword(keyword, attributes);
Object[] handledParams = argumentHandlers.handlerArguments(keyword, params);
Object returnedValue = ((Keyword) context.getBean(keywordToBeanMap.get(keyword))).execute(handledParams);
attributes.put("status", "PASS");
return returnedValue;
} catch(Exception e) {
attributes.put("exception", e);
attributes.put("status", "FAIL");
if(SoftAssertManager.INSTANCE.isEnable()) {
LOGGER.warn("[SOFT ASSERT]: (" + keyword + ") -> " + e.getMessage());
SoftAssertManager.INSTANCE.add(keyword, e);
return null;
} else {
throw new IllegalStateException(e.getMessage(), e);
}
} finally {
endJSpringBotKeyword(keyword, attributes);
ApplicationContextHolder.remove();
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Object",
"runKeyword",
"(",
"String",
"keyword",
",",
"final",
"Object",
"[",
"]",
"params",
")",
"{",
"Map",
"attributes",
"=",
"new",
"HashMap",
"(",
")",
";",
"attributes",
".",
"put",
"(",
... | Implements the Robot Framework interface method 'run_keyword' required for dynamic libraries.
@param keyword name of keyword to be executed
@param params parameters passed by Robot Framework
@return result of the keyword execution | [
"Implements",
"the",
"Robot",
"Framework",
"interface",
"method",
"run_keyword",
"required",
"for",
"dynamic",
"libraries",
"."
] | 03285a7013492fb793cb0c38a4625a5f5c5750e0 | https://github.com/jspringbot/jspringbot/blob/03285a7013492fb793cb0c38a4625a5f5c5750e0/src/main/java/org/jspringbot/spring/SpringRobotLibrary.java#L108-L139 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/FacebookBatcher.java | FacebookBatcher.getAppAccessToken | public static String getAppAccessToken(String clientId, String clientSecret) {
return getAccessToken(clientId, clientSecret, null, null);
} | java | public static String getAppAccessToken(String clientId, String clientSecret) {
return getAccessToken(clientId, clientSecret, null, null);
} | [
"public",
"static",
"String",
"getAppAccessToken",
"(",
"String",
"clientId",
",",
"String",
"clientSecret",
")",
"{",
"return",
"getAccessToken",
"(",
"clientId",
",",
"clientSecret",
",",
"null",
",",
"null",
")",
";",
"}"
] | Get the app access token from Facebook.
see https://developers.facebook.com/docs/authentication/ | [
"Get",
"the",
"app",
"access",
"token",
"from",
"Facebook",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/FacebookBatcher.java#L69-L71 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/FacebookBatcher.java | FacebookBatcher.execute | @Override
public void execute() {
if (this.batches.isEmpty())
return;
// Reset the collection before making the call to eliminate callback chatter when
// the batches call back to the master.
List<Batch> old = this.batches;
// Reset our batches
this.batches = new ArrayList<Batch>();
this.queryBatch = null;
for (Batch batch: old) {
batch.execute();
}
} | java | @Override
public void execute() {
if (this.batches.isEmpty())
return;
// Reset the collection before making the call to eliminate callback chatter when
// the batches call back to the master.
List<Batch> old = this.batches;
// Reset our batches
this.batches = new ArrayList<Batch>();
this.queryBatch = null;
for (Batch batch: old) {
batch.execute();
}
} | [
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"{",
"if",
"(",
"this",
".",
"batches",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"// Reset the collection before making the call to eliminate callback chatter when\r",
"// the batches call back to the master.\r",
... | Executes all existing batches and removes them from consideration for further batching. | [
"Executes",
"all",
"existing",
"batches",
"and",
"removes",
"them",
"from",
"consideration",
"for",
"further",
"batching",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/FacebookBatcher.java#L368-L384 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/FacebookBatcher.java | FacebookBatcher.getBatchForGraph | private Batch getBatchForGraph() {
Batch lastValidBatch = this.batches.isEmpty() ? null : this.batches.get(this.batches.size()-1);
if (lastValidBatch != null && lastValidBatch.graphSize() < this.maxBatchSize)
return lastValidBatch;
else {
Batch next = new Batch(this, this.mapper, this.accessToken, this.apiVersion, this.timeout, this.retries);
this.batches.add(next);
return next;
}
} | java | private Batch getBatchForGraph() {
Batch lastValidBatch = this.batches.isEmpty() ? null : this.batches.get(this.batches.size()-1);
if (lastValidBatch != null && lastValidBatch.graphSize() < this.maxBatchSize)
return lastValidBatch;
else {
Batch next = new Batch(this, this.mapper, this.accessToken, this.apiVersion, this.timeout, this.retries);
this.batches.add(next);
return next;
}
} | [
"private",
"Batch",
"getBatchForGraph",
"(",
")",
"{",
"Batch",
"lastValidBatch",
"=",
"this",
".",
"batches",
".",
"isEmpty",
"(",
")",
"?",
"null",
":",
"this",
".",
"batches",
".",
"get",
"(",
"this",
".",
"batches",
".",
"size",
"(",
")",
"-",
"1... | Get an appropriate Batch for issuing a new graph call. Will construct a new one
if all existing batches are full. | [
"Get",
"an",
"appropriate",
"Batch",
"for",
"issuing",
"a",
"new",
"graph",
"call",
".",
"Will",
"construct",
"a",
"new",
"one",
"if",
"all",
"existing",
"batches",
"are",
"full",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/FacebookBatcher.java#L390-L400 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.from | public static SmartBinder from(Signature inbound) {
return new SmartBinder(inbound, Binder.from(inbound.type()));
} | java | public static SmartBinder from(Signature inbound) {
return new SmartBinder(inbound, Binder.from(inbound.type()));
} | [
"public",
"static",
"SmartBinder",
"from",
"(",
"Signature",
"inbound",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"inbound",
",",
"Binder",
".",
"from",
"(",
"inbound",
".",
"type",
"(",
")",
")",
")",
";",
"}"
] | Create a new SmartBinder from the given Signature.
@param inbound the Signature to start from
@return a new SmartBinder | [
"Create",
"a",
"new",
"SmartBinder",
"from",
"the",
"given",
"Signature",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L88-L90 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.from | public static SmartBinder from(Class<?> retType, String[] names, Class<?>... types) {
return from(Signature.returning(retType).appendArgs(names, types));
} | java | public static SmartBinder from(Class<?> retType, String[] names, Class<?>... types) {
return from(Signature.returning(retType).appendArgs(names, types));
} | [
"public",
"static",
"SmartBinder",
"from",
"(",
"Class",
"<",
"?",
">",
"retType",
",",
"String",
"[",
"]",
"names",
",",
"Class",
"<",
"?",
">",
"...",
"types",
")",
"{",
"return",
"from",
"(",
"Signature",
".",
"returning",
"(",
"retType",
")",
"."... | Create a new SmartBinder from the given types and argument names.
@param retType the type of the return value to start with
@param names the names of arguments
@param types the argument types
@return a new SmartBinder | [
"Create",
"a",
"new",
"SmartBinder",
"from",
"the",
"given",
"types",
"and",
"argument",
"names",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L100-L102 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.from | public static SmartBinder from(Class<?> retType, String name, Class<?> type) {
return from(Signature.returning(retType).appendArg(name, type));
} | java | public static SmartBinder from(Class<?> retType, String name, Class<?> type) {
return from(Signature.returning(retType).appendArg(name, type));
} | [
"public",
"static",
"SmartBinder",
"from",
"(",
"Class",
"<",
"?",
">",
"retType",
",",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"from",
"(",
"Signature",
".",
"returning",
"(",
"retType",
")",
".",
"appendArg",
"(",
... | Create a new SmartBinder with from the given types and argument name.
@param retType the type of the return value to start with
@param name the name of the sole argument
@param type the sole argument's type
@return a new SmartBinder | [
"Create",
"a",
"new",
"SmartBinder",
"with",
"from",
"the",
"given",
"types",
"and",
"argument",
"name",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L112-L114 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.from | public static SmartBinder from(Lookup lookup, Signature inbound) {
return new SmartBinder(inbound, Binder.from(lookup, inbound.type()));
} | java | public static SmartBinder from(Lookup lookup, Signature inbound) {
return new SmartBinder(inbound, Binder.from(lookup, inbound.type()));
} | [
"public",
"static",
"SmartBinder",
"from",
"(",
"Lookup",
"lookup",
",",
"Signature",
"inbound",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"inbound",
",",
"Binder",
".",
"from",
"(",
"lookup",
",",
"inbound",
".",
"type",
"(",
")",
")",
")",
";",
... | Create a new SmartBinder from the given Signature, using the given
Lookup for any handle lookups.
@param lookup the Lookup to use for handle lookups
@param inbound the Signature to start from
@return a new SmartBinder | [
"Create",
"a",
"new",
"SmartBinder",
"from",
"the",
"given",
"Signature",
"using",
"the",
"given",
"Lookup",
"for",
"any",
"handle",
"lookups",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L124-L126 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.foldVoid | public SmartBinder foldVoid(SmartHandle function) {
if (Arrays.equals(signature().argNames(), function.signature().argNames())) {
return foldVoid(function.handle());
} else {
return foldVoid(signature().asFold(void.class).permuteWith(function).handle());
}
} | java | public SmartBinder foldVoid(SmartHandle function) {
if (Arrays.equals(signature().argNames(), function.signature().argNames())) {
return foldVoid(function.handle());
} else {
return foldVoid(signature().asFold(void.class).permuteWith(function).handle());
}
} | [
"public",
"SmartBinder",
"foldVoid",
"(",
"SmartHandle",
"function",
")",
"{",
"if",
"(",
"Arrays",
".",
"equals",
"(",
"signature",
"(",
")",
".",
"argNames",
"(",
")",
",",
"function",
".",
"signature",
"(",
")",
".",
"argNames",
"(",
")",
")",
")",
... | Pass all arguments to the given function and drop any result.
@param function a function which will receive all arguments and have its
return value inserted into the call chain
@return a new SmartBinder with the fold applied | [
"Pass",
"all",
"arguments",
"to",
"the",
"given",
"function",
"and",
"drop",
"any",
"result",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L210-L216 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.foldStatic | public SmartBinder foldStatic(String newName, Lookup lookup, Class<?> target, String method) {
Binder newBinder = binder.foldStatic(lookup, target, method);
return new SmartBinder(this, signature().prependArg(newName, newBinder.type().parameterType(0)), binder);
} | java | public SmartBinder foldStatic(String newName, Lookup lookup, Class<?> target, String method) {
Binder newBinder = binder.foldStatic(lookup, target, method);
return new SmartBinder(this, signature().prependArg(newName, newBinder.type().parameterType(0)), binder);
} | [
"public",
"SmartBinder",
"foldStatic",
"(",
"String",
"newName",
",",
"Lookup",
"lookup",
",",
"Class",
"<",
"?",
">",
"target",
",",
"String",
"method",
")",
"{",
"Binder",
"newBinder",
"=",
"binder",
".",
"foldStatic",
"(",
"lookup",
",",
"target",
",",
... | Acquire a static folding function from the given target class, using the
given name and Lookup. Pass all arguments to that function and insert
the resulting value as newName into the argument list.
@param newName the name of the new first argument where the fold
function's result will be passed
@param lookup the Lookup to use for acquiring a folding function
@param target the class on which to find the folding function
@param method the name of the method to become a folding function
@return a new SmartBinder with the fold applied | [
"Acquire",
"a",
"static",
"folding",
"function",
"from",
"the",
"given",
"target",
"class",
"using",
"the",
"given",
"name",
"and",
"Lookup",
".",
"Pass",
"all",
"arguments",
"to",
"that",
"function",
"and",
"insert",
"the",
"resulting",
"value",
"as",
"newN... | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L230-L233 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.foldVirtual | public SmartBinder foldVirtual(String newName, Lookup lookup, String method) {
Binder newBinder = binder.foldVirtual(lookup, method);
return new SmartBinder(this, signature().prependArg(newName, newBinder.type().parameterType(0)), newBinder);
} | java | public SmartBinder foldVirtual(String newName, Lookup lookup, String method) {
Binder newBinder = binder.foldVirtual(lookup, method);
return new SmartBinder(this, signature().prependArg(newName, newBinder.type().parameterType(0)), newBinder);
} | [
"public",
"SmartBinder",
"foldVirtual",
"(",
"String",
"newName",
",",
"Lookup",
"lookup",
",",
"String",
"method",
")",
"{",
"Binder",
"newBinder",
"=",
"binder",
".",
"foldVirtual",
"(",
"lookup",
",",
"method",
")",
";",
"return",
"new",
"SmartBinder",
"(... | Acquire a virtual folding function from the first argument's class,
using the given name and Lookup. Pass all arguments to that function and
insert the resulting value as newName into the argument list.
@param newName the name of the new first argument where the fold
function's result will be passed
@param lookup the Lookup to use for acquiring a folding function
@param method the name of the method to become a folding function
@return a new SmartBinder with the fold applied | [
"Acquire",
"a",
"virtual",
"folding",
"function",
"from",
"the",
"first",
"argument",
"s",
"class",
"using",
"the",
"given",
"name",
"and",
"Lookup",
".",
"Pass",
"all",
"arguments",
"to",
"that",
"function",
"and",
"insert",
"the",
"resulting",
"value",
"as... | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L262-L265 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.permute | public SmartBinder permute(Signature target) {
return new SmartBinder(this, target, binder.permute(signature().to(target)));
} | java | public SmartBinder permute(Signature target) {
return new SmartBinder(this, target, binder.permute(signature().to(target)));
} | [
"public",
"SmartBinder",
"permute",
"(",
"Signature",
"target",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"target",
",",
"binder",
".",
"permute",
"(",
"signature",
"(",
")",
".",
"to",
"(",
"target",
")",
")",
")",
";",
"}"
] | Using the argument names and order in the target Signature, permute the
arguments in this SmartBinder. Arguments may be duplicated or omitted
in the target Signature, but all arguments in the target must be defined
in this SmartBinder .
@param target the Signature from which to derive a new argument list
@return a new SmartBinder with the permute applied | [
"Using",
"the",
"argument",
"names",
"and",
"order",
"in",
"the",
"target",
"Signature",
"permute",
"the",
"arguments",
"in",
"this",
"SmartBinder",
".",
"Arguments",
"may",
"be",
"duplicated",
"or",
"omitted",
"in",
"the",
"target",
"Signature",
"but",
"all",... | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L296-L298 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.spread | public SmartBinder spread(String[] spreadNames, Class<?>... spreadTypes) {
return new SmartBinder(this, signature().spread(spreadNames, spreadTypes), binder.spread(spreadTypes));
} | java | public SmartBinder spread(String[] spreadNames, Class<?>... spreadTypes) {
return new SmartBinder(this, signature().spread(spreadNames, spreadTypes), binder.spread(spreadTypes));
} | [
"public",
"SmartBinder",
"spread",
"(",
"String",
"[",
"]",
"spreadNames",
",",
"Class",
"<",
"?",
">",
"...",
"spreadTypes",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"signature",
"(",
")",
".",
"spread",
"(",
"spreadNames",
",",
"spre... | Spread a trailing array into the specified argument types.
@param spreadNames the names for the spread out arguments
@param spreadTypes the types as which to spread the incoming array
@return a new SmartBinder with the spread applied | [
"Spread",
"a",
"trailing",
"array",
"into",
"the",
"specified",
"argument",
"types",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L336-L338 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.spread | public SmartBinder spread(String baseName, int count) {
return new SmartBinder(this, signature().spread(baseName, count), binder.spread(count));
} | java | public SmartBinder spread(String baseName, int count) {
return new SmartBinder(this, signature().spread(baseName, count), binder.spread(count));
} | [
"public",
"SmartBinder",
"spread",
"(",
"String",
"baseName",
",",
"int",
"count",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"signature",
"(",
")",
".",
"spread",
"(",
"baseName",
",",
"count",
")",
",",
"binder",
".",
"spread",
"(",
... | Spread a trailing array into count number of arguments, using the
natural component type for the array. Build names for the arguments
using the given baseName plus the argument's index.
Example:
Current binder has a signature of (int, String[])void. We want
to spread the strings into five arguments named "str".
<code>binder = binder.spread("str", 5)</code>
The resulting signature will have five trailing arguments named
"arg0" through "arg4".
@param baseName the base name from which to create the new argument names
@param count the count of arguments to spread
@return a new SmartBinder with the spread applied | [
"Spread",
"a",
"trailing",
"array",
"into",
"count",
"number",
"of",
"arguments",
"using",
"the",
"natural",
"component",
"type",
"for",
"the",
"array",
".",
"Build",
"names",
"for",
"the",
"arguments",
"using",
"the",
"given",
"baseName",
"plus",
"the",
"ar... | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L358-L360 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.insert | public SmartBinder insert(int index, String[] names, Class<?>[] types, Object... values) {
return new SmartBinder(this, signature().insertArgs(index, names, types), binder.insert(index, types, values));
} | java | public SmartBinder insert(int index, String[] names, Class<?>[] types, Object... values) {
return new SmartBinder(this, signature().insertArgs(index, names, types), binder.insert(index, types, values));
} | [
"public",
"SmartBinder",
"insert",
"(",
"int",
"index",
",",
"String",
"[",
"]",
"names",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"types",
",",
"Object",
"...",
"values",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"signature",
"(",
")... | Insert arguments into the argument list at the given index with the
given names and values.
@param index the index at which to insert the arguments
@param names the names of the new arguments
@param types the types of the new arguments
@param values the values of the new arguments
@return a new SmartBinder with the insert applied | [
"Insert",
"arguments",
"into",
"the",
"argument",
"list",
"at",
"the",
"given",
"index",
"with",
"the",
"given",
"names",
"and",
"values",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L507-L509 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.append | public SmartBinder append(String[] names, Class<?>[] types, Object... values) {
return new SmartBinder(this, signature().appendArgs(names, types), binder.append(types, values));
} | java | public SmartBinder append(String[] names, Class<?>[] types, Object... values) {
return new SmartBinder(this, signature().appendArgs(names, types), binder.append(types, values));
} | [
"public",
"SmartBinder",
"append",
"(",
"String",
"[",
"]",
"names",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"types",
",",
"Object",
"...",
"values",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"signature",
"(",
")",
".",
"appendArgs",
... | Append the given arguments to the argument list, assigning them the
given names.
@param names the names of the new arguments
@param types the types to use in the new signature
@param values the values of the new arguments
@return a new SmartBinder with the append applied | [
"Append",
"the",
"given",
"arguments",
"to",
"the",
"argument",
"list",
"assigning",
"them",
"the",
"given",
"names",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L641-L643 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.prepend | public SmartBinder prepend(String[] names, Class<?>[] types, Object... values) {
return new SmartBinder(this, signature().prependArgs(names, types), binder.prepend(types, values));
} | java | public SmartBinder prepend(String[] names, Class<?>[] types, Object... values) {
return new SmartBinder(this, signature().prependArgs(names, types), binder.prepend(types, values));
} | [
"public",
"SmartBinder",
"prepend",
"(",
"String",
"[",
"]",
"names",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"types",
",",
"Object",
"...",
"values",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"signature",
"(",
")",
".",
"prependArgs",... | Prepend the given arguments to the argument list, assigning them the
given name.
@param names the names of the new arguments
@param types the types to use in the new signature
@param values the values of the new arguments
@return a new SmartBinder with the prepend applied | [
"Prepend",
"the",
"given",
"arguments",
"to",
"the",
"argument",
"list",
"assigning",
"them",
"the",
"given",
"name",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L775-L777 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.drop | public SmartBinder drop(String name) {
int index = signature().argOffset(name);
return new SmartBinder(this, signature().dropArg(index), binder.drop(index));
} | java | public SmartBinder drop(String name) {
int index = signature().argOffset(name);
return new SmartBinder(this, signature().dropArg(index), binder.drop(index));
} | [
"public",
"SmartBinder",
"drop",
"(",
"String",
"name",
")",
"{",
"int",
"index",
"=",
"signature",
"(",
")",
".",
"argOffset",
"(",
"name",
")",
";",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"signature",
"(",
")",
".",
"dropArg",
"(",
"index"... | Drop the argument with the given name.
@param name the name of the argument to drop
@return a new SmartBinder with the drop applied | [
"Drop",
"the",
"argument",
"with",
"the",
"given",
"name",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L789-L792 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.dropLast | public SmartBinder dropLast(int count) {
return new SmartBinder(this, signature().dropLast(count), binder.dropLast(count));
} | java | public SmartBinder dropLast(int count) {
return new SmartBinder(this, signature().dropLast(count), binder.dropLast(count));
} | [
"public",
"SmartBinder",
"dropLast",
"(",
"int",
"count",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"signature",
"(",
")",
".",
"dropLast",
"(",
"count",
")",
",",
"binder",
".",
"dropLast",
"(",
"count",
")",
")",
";",
"}"
] | Drop the last N arguments.
@param count the count of arguments to drop
@return a new SmartBinder with the drop applied | [
"Drop",
"the",
"last",
"N",
"arguments",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L809-L811 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.dropFirst | public SmartBinder dropFirst(int count) {
return new SmartBinder(this, signature().dropFirst(count), binder.dropFirst(count));
} | java | public SmartBinder dropFirst(int count) {
return new SmartBinder(this, signature().dropFirst(count), binder.dropFirst(count));
} | [
"public",
"SmartBinder",
"dropFirst",
"(",
"int",
"count",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"signature",
"(",
")",
".",
"dropFirst",
"(",
"count",
")",
",",
"binder",
".",
"dropFirst",
"(",
"count",
")",
")",
";",
"}"
] | Drop the first N arguments.
@param count the count of arguments to drop
@return a new SmartBinder with the drop applied | [
"Drop",
"the",
"first",
"N",
"arguments",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L828-L830 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.collect | public SmartBinder collect(String outName, String namePattern) {
int index = signature().argOffsets(namePattern);
assert index >= 0 : "no arguments matching " + namePattern + " found in signature " + signature();
Signature newSignature = signature().collect(outName, namePattern);
return new SmartBinder(this, newSignature, binder.collect(index, signature().argCount() - (newSignature.argCount() - 1), Array.newInstance(signature().argType(index), 0).getClass()));
} | java | public SmartBinder collect(String outName, String namePattern) {
int index = signature().argOffsets(namePattern);
assert index >= 0 : "no arguments matching " + namePattern + " found in signature " + signature();
Signature newSignature = signature().collect(outName, namePattern);
return new SmartBinder(this, newSignature, binder.collect(index, signature().argCount() - (newSignature.argCount() - 1), Array.newInstance(signature().argType(index), 0).getClass()));
} | [
"public",
"SmartBinder",
"collect",
"(",
"String",
"outName",
",",
"String",
"namePattern",
")",
"{",
"int",
"index",
"=",
"signature",
"(",
")",
".",
"argOffsets",
"(",
"namePattern",
")",
";",
"assert",
"index",
">=",
"0",
":",
"\"no arguments matching \"",
... | Collect arguments matching namePattern into an trailing array argument
named outName.
The namePattern is a standard regular expression.
@param outName the name of the new array argument
@param namePattern a pattern with which to match arguments for collecting
@return a new SmartBinder with the collect applied | [
"Collect",
"arguments",
"matching",
"namePattern",
"into",
"an",
"trailing",
"array",
"argument",
"named",
"outName",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L846-L854 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.cast | public SmartBinder cast(Signature target) {
return new SmartBinder(target, binder.cast(target.type()));
} | java | public SmartBinder cast(Signature target) {
return new SmartBinder(target, binder.cast(target.type()));
} | [
"public",
"SmartBinder",
"cast",
"(",
"Signature",
"target",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"target",
",",
"binder",
".",
"cast",
"(",
"target",
".",
"type",
"(",
")",
")",
")",
";",
"}"
] | Cast the incoming arguments to the types in the given signature. The
argument count must match, but the names in the target signature are
ignored.
@param target the Signature to which arguments should be cast
@return a new SmartBinder with the cast applied | [
"Cast",
"the",
"incoming",
"arguments",
"to",
"the",
"types",
"in",
"the",
"given",
"signature",
".",
"The",
"argument",
"count",
"must",
"match",
"but",
"the",
"names",
"in",
"the",
"target",
"signature",
"are",
"ignored",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L868-L870 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.cast | public SmartBinder cast(Class<?> returnType, Class<?>... argTypes) {
return new SmartBinder(this, new Signature(returnType, argTypes, signature().argNames()), binder.cast(returnType, argTypes));
} | java | public SmartBinder cast(Class<?> returnType, Class<?>... argTypes) {
return new SmartBinder(this, new Signature(returnType, argTypes, signature().argNames()), binder.cast(returnType, argTypes));
} | [
"public",
"SmartBinder",
"cast",
"(",
"Class",
"<",
"?",
">",
"returnType",
",",
"Class",
"<",
"?",
">",
"...",
"argTypes",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"new",
"Signature",
"(",
"returnType",
",",
"argTypes",
",",
"signatur... | Cast the incoming arguments to the return and argument types given. The
argument count must match.
@param returnType the return type for the casted signature
@param argTypes the types of the arguments for the casted signature
@return a new SmartBinder with the cast applied | [
"Cast",
"the",
"incoming",
"arguments",
"to",
"the",
"return",
"and",
"argument",
"types",
"given",
".",
"The",
"argument",
"count",
"must",
"match",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L880-L882 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.castVirtual | public SmartBinder castVirtual(Class<?> returnType, Class<?> firstArg, Class<?>... restArgs) {
return new SmartBinder(this, new Signature(returnType, firstArg, restArgs, signature().argNames()), binder.castVirtual(returnType, firstArg, restArgs));
} | java | public SmartBinder castVirtual(Class<?> returnType, Class<?> firstArg, Class<?>... restArgs) {
return new SmartBinder(this, new Signature(returnType, firstArg, restArgs, signature().argNames()), binder.castVirtual(returnType, firstArg, restArgs));
} | [
"public",
"SmartBinder",
"castVirtual",
"(",
"Class",
"<",
"?",
">",
"returnType",
",",
"Class",
"<",
"?",
">",
"firstArg",
",",
"Class",
"<",
"?",
">",
"...",
"restArgs",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"new",
"Signature",
... | Cast the incoming arguments to the return, first argument type, and
remaining argument types. Provide for convenience when dealing with
virtual method argument lists, which frequently omit the target
object.
@param returnType the return type for the casted signature
@param firstArg the type of the first argument for the casted signature
@param restArgs the types of the remaining arguments for the casted signature
@return a new SmartBinder with the cast applied. | [
"Cast",
"the",
"incoming",
"arguments",
"to",
"the",
"return",
"first",
"argument",
"type",
"and",
"remaining",
"argument",
"types",
".",
"Provide",
"for",
"convenience",
"when",
"dealing",
"with",
"virtual",
"method",
"argument",
"lists",
"which",
"frequently",
... | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L895-L897 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.castArg | public SmartBinder castArg(String name, Class<?> type) {
Signature newSig = signature().replaceArg(name, name, type);
return new SmartBinder(this, newSig, binder.cast(newSig.type()));
} | java | public SmartBinder castArg(String name, Class<?> type) {
Signature newSig = signature().replaceArg(name, name, type);
return new SmartBinder(this, newSig, binder.cast(newSig.type()));
} | [
"public",
"SmartBinder",
"castArg",
"(",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"Signature",
"newSig",
"=",
"signature",
"(",
")",
".",
"replaceArg",
"(",
"name",
",",
"name",
",",
"type",
")",
";",
"return",
"new",
"SmartBind... | Cast the named argument to the given type.
@param name the name of the argument to cast
@param type the type to which that argument will be cast
@return a new SmartBinder with the cast applied | [
"Cast",
"the",
"named",
"argument",
"to",
"the",
"given",
"type",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L906-L909 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.castReturn | public SmartBinder castReturn(Class<?> type) {
return new SmartBinder(this, signature().changeReturn(type), binder.cast(type, binder.type().parameterArray()));
} | java | public SmartBinder castReturn(Class<?> type) {
return new SmartBinder(this, signature().changeReturn(type), binder.cast(type, binder.type().parameterArray()));
} | [
"public",
"SmartBinder",
"castReturn",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"new",
"SmartBinder",
"(",
"this",
",",
"signature",
"(",
")",
".",
"changeReturn",
"(",
"type",
")",
",",
"binder",
".",
"cast",
"(",
"type",
",",
"binder"... | Cast the return value to the given type.
Example: Our current signature is (String)String but the method this
handle will eventually call returns CharSequence.
<code>binder = binder.castReturn(CharSequence.class);</code>
Our handle will now successfully find and call the target method and
propagate the returned CharSequence as a String.
@param type the new type for the return value
@return a new SmartBinder | [
"Cast",
"the",
"return",
"value",
"to",
"the",
"given",
"type",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L925-L927 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.invokeVirtual | public SmartHandle invokeVirtual(Lookup lookup, String name) throws NoSuchMethodException, IllegalAccessException {
return new SmartHandle(start, binder.invokeVirtual(lookup, name));
} | java | public SmartHandle invokeVirtual(Lookup lookup, String name) throws NoSuchMethodException, IllegalAccessException {
return new SmartHandle(start, binder.invokeVirtual(lookup, name));
} | [
"public",
"SmartHandle",
"invokeVirtual",
"(",
"Lookup",
"lookup",
",",
"String",
"name",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
"{",
"return",
"new",
"SmartHandle",
"(",
"start",
",",
"binder",
".",
"invokeVirtual",
"(",
"lookup",
... | Terminate this binder by looking up the named virtual method on the
first argument's type. Perform the actual method lookup using the given
Lookup object.
@param lookup the Lookup to use for handle lookups
@param name the name of the target virtual method
@return a SmartHandle with this binder's starting signature, bound
to the target method
@throws NoSuchMethodException if the named method with current signature's types does not exist
@throws IllegalAccessException if the named method is not accessible to the given Lookup | [
"Terminate",
"this",
"binder",
"by",
"looking",
"up",
"the",
"named",
"virtual",
"method",
"on",
"the",
"first",
"argument",
"s",
"type",
".",
"Perform",
"the",
"actual",
"method",
"lookup",
"using",
"the",
"given",
"Lookup",
"object",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L981-L983 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.invokeStatic | public SmartHandle invokeStatic(Lookup lookup, Class<?> target, String name) throws NoSuchMethodException, IllegalAccessException {
return new SmartHandle(start, binder.invokeStatic(lookup, target, name));
} | java | public SmartHandle invokeStatic(Lookup lookup, Class<?> target, String name) throws NoSuchMethodException, IllegalAccessException {
return new SmartHandle(start, binder.invokeStatic(lookup, target, name));
} | [
"public",
"SmartHandle",
"invokeStatic",
"(",
"Lookup",
"lookup",
",",
"Class",
"<",
"?",
">",
"target",
",",
"String",
"name",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
"{",
"return",
"new",
"SmartHandle",
"(",
"start",
",",
"binder... | Terminate this binder by looking up the named static method on the
given target type. Perform the actual method lookup using the given
Lookup object.
@param lookup the Lookup to use for handle lookups
@param target the type on which to find the static method
@param name the name of the target static method
@return a SmartHandle with this binder's starting signature, bound
to the target method
@throws NoSuchMethodException if the named method with current signature's types does not exist
@throws IllegalAccessException if the named method is not accessible to the given Lookup | [
"Terminate",
"this",
"binder",
"by",
"looking",
"up",
"the",
"named",
"static",
"method",
"on",
"the",
"given",
"target",
"type",
".",
"Perform",
"the",
"actual",
"method",
"lookup",
"using",
"the",
"given",
"Lookup",
"object",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L1018-L1020 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.invoke | public SmartHandle invoke(SmartHandle target) {
return new SmartHandle(start, binder.invoke(target.handle()));
} | java | public SmartHandle invoke(SmartHandle target) {
return new SmartHandle(start, binder.invoke(target.handle()));
} | [
"public",
"SmartHandle",
"invoke",
"(",
"SmartHandle",
"target",
")",
"{",
"return",
"new",
"SmartHandle",
"(",
"start",
",",
"binder",
".",
"invoke",
"(",
"target",
".",
"handle",
"(",
")",
")",
")",
";",
"}"
] | Terminate this binder by invoking the given target handle. The signature
of this binder is not compared to the signature of the given
SmartHandle.
@param target the handle to invoke
@return a new SmartHandle with this binder's starting signature, bound
through to the given handle | [
"Terminate",
"this",
"binder",
"by",
"invoking",
"the",
"given",
"target",
"handle",
".",
"The",
"signature",
"of",
"this",
"binder",
"is",
"not",
"compared",
"to",
"the",
"signature",
"of",
"the",
"given",
"SmartHandle",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L1052-L1054 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.filter | public SmartBinder filter(String pattern, MethodHandle filter) {
String[] argNames = signature().argNames();
Pattern pat = Pattern.compile(pattern);
Binder newBinder = binder();
Signature newSig = signature();
for (int i = 0; i < argNames.length; i++) {
if (pat.matcher(argNames[i]).matches()) {
newBinder = newBinder.filter(i, filter);
newSig = newSig.argType(i, filter.type().returnType());
}
}
return new SmartBinder(newSig, newBinder);
} | java | public SmartBinder filter(String pattern, MethodHandle filter) {
String[] argNames = signature().argNames();
Pattern pat = Pattern.compile(pattern);
Binder newBinder = binder();
Signature newSig = signature();
for (int i = 0; i < argNames.length; i++) {
if (pat.matcher(argNames[i]).matches()) {
newBinder = newBinder.filter(i, filter);
newSig = newSig.argType(i, filter.type().returnType());
}
}
return new SmartBinder(newSig, newBinder);
} | [
"public",
"SmartBinder",
"filter",
"(",
"String",
"pattern",
",",
"MethodHandle",
"filter",
")",
"{",
"String",
"[",
"]",
"argNames",
"=",
"signature",
"(",
")",
".",
"argNames",
"(",
")",
";",
"Pattern",
"pat",
"=",
"Pattern",
".",
"compile",
"(",
"patt... | Filter the arguments matching the given pattern using the given filter function.
@param pattern the regular expression pattern to match arguments
@param filter the MethodHandle to use to filter the arguments
@return a new SmartBinder with the filter applied | [
"Filter",
"the",
"arguments",
"matching",
"the",
"given",
"pattern",
"using",
"the",
"given",
"filter",
"function",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L1153-L1167 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.from | public static Signature from(Class<?> retval, Class<?>[] argTypes, String... argNames) {
assert argTypes.length == argNames.length;
return new Signature(retval, argTypes, argNames);
} | java | public static Signature from(Class<?> retval, Class<?>[] argTypes, String... argNames) {
assert argTypes.length == argNames.length;
return new Signature(retval, argTypes, argNames);
} | [
"public",
"static",
"Signature",
"from",
"(",
"Class",
"<",
"?",
">",
"retval",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"argTypes",
",",
"String",
"...",
"argNames",
")",
"{",
"assert",
"argTypes",
".",
"length",
"==",
"argNames",
".",
"length",
";",
... | Create a new signature based on the given return value, argument types, and argument names
@param retval the type of the return value
@param argTypes the types of the arguments
@param argNames the names of the arguments
@return a new Signature | [
"Create",
"a",
"new",
"signature",
"based",
"on",
"the",
"given",
"return",
"value",
"argument",
"types",
"and",
"argument",
"names"
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L154-L158 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.dropArg | public Signature dropArg(String name) {
String[] newArgNames = new String[argNames.length - 1];
MethodType newType = methodType;
for (int i = 0, j = 0; i < argNames.length; i++) {
if (argNames[i].equals(name)) {
newType = newType.dropParameterTypes(j, j + 1);
continue;
}
newArgNames[j++] = argNames[i];
}
if (newType == null) {
// arg name not found; should we error?
return this;
}
return new Signature(newType, newArgNames);
} | java | public Signature dropArg(String name) {
String[] newArgNames = new String[argNames.length - 1];
MethodType newType = methodType;
for (int i = 0, j = 0; i < argNames.length; i++) {
if (argNames[i].equals(name)) {
newType = newType.dropParameterTypes(j, j + 1);
continue;
}
newArgNames[j++] = argNames[i];
}
if (newType == null) {
// arg name not found; should we error?
return this;
}
return new Signature(newType, newArgNames);
} | [
"public",
"Signature",
"dropArg",
"(",
"String",
"name",
")",
"{",
"String",
"[",
"]",
"newArgNames",
"=",
"new",
"String",
"[",
"argNames",
".",
"length",
"-",
"1",
"]",
";",
"MethodType",
"newType",
"=",
"methodType",
";",
"for",
"(",
"int",
"i",
"="... | Drops the first argument with the given name.
@param name the name of the argument to drop
@return a new signature | [
"Drops",
"the",
"first",
"argument",
"with",
"the",
"given",
"name",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L308-L326 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.dropArg | public Signature dropArg(int index) {
assert index < argNames.length;
String[] newArgNames = new String[argNames.length - 1];
if (index > 0) System.arraycopy(argNames, 0, newArgNames, 0, index);
if (index < argNames.length - 1)
System.arraycopy(argNames, index + 1, newArgNames, index, argNames.length - (index + 1));
MethodType newType = methodType.dropParameterTypes(index, index + 1);
return new Signature(newType, newArgNames);
} | java | public Signature dropArg(int index) {
assert index < argNames.length;
String[] newArgNames = new String[argNames.length - 1];
if (index > 0) System.arraycopy(argNames, 0, newArgNames, 0, index);
if (index < argNames.length - 1)
System.arraycopy(argNames, index + 1, newArgNames, index, argNames.length - (index + 1));
MethodType newType = methodType.dropParameterTypes(index, index + 1);
return new Signature(newType, newArgNames);
} | [
"public",
"Signature",
"dropArg",
"(",
"int",
"index",
")",
"{",
"assert",
"index",
"<",
"argNames",
".",
"length",
";",
"String",
"[",
"]",
"newArgNames",
"=",
"new",
"String",
"[",
"argNames",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"index",
... | Drops the argument at the given index.
@param index the index of the argument to drop
@return a new signature | [
"Drops",
"the",
"argument",
"at",
"the",
"given",
"index",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L334-L345 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.dropLast | public Signature dropLast(int n) {
return new Signature(
methodType.dropParameterTypes(methodType.parameterCount() - n, methodType.parameterCount()),
Arrays.copyOfRange(argNames, 0, argNames.length - n));
} | java | public Signature dropLast(int n) {
return new Signature(
methodType.dropParameterTypes(methodType.parameterCount() - n, methodType.parameterCount()),
Arrays.copyOfRange(argNames, 0, argNames.length - n));
} | [
"public",
"Signature",
"dropLast",
"(",
"int",
"n",
")",
"{",
"return",
"new",
"Signature",
"(",
"methodType",
".",
"dropParameterTypes",
"(",
"methodType",
".",
"parameterCount",
"(",
")",
"-",
"n",
",",
"methodType",
".",
"parameterCount",
"(",
")",
")",
... | Drop the specified number of last arguments from this signature.
@param n number of arguments to drop
@return a new signature | [
"Drop",
"the",
"specified",
"number",
"of",
"last",
"arguments",
"from",
"this",
"signature",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L362-L366 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.dropFirst | public Signature dropFirst(int n) {
return new Signature(
methodType.dropParameterTypes(0, n),
Arrays.copyOfRange(argNames, n, argNames.length));
} | java | public Signature dropFirst(int n) {
return new Signature(
methodType.dropParameterTypes(0, n),
Arrays.copyOfRange(argNames, n, argNames.length));
} | [
"public",
"Signature",
"dropFirst",
"(",
"int",
"n",
")",
"{",
"return",
"new",
"Signature",
"(",
"methodType",
".",
"dropParameterTypes",
"(",
"0",
",",
"n",
")",
",",
"Arrays",
".",
"copyOfRange",
"(",
"argNames",
",",
"n",
",",
"argNames",
".",
"lengt... | Drop the specified number of first arguments from this signature.
@param n number of arguments to drop
@return a new signature | [
"Drop",
"the",
"specified",
"number",
"of",
"first",
"arguments",
"from",
"this",
"signature",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L383-L387 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.replaceArg | public Signature replaceArg(String oldName, String newName, Class<?> newType) {
int offset = argOffset(oldName);
String[] newArgNames = argNames;
if (!oldName.equals(newName)) {
newArgNames = Arrays.copyOf(argNames, argNames.length);
newArgNames[offset] = newName;
}
Class<?> oldType = methodType.parameterType(offset);
MethodType newMethodType = methodType;
if (!oldType.equals(newType)) newMethodType = methodType.changeParameterType(offset, newType);
return new Signature(newMethodType, newArgNames);
} | java | public Signature replaceArg(String oldName, String newName, Class<?> newType) {
int offset = argOffset(oldName);
String[] newArgNames = argNames;
if (!oldName.equals(newName)) {
newArgNames = Arrays.copyOf(argNames, argNames.length);
newArgNames[offset] = newName;
}
Class<?> oldType = methodType.parameterType(offset);
MethodType newMethodType = methodType;
if (!oldType.equals(newType)) newMethodType = methodType.changeParameterType(offset, newType);
return new Signature(newMethodType, newArgNames);
} | [
"public",
"Signature",
"replaceArg",
"(",
"String",
"oldName",
",",
"String",
"newName",
",",
"Class",
"<",
"?",
">",
"newType",
")",
"{",
"int",
"offset",
"=",
"argOffset",
"(",
"oldName",
")",
";",
"String",
"[",
"]",
"newArgNames",
"=",
"argNames",
";... | Replace the named argument with a new name and type.
@param oldName the old name of the argument
@param newName the new name of the argument; can be the same as old
@param newType the new type of the argument; can be the same as old
@return a new signature with the modified argument | [
"Replace",
"the",
"named",
"argument",
"with",
"a",
"new",
"name",
"and",
"type",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L397-L412 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.collect | public Signature collect(String newName, String oldPattern) {
int start = -1;
int newCount = 0;
int gatherCount = 0;
Class<?> type = null;
Pattern pattern = Pattern.compile(oldPattern);
MethodType newType = type();
for (int i = 0; i < argNames.length; i++) {
if (pattern.matcher(argName(i)).matches()) {
gatherCount++;
newType = newType.dropParameterTypes(newCount, newCount + 1);
Class<?> argType = argType(i);
if (start == -1) start = i;
if (type == null) {
type = argType;
} else {
if (argType != type) {
throw new InvalidTransformException("arguments matching " + pattern + " are not all of the same type");
}
}
} else {
newCount++;
}
}
if (start != -1) {
String[] newNames = new String[newCount + 1];
// pre
System.arraycopy(argNames, 0, newNames, 0, start);
// vararg
newNames[start] = newName;
newType = newType.insertParameterTypes(start, Array.newInstance(type, 0).getClass());
// post
if (newCount + 1 > start) { // args not at end
System.arraycopy(argNames, start + gatherCount, newNames, start + 1, newCount - start);
}
return new Signature(newType, newNames);
}
return this;
} | java | public Signature collect(String newName, String oldPattern) {
int start = -1;
int newCount = 0;
int gatherCount = 0;
Class<?> type = null;
Pattern pattern = Pattern.compile(oldPattern);
MethodType newType = type();
for (int i = 0; i < argNames.length; i++) {
if (pattern.matcher(argName(i)).matches()) {
gatherCount++;
newType = newType.dropParameterTypes(newCount, newCount + 1);
Class<?> argType = argType(i);
if (start == -1) start = i;
if (type == null) {
type = argType;
} else {
if (argType != type) {
throw new InvalidTransformException("arguments matching " + pattern + " are not all of the same type");
}
}
} else {
newCount++;
}
}
if (start != -1) {
String[] newNames = new String[newCount + 1];
// pre
System.arraycopy(argNames, 0, newNames, 0, start);
// vararg
newNames[start] = newName;
newType = newType.insertParameterTypes(start, Array.newInstance(type, 0).getClass());
// post
if (newCount + 1 > start) { // args not at end
System.arraycopy(argNames, start + gatherCount, newNames, start + 1, newCount - start);
}
return new Signature(newType, newNames);
}
return this;
} | [
"public",
"Signature",
"collect",
"(",
"String",
"newName",
",",
"String",
"oldPattern",
")",
"{",
"int",
"start",
"=",
"-",
"1",
";",
"int",
"newCount",
"=",
"0",
";",
"int",
"gatherCount",
"=",
"0",
";",
"Class",
"<",
"?",
">",
"type",
"=",
"null",... | Collect sequential arguments matching pattern into an array. They must have the same type.
@param newName the name of the new array argument
@param oldPattern the pattern of arguments to collect
@return a new signature with an array argument where the collected arguments were | [
"Collect",
"sequential",
"arguments",
"matching",
"pattern",
"into",
"an",
"array",
".",
"They",
"must",
"have",
"the",
"same",
"type",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L474-L520 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.argName | public Signature argName(int index, String name) {
String[] argNames = Arrays.copyOf(argNames(), argNames().length);
argNames[index] = name;
return new Signature(type(), argNames);
} | java | public Signature argName(int index, String name) {
String[] argNames = Arrays.copyOf(argNames(), argNames().length);
argNames[index] = name;
return new Signature(type(), argNames);
} | [
"public",
"Signature",
"argName",
"(",
"int",
"index",
",",
"String",
"name",
")",
"{",
"String",
"[",
"]",
"argNames",
"=",
"Arrays",
".",
"copyOf",
"(",
"argNames",
"(",
")",
",",
"argNames",
"(",
")",
".",
"length",
")",
";",
"argNames",
"[",
"ind... | Set the argument name at the given index.
@param index the index at which to set the argument name
@param name the name to set
@return a new signature with the given name at the given index | [
"Set",
"the",
"argument",
"name",
"at",
"the",
"given",
"index",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L612-L616 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.argType | public Signature argType(int index, Class<?> type) {
return new Signature(type().changeParameterType(index, type), argNames());
} | java | public Signature argType(int index, Class<?> type) {
return new Signature(type().changeParameterType(index, type), argNames());
} | [
"public",
"Signature",
"argType",
"(",
"int",
"index",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"new",
"Signature",
"(",
"type",
"(",
")",
".",
"changeParameterType",
"(",
"index",
",",
"type",
")",
",",
"argNames",
"(",
")",
")",
";"... | Set the argument type at the given index.
@param index the index at which to set the argument type
@param type the type to set
@return a new signature with the given type at the given index | [
"Set",
"the",
"argument",
"type",
"at",
"the",
"given",
"index",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L653-L655 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.permuteWith | public MethodHandle permuteWith(MethodHandle target, String... permuteArgs) {
return MethodHandles.permuteArguments(target, methodType, to(permute(permuteArgs)));
} | java | public MethodHandle permuteWith(MethodHandle target, String... permuteArgs) {
return MethodHandles.permuteArguments(target, methodType, to(permute(permuteArgs)));
} | [
"public",
"MethodHandle",
"permuteWith",
"(",
"MethodHandle",
"target",
",",
"String",
"...",
"permuteArgs",
")",
"{",
"return",
"MethodHandles",
".",
"permuteArguments",
"(",
"target",
",",
"methodType",
",",
"to",
"(",
"permute",
"(",
"permuteArgs",
")",
")",
... | Produce a method handle permuting the arguments in this signature using
the given permute arguments and targeting the given java.lang.invoke.MethodHandle.
Example:
<pre>
Signature sig = Signature.returning(String.class).appendArg("a", int.class).appendArg("b", int.class);
MethodHandle handle = handleThatTakesOneInt();
MethodHandle newHandle = sig.permuteTo(handle, "b");
</pre>
@param target the method handle to target
@param permuteArgs the arguments to permute
@return a new handle that permutes appropriate positions based on the
given permute args | [
"Produce",
"a",
"method",
"handle",
"permuting",
"the",
"arguments",
"in",
"this",
"signature",
"using",
"the",
"given",
"permute",
"arguments",
"and",
"targeting",
"the",
"given",
"java",
".",
"lang",
".",
"invoke",
".",
"MethodHandle",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L730-L732 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.permuteWith | public SmartHandle permuteWith(SmartHandle target) {
String[] argNames = target.signature().argNames();
return new SmartHandle(this, permuteWith(target.handle(), argNames));
} | java | public SmartHandle permuteWith(SmartHandle target) {
String[] argNames = target.signature().argNames();
return new SmartHandle(this, permuteWith(target.handle(), argNames));
} | [
"public",
"SmartHandle",
"permuteWith",
"(",
"SmartHandle",
"target",
")",
"{",
"String",
"[",
"]",
"argNames",
"=",
"target",
".",
"signature",
"(",
")",
".",
"argNames",
"(",
")",
";",
"return",
"new",
"SmartHandle",
"(",
"this",
",",
"permuteWith",
"(",... | Produce a new SmartHandle by permuting this Signature's arguments to the
Signature of a target SmartHandle. The new SmartHandle's signature will
match this one, permuting those arguments and invoking the target handle.
@param target the SmartHandle to use as a permutation target
@return a new SmartHandle that permutes this Signature's args into a call
to the target SmartHandle.
@see Signature#permuteWith(java.lang.invoke.MethodHandle, java.lang.String[]) | [
"Produce",
"a",
"new",
"SmartHandle",
"by",
"permuting",
"this",
"Signature",
"s",
"arguments",
"to",
"the",
"Signature",
"of",
"a",
"target",
"SmartHandle",
".",
"The",
"new",
"SmartHandle",
"s",
"signature",
"will",
"match",
"this",
"one",
"permuting",
"thos... | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L744-L747 | train |
mcdiae/kludje | kludje-experimental/src/main/java/uk/kludje/experimental/stream/AltStreams.java | AltStreams.streamUntil | public static <E> Stream<E> streamUntil(Supplier<? extends E> supplier, Predicate<? super E> stop) {
Iterator<E> iterator = AltIterators.iterateUntil(supplier, stop);
Spliterator<E> spliterator = Spliterators.spliterator(iterator, Long.MAX_VALUE, Spliterator.ORDERED);
return StreamSupport.stream(spliterator, false);
} | java | public static <E> Stream<E> streamUntil(Supplier<? extends E> supplier, Predicate<? super E> stop) {
Iterator<E> iterator = AltIterators.iterateUntil(supplier, stop);
Spliterator<E> spliterator = Spliterators.spliterator(iterator, Long.MAX_VALUE, Spliterator.ORDERED);
return StreamSupport.stream(spliterator, false);
} | [
"public",
"static",
"<",
"E",
">",
"Stream",
"<",
"E",
">",
"streamUntil",
"(",
"Supplier",
"<",
"?",
"extends",
"E",
">",
"supplier",
",",
"Predicate",
"<",
"?",
"super",
"E",
">",
"stop",
")",
"{",
"Iterator",
"<",
"E",
">",
"iterator",
"=",
"Alt... | Consumes data from the supplier until a condition is met.
Use this method where a "poison pill" can be supplied to stop processing.
@param supplier element source
@param stop stops invoking supplier when this returns true
@param <E> the element type
@return a new stream | [
"Consumes",
"data",
"from",
"the",
"supplier",
"until",
"a",
"condition",
"is",
"met",
".",
"Use",
"this",
"method",
"where",
"a",
"poison",
"pill",
"can",
"be",
"supplied",
"to",
"stop",
"processing",
"."
] | 9ed80cd183ebf162708d5922d784f79ac3841dfc | https://github.com/mcdiae/kludje/blob/9ed80cd183ebf162708d5922d784f79ac3841dfc/kludje-experimental/src/main/java/uk/kludje/experimental/stream/AltStreams.java#L47-L52 | train |
mcdiae/kludje | kludje-experimental/src/main/java/uk/kludje/experimental/array/LinearSearch.java | LinearSearch.find | public static int find(int[] arr, int start, int end, int valueToFind) {
assert arr != null;
assert end >= 0;
assert end <= arr.length;
for (int i = start; i < end; i++) {
if (arr[i] == valueToFind) {
return i;
}
}
return NOT_FOUND;
} | java | public static int find(int[] arr, int start, int end, int valueToFind) {
assert arr != null;
assert end >= 0;
assert end <= arr.length;
for (int i = start; i < end; i++) {
if (arr[i] == valueToFind) {
return i;
}
}
return NOT_FOUND;
} | [
"public",
"static",
"int",
"find",
"(",
"int",
"[",
"]",
"arr",
",",
"int",
"start",
",",
"int",
"end",
",",
"int",
"valueToFind",
")",
"{",
"assert",
"arr",
"!=",
"null",
";",
"assert",
"end",
">=",
"0",
";",
"assert",
"end",
"<=",
"arr",
".",
"... | Finds a value in an int array.
@param arr the target array
@param start the inclusive initial value to check
@param end the exclusive end value to check
@param valueToFind the value to find
@return the index1 or NOT_FOUND | [
"Finds",
"a",
"value",
"in",
"an",
"int",
"array",
"."
] | 9ed80cd183ebf162708d5922d784f79ac3841dfc | https://github.com/mcdiae/kludje/blob/9ed80cd183ebf162708d5922d784f79ac3841dfc/kludje-experimental/src/main/java/uk/kludje/experimental/array/LinearSearch.java#L40-L53 | train |
mcdiae/kludje | kludje-experimental/src/main/java/uk/kludje/experimental/array/LinearSearch.java | LinearSearch.find | public static int find(Object[] arr, int start, int end, Object valueToFind) {
assert arr != null;
assert end >= 0;
assert end <= arr.length;
for (int i = start; i < end; i++) {
if (Objects.equals(arr[i], valueToFind)) {
return i;
}
}
return NOT_FOUND;
} | java | public static int find(Object[] arr, int start, int end, Object valueToFind) {
assert arr != null;
assert end >= 0;
assert end <= arr.length;
for (int i = start; i < end; i++) {
if (Objects.equals(arr[i], valueToFind)) {
return i;
}
}
return NOT_FOUND;
} | [
"public",
"static",
"int",
"find",
"(",
"Object",
"[",
"]",
"arr",
",",
"int",
"start",
",",
"int",
"end",
",",
"Object",
"valueToFind",
")",
"{",
"assert",
"arr",
"!=",
"null",
";",
"assert",
"end",
">=",
"0",
";",
"assert",
"end",
"<=",
"arr",
".... | Finds a value in an Object array.
@param arr the target array
@param start the inclusive initial value to check
@param end the exclusive end value to check
@param valueToFind the value to find
@return the index1 or NOT_FOUND | [
"Finds",
"a",
"value",
"in",
"an",
"Object",
"array",
"."
] | 9ed80cd183ebf162708d5922d784f79ac3841dfc | https://github.com/mcdiae/kludje/blob/9ed80cd183ebf162708d5922d784f79ac3841dfc/kludje-experimental/src/main/java/uk/kludje/experimental/array/LinearSearch.java#L64-L77 | train |
mcdiae/kludje | kludje-experimental/src/main/java/uk/kludje/experimental/fluent/Mutator.java | Mutator.mutate | public static <T> Mutator<T> mutate(T t) {
Objects.requireNonNull(t);
return new Mutator<>(t);
} | java | public static <T> Mutator<T> mutate(T t) {
Objects.requireNonNull(t);
return new Mutator<>(t);
} | [
"public",
"static",
"<",
"T",
">",
"Mutator",
"<",
"T",
">",
"mutate",
"(",
"T",
"t",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"t",
")",
";",
"return",
"new",
"Mutator",
"<>",
"(",
"t",
")",
";",
"}"
] | Creates a new mutate instance.
@param t the non-null type to adapt
@param <T> the adapted type
@return a new instance | [
"Creates",
"a",
"new",
"mutate",
"instance",
"."
] | 9ed80cd183ebf162708d5922d784f79ac3841dfc | https://github.com/mcdiae/kludje/blob/9ed80cd183ebf162708d5922d784f79ac3841dfc/kludje-experimental/src/main/java/uk/kludje/experimental/fluent/Mutator.java#L48-L51 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/util/DefaultRequestExecutor.java | DefaultRequestExecutor.executeOnce | private HttpResponse executeOnce(RequestSetup setup) throws IOException {
DefaultRequestDefinition req = new DefaultRequestDefinition();
setup.setup(req);
HttpResponse response = req.execute();
// This will force the request to complete, causing any timeout exceptions to happen here
response.getResponseCode();
return response;
} | java | private HttpResponse executeOnce(RequestSetup setup) throws IOException {
DefaultRequestDefinition req = new DefaultRequestDefinition();
setup.setup(req);
HttpResponse response = req.execute();
// This will force the request to complete, causing any timeout exceptions to happen here
response.getResponseCode();
return response;
} | [
"private",
"HttpResponse",
"executeOnce",
"(",
"RequestSetup",
"setup",
")",
"throws",
"IOException",
"{",
"DefaultRequestDefinition",
"req",
"=",
"new",
"DefaultRequestDefinition",
"(",
")",
";",
"setup",
".",
"setup",
"(",
"req",
")",
";",
"HttpResponse",
"respo... | Execute given the specified http method once, throwing any exceptions as they come | [
"Execute",
"given",
"the",
"specified",
"http",
"method",
"once",
"throwing",
"any",
"exceptions",
"as",
"they",
"come"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/util/DefaultRequestExecutor.java#L126-L136 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/transform/Transform.java | Transform.buildClassArguments | protected static void buildClassArguments(StringBuilder builder, Class<?>[] types) {
boolean second = false;
for (Class cls : types) {
if (second) builder.append(", ");
second = true;
buildClassArgument(builder, cls);
}
} | java | protected static void buildClassArguments(StringBuilder builder, Class<?>[] types) {
boolean second = false;
for (Class cls : types) {
if (second) builder.append(", ");
second = true;
buildClassArgument(builder, cls);
}
} | [
"protected",
"static",
"void",
"buildClassArguments",
"(",
"StringBuilder",
"builder",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"types",
")",
"{",
"boolean",
"second",
"=",
"false",
";",
"for",
"(",
"Class",
"cls",
":",
"types",
")",
"{",
"if",
"(",
"sec... | Build a list of argument type classes suitable for inserting into Java code.
This will be an argument list of the form "pkg.Cls1.class, pkg.Cls2[].class, primtype.class, ..."
@param builder the builder in which to build the argument list
@param types the classes from which to create the argument list | [
"Build",
"a",
"list",
"of",
"argument",
"type",
"classes",
"suitable",
"for",
"inserting",
"into",
"Java",
"code",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/transform/Transform.java#L65-L72 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/transform/Transform.java | Transform.buildClassArgument | protected static void buildClassArgument(StringBuilder builder, Class cls) {
buildClass(builder, cls);
builder.append(".class");
} | java | protected static void buildClassArgument(StringBuilder builder, Class cls) {
buildClass(builder, cls);
builder.append(".class");
} | [
"protected",
"static",
"void",
"buildClassArgument",
"(",
"StringBuilder",
"builder",
",",
"Class",
"cls",
")",
"{",
"buildClass",
"(",
"builder",
",",
"cls",
")",
";",
"builder",
".",
"append",
"(",
"\".class\"",
")",
";",
"}"
] | Build Java code to represent a single .class reference.
This will be an argument of the form "pkg.Cls1.class" or "pkg.Cls2[].class" or "primtype.class"
@param builder the builder in which to build the argument
@param cls the type for the argument | [
"Build",
"Java",
"code",
"to",
"represent",
"a",
"single",
".",
"class",
"reference",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/transform/Transform.java#L82-L85 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/transform/Transform.java | Transform.buildClassCast | protected static void buildClassCast(StringBuilder builder, Class cls) {
builder.append('(');
buildClass(builder, cls);
builder.append(')');
} | java | protected static void buildClassCast(StringBuilder builder, Class cls) {
builder.append('(');
buildClass(builder, cls);
builder.append(')');
} | [
"protected",
"static",
"void",
"buildClassCast",
"(",
"StringBuilder",
"builder",
",",
"Class",
"cls",
")",
"{",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"buildClass",
"(",
"builder",
",",
"cls",
")",
";",
"builder",
".",
"append",
"(",
"'",
... | Build Java code to represent a cast to the given type.
This will be an argument of the form "(pkg.Cls1)" or "(pkg.Cls2[])" or "(primtype)"
@param builder the builder in which to build the argument
@param cls the type for the argument | [
"Build",
"Java",
"code",
"to",
"represent",
"a",
"cast",
"to",
"the",
"given",
"type",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/transform/Transform.java#L95-L99 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/transform/Transform.java | Transform.buildPrimitiveJava | protected static void buildPrimitiveJava(StringBuilder builder, Object value) {
builder.append(value.toString());
if (value.getClass() == Float.class) builder.append('F');
if (value.getClass() == Long.class) builder.append('L');
} | java | protected static void buildPrimitiveJava(StringBuilder builder, Object value) {
builder.append(value.toString());
if (value.getClass() == Float.class) builder.append('F');
if (value.getClass() == Long.class) builder.append('L');
} | [
"protected",
"static",
"void",
"buildPrimitiveJava",
"(",
"StringBuilder",
"builder",
",",
"Object",
"value",
")",
"{",
"builder",
".",
"append",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"value",
".",
"getClass",
"(",
")",
"==",
"Flo... | Build Java code to represent a literal primitive.
This will append L or F as appropriate for long and float primitives.
@param builder the builder in which to generate the code
@param value the primitive value to generate from | [
"Build",
"Java",
"code",
"to",
"represent",
"a",
"literal",
"primitive",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/transform/Transform.java#L109-L113 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/transform/Transform.java | Transform.buildClass | private static void buildClass(StringBuilder builder, Class cls) {
int arrayDims = 0;
Class tmp = cls;
while (tmp.isArray()) {
arrayDims++;
tmp = tmp.getComponentType();
}
builder.append(tmp.getName());
if (arrayDims > 0) {
for (; arrayDims > 0 ; arrayDims--) {
builder.append("[]");
}
}
} | java | private static void buildClass(StringBuilder builder, Class cls) {
int arrayDims = 0;
Class tmp = cls;
while (tmp.isArray()) {
arrayDims++;
tmp = tmp.getComponentType();
}
builder.append(tmp.getName());
if (arrayDims > 0) {
for (; arrayDims > 0 ; arrayDims--) {
builder.append("[]");
}
}
} | [
"private",
"static",
"void",
"buildClass",
"(",
"StringBuilder",
"builder",
",",
"Class",
"cls",
")",
"{",
"int",
"arrayDims",
"=",
"0",
";",
"Class",
"tmp",
"=",
"cls",
";",
"while",
"(",
"tmp",
".",
"isArray",
"(",
")",
")",
"{",
"arrayDims",
"++",
... | Build Java code to represent a type reference to the given class.
This will be of the form "pkg.Cls1" or "pkc.Cls2[]" or "primtype".
@param builder the builder in which to build the type reference
@param cls the type for the reference | [
"Build",
"Java",
"code",
"to",
"represent",
"a",
"type",
"reference",
"to",
"the",
"given",
"class",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/transform/Transform.java#L123-L136 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/transform/Transform.java | Transform.generateMethodType | public static String generateMethodType(MethodType source) {
StringBuilder builder = new StringBuilder("MethodType.methodType(");
buildClassArgument(builder, source.returnType());
if (source.parameterCount() > 0) {
builder.append(", ");
buildClassArguments(builder, source.parameterArray());
}
builder.append(")");
return builder.toString();
} | java | public static String generateMethodType(MethodType source) {
StringBuilder builder = new StringBuilder("MethodType.methodType(");
buildClassArgument(builder, source.returnType());
if (source.parameterCount() > 0) {
builder.append(", ");
buildClassArguments(builder, source.parameterArray());
}
builder.append(")");
return builder.toString();
} | [
"public",
"static",
"String",
"generateMethodType",
"(",
"MethodType",
"source",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"\"MethodType.methodType(\"",
")",
";",
"buildClassArgument",
"(",
"builder",
",",
"source",
".",
"returnType",
"... | Build Java code appropriate for standing up the given MethodType.
@param source the MethodType for which to build Java code
@return Java code suitable for building the given MethodType | [
"Build",
"Java",
"code",
"appropriate",
"for",
"standing",
"up",
"the",
"given",
"MethodType",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/transform/Transform.java#L144-L153 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/util/RequestBuilder.java | RequestBuilder.execute | protected HttpResponse execute(final HttpMethod meth, String postURL) throws IOException {
final String url = (meth == HttpMethod.POST) ? postURL : this.toString();
if (log.isLoggable(Level.FINER))
log.finer(meth + "ing: " + url);
return RequestExecutor.instance().execute(this.retries, new RequestSetup() {
public void setup(RequestDefinition req) throws IOException {
req.init(meth, url);
for (Map.Entry<String, String> header: headers.entrySet())
req.setHeader(header.getKey(), header.getValue());
if (timeout > 0)
req.setTimeout(timeout);
if (meth == HttpMethod.POST && !params.isEmpty()) {
if (!hasBinaryAttachments) {
String queryString = createQueryString();
if (log.isLoggable(Level.FINER))
log.finer("POST data is: " + queryString);
// This is more efficient if we don't have any binary attachments
req.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
req.setContent(queryString.getBytes("utf-8"));
} else {
log.finer("POST contains binary data, sending multipart/form-data");
// Binary attachments requires more complicated multipart/form-data format
MultipartWriter writer = new MultipartWriter(req);
writer.write(params);
}
}
}
});
} | java | protected HttpResponse execute(final HttpMethod meth, String postURL) throws IOException {
final String url = (meth == HttpMethod.POST) ? postURL : this.toString();
if (log.isLoggable(Level.FINER))
log.finer(meth + "ing: " + url);
return RequestExecutor.instance().execute(this.retries, new RequestSetup() {
public void setup(RequestDefinition req) throws IOException {
req.init(meth, url);
for (Map.Entry<String, String> header: headers.entrySet())
req.setHeader(header.getKey(), header.getValue());
if (timeout > 0)
req.setTimeout(timeout);
if (meth == HttpMethod.POST && !params.isEmpty()) {
if (!hasBinaryAttachments) {
String queryString = createQueryString();
if (log.isLoggable(Level.FINER))
log.finer("POST data is: " + queryString);
// This is more efficient if we don't have any binary attachments
req.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
req.setContent(queryString.getBytes("utf-8"));
} else {
log.finer("POST contains binary data, sending multipart/form-data");
// Binary attachments requires more complicated multipart/form-data format
MultipartWriter writer = new MultipartWriter(req);
writer.write(params);
}
}
}
});
} | [
"protected",
"HttpResponse",
"execute",
"(",
"final",
"HttpMethod",
"meth",
",",
"String",
"postURL",
")",
"throws",
"IOException",
"{",
"final",
"String",
"url",
"=",
"(",
"meth",
"==",
"HttpMethod",
".",
"POST",
")",
"?",
"postURL",
":",
"this",
".",
"to... | Execute given the specified http method, retrying up to the allowed number of retries.
@postURL is the url to use if this is a POST request; ignored otherwise. | [
"Execute",
"given",
"the",
"specified",
"http",
"method",
"retrying",
"up",
"to",
"the",
"allowed",
"number",
"of",
"retries",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/util/RequestBuilder.java#L153-L189 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/util/RequestBuilder.java | RequestBuilder.createQueryString | protected String createQueryString() {
assert !this.hasBinaryAttachments;
if (this.params.isEmpty())
return "";
StringBuilder bld = null;
for (Map.Entry<String, Object> param: this.params.entrySet()) {
if (bld == null)
bld = new StringBuilder();
else
bld.append('&');
bld.append(StringUtils.urlEncode(param.getKey()));
bld.append('=');
bld.append(StringUtils.urlEncode(param.getValue().toString()));
}
return bld.toString();
} | java | protected String createQueryString() {
assert !this.hasBinaryAttachments;
if (this.params.isEmpty())
return "";
StringBuilder bld = null;
for (Map.Entry<String, Object> param: this.params.entrySet()) {
if (bld == null)
bld = new StringBuilder();
else
bld.append('&');
bld.append(StringUtils.urlEncode(param.getKey()));
bld.append('=');
bld.append(StringUtils.urlEncode(param.getValue().toString()));
}
return bld.toString();
} | [
"protected",
"String",
"createQueryString",
"(",
")",
"{",
"assert",
"!",
"this",
".",
"hasBinaryAttachments",
";",
"if",
"(",
"this",
".",
"params",
".",
"isEmpty",
"(",
")",
")",
"return",
"\"\"",
";",
"StringBuilder",
"bld",
"=",
"null",
";",
"for",
"... | Creates a string representing the current query string, or an empty string if there are no parameters. Will not work if there are binary
attachments! | [
"Creates",
"a",
"string",
"representing",
"the",
"current",
"query",
"string",
"or",
"an",
"empty",
"string",
"if",
"there",
"are",
"no",
"parameters",
".",
"Will",
"not",
"work",
"if",
"there",
"are",
"binary",
"attachments!"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/util/RequestBuilder.java#L195-L215 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/FacebookCookie.java | FacebookCookie.decode | public static FacebookCookie decode(String cookie, String appSecret)
{
// Parsing and verifying signature seems to be poorly documented, but here's what I've found:
// Look at parseSignedRequest() in https://github.com/facebook/php-sdk/blob/master/src/base_facebook.php
// Python version: https://developers.facebook.com/docs/samples/canvas/
try {
String[] parts = cookie.split("\\.");
byte[] sig = Base64.decodeBase64(parts[0]);
byte[] json = Base64.decodeBase64(parts[1]);
byte[] plaintext = parts[1].getBytes(); // careful, we compute against the base64 encoded version
FacebookCookie decoded = MAPPER.readValue(json, FacebookCookie.class);
// "HMAC-SHA256" doesn't work, but "HMACSHA256" does.
String algorithm = decoded.algorithm.replace("-", "");
SecretKey secret = new SecretKeySpec(appSecret.getBytes(), algorithm);
Mac mac = Mac.getInstance(algorithm);
mac.init(secret);
byte[] digested = mac.doFinal(plaintext);
if (!Arrays.equals(sig, digested))
throw new IllegalStateException("Signature failed");
return decoded;
} catch (Exception ex) {
throw new IllegalStateException("Unable to decode cookie", ex);
}
} | java | public static FacebookCookie decode(String cookie, String appSecret)
{
// Parsing and verifying signature seems to be poorly documented, but here's what I've found:
// Look at parseSignedRequest() in https://github.com/facebook/php-sdk/blob/master/src/base_facebook.php
// Python version: https://developers.facebook.com/docs/samples/canvas/
try {
String[] parts = cookie.split("\\.");
byte[] sig = Base64.decodeBase64(parts[0]);
byte[] json = Base64.decodeBase64(parts[1]);
byte[] plaintext = parts[1].getBytes(); // careful, we compute against the base64 encoded version
FacebookCookie decoded = MAPPER.readValue(json, FacebookCookie.class);
// "HMAC-SHA256" doesn't work, but "HMACSHA256" does.
String algorithm = decoded.algorithm.replace("-", "");
SecretKey secret = new SecretKeySpec(appSecret.getBytes(), algorithm);
Mac mac = Mac.getInstance(algorithm);
mac.init(secret);
byte[] digested = mac.doFinal(plaintext);
if (!Arrays.equals(sig, digested))
throw new IllegalStateException("Signature failed");
return decoded;
} catch (Exception ex) {
throw new IllegalStateException("Unable to decode cookie", ex);
}
} | [
"public",
"static",
"FacebookCookie",
"decode",
"(",
"String",
"cookie",
",",
"String",
"appSecret",
")",
"{",
"// Parsing and verifying signature seems to be poorly documented, but here's what I've found:\r",
"// Look at parseSignedRequest() in https://github.com/facebook/php-sdk/blob/mas... | Decodes and validates the cookie.
@param cookie is the fbsr_YOURAPPID cookie from Facebook
@param appSecret is your application secret from the Facebook Developer application console
@throws IllegalStateException if the cookie does not validate | [
"Decodes",
"and",
"validates",
"the",
"cookie",
"."
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/FacebookCookie.java#L60-L91 | train |
jspringbot/jspringbot | src/main/java/org/jspringbot/spring/KeywordUtils.java | KeywordUtils.getKeywordMap | public static Map<String, String> getKeywordMap(ApplicationContext context) {
Map<String, String> keywordToBeanMap = new HashMap<String, String>();
// Retrieve beans implementing the Keyword interface.
String[] beanNames = context.getBeanNamesForType(Keyword.class);
for (String beanName : beanNames) {
Object bean = context.getBean(beanName);
// Retrieve keyword information
KeywordInfo keywordInfo = AnnotationUtils.findAnnotation(bean.getClass(), KeywordInfo.class);
// Set keyword name as specified in the keyword info, or if information is not available, use bean name.
String keywordName = keywordInfo != null ? keywordInfo.name() : beanName;
if (keywordToBeanMap.put(keywordName, beanName) != null) {
// If map already contains the keyword name, throw an exception. Keywords should be unique.
throw new RuntimeException("Multiple definitions for keyword '" + keywordName + "' exists.");
}
}
return keywordToBeanMap;
} | java | public static Map<String, String> getKeywordMap(ApplicationContext context) {
Map<String, String> keywordToBeanMap = new HashMap<String, String>();
// Retrieve beans implementing the Keyword interface.
String[] beanNames = context.getBeanNamesForType(Keyword.class);
for (String beanName : beanNames) {
Object bean = context.getBean(beanName);
// Retrieve keyword information
KeywordInfo keywordInfo = AnnotationUtils.findAnnotation(bean.getClass(), KeywordInfo.class);
// Set keyword name as specified in the keyword info, or if information is not available, use bean name.
String keywordName = keywordInfo != null ? keywordInfo.name() : beanName;
if (keywordToBeanMap.put(keywordName, beanName) != null) {
// If map already contains the keyword name, throw an exception. Keywords should be unique.
throw new RuntimeException("Multiple definitions for keyword '" + keywordName + "' exists.");
}
}
return keywordToBeanMap;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"getKeywordMap",
"(",
"ApplicationContext",
"context",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"keywordToBeanMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",... | Builds mapping of robot keywords to actual bean names in spring context.
@param context Spring application context.
@return mapping of robot keywords to bean names | [
"Builds",
"mapping",
"of",
"robot",
"keywords",
"to",
"actual",
"bean",
"names",
"in",
"spring",
"context",
"."
] | 03285a7013492fb793cb0c38a4625a5f5c5750e0 | https://github.com/jspringbot/jspringbot/blob/03285a7013492fb793cb0c38a4625a5f5c5750e0/src/main/java/org/jspringbot/spring/KeywordUtils.java#L57-L79 | train |
jspringbot/jspringbot | src/main/java/org/jspringbot/spring/KeywordUtils.java | KeywordUtils.getDescription | public static String getDescription(String keyword, ApplicationContext context, Map<String, String> beanMap) {
KeywordInfo keywordInfo = getKeywordInfo(keyword, context, beanMap);
if(keywordInfo == null) {
return "";
}
String desc = keywordInfo.description();
if(desc.startsWith("classpath:")) {
try {
ResourceEditor editor = new ResourceEditor();
editor.setAsText(desc);
Resource r = (Resource) editor.getValue();
return IOUtils.toString(r.getInputStream());
} catch (Exception ignored) {
}
}
return desc;
} | java | public static String getDescription(String keyword, ApplicationContext context, Map<String, String> beanMap) {
KeywordInfo keywordInfo = getKeywordInfo(keyword, context, beanMap);
if(keywordInfo == null) {
return "";
}
String desc = keywordInfo.description();
if(desc.startsWith("classpath:")) {
try {
ResourceEditor editor = new ResourceEditor();
editor.setAsText(desc);
Resource r = (Resource) editor.getValue();
return IOUtils.toString(r.getInputStream());
} catch (Exception ignored) {
}
}
return desc;
} | [
"public",
"static",
"String",
"getDescription",
"(",
"String",
"keyword",
",",
"ApplicationContext",
"context",
",",
"Map",
"<",
"String",
",",
"String",
">",
"beanMap",
")",
"{",
"KeywordInfo",
"keywordInfo",
"=",
"getKeywordInfo",
"(",
"keyword",
",",
"context... | Retrieves the given keyword's description.
@param keyword keyword name
@param context Spring application context
@param beanMap keyword name to bean name mapping
@return the documentation string of the given keyword, or empty string if unavailable. | [
"Retrieves",
"the",
"given",
"keyword",
"s",
"description",
"."
] | 03285a7013492fb793cb0c38a4625a5f5c5750e0 | https://github.com/jspringbot/jspringbot/blob/03285a7013492fb793cb0c38a4625a5f5c5750e0/src/main/java/org/jspringbot/spring/KeywordUtils.java#L90-L111 | train |
jspringbot/jspringbot | src/main/java/org/jspringbot/spring/KeywordUtils.java | KeywordUtils.getParameters | public static String[] getParameters(String keyword, ApplicationContext context, Map<String, String> beanMap) {
KeywordInfo keywordInfo = getKeywordInfo(keyword, context, beanMap);
return keywordInfo == null ? DEFAULT_PARAMS : keywordInfo.parameters();
} | java | public static String[] getParameters(String keyword, ApplicationContext context, Map<String, String> beanMap) {
KeywordInfo keywordInfo = getKeywordInfo(keyword, context, beanMap);
return keywordInfo == null ? DEFAULT_PARAMS : keywordInfo.parameters();
} | [
"public",
"static",
"String",
"[",
"]",
"getParameters",
"(",
"String",
"keyword",
",",
"ApplicationContext",
"context",
",",
"Map",
"<",
"String",
",",
"String",
">",
"beanMap",
")",
"{",
"KeywordInfo",
"keywordInfo",
"=",
"getKeywordInfo",
"(",
"keyword",
",... | Retrieves the given keyword's parameter description.
@param keyword keyword name
@param context Spring application context
@param beanMap keyword name to bean name mapping
@return the parameter description string of the given keyword, or {"*args"} if unavailable. | [
"Retrieves",
"the",
"given",
"keyword",
"s",
"parameter",
"description",
"."
] | 03285a7013492fb793cb0c38a4625a5f5c5750e0 | https://github.com/jspringbot/jspringbot/blob/03285a7013492fb793cb0c38a4625a5f5c5750e0/src/main/java/org/jspringbot/spring/KeywordUtils.java#L121-L125 | train |
jspringbot/jspringbot | src/main/java/org/jspringbot/spring/KeywordUtils.java | KeywordUtils.getKeywordInfo | public static KeywordInfo getKeywordInfo(String keyword, ApplicationContext context, Map<String, String> beanMap) {
Object bean = context.getBean(beanMap.get(keyword));
return AnnotationUtils.findAnnotation(bean.getClass(), KeywordInfo.class);
} | java | public static KeywordInfo getKeywordInfo(String keyword, ApplicationContext context, Map<String, String> beanMap) {
Object bean = context.getBean(beanMap.get(keyword));
return AnnotationUtils.findAnnotation(bean.getClass(), KeywordInfo.class);
} | [
"public",
"static",
"KeywordInfo",
"getKeywordInfo",
"(",
"String",
"keyword",
",",
"ApplicationContext",
"context",
",",
"Map",
"<",
"String",
",",
"String",
">",
"beanMap",
")",
"{",
"Object",
"bean",
"=",
"context",
".",
"getBean",
"(",
"beanMap",
".",
"g... | Retrieves the KeywordInfo of the given keyword.
@param keyword keyword name
@param context Spring application context
@param beanMap keyword name to bean name mapping
@return KeywordInfo object or null if unavailable | [
"Retrieves",
"the",
"KeywordInfo",
"of",
"the",
"given",
"keyword",
"."
] | 03285a7013492fb793cb0c38a4625a5f5c5750e0 | https://github.com/jspringbot/jspringbot/blob/03285a7013492fb793cb0c38a4625a5f5c5750e0/src/main/java/org/jspringbot/spring/KeywordUtils.java#L135-L138 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/MultiqueryRequest.java | MultiqueryRequest.getParams | @Override
@JsonIgnore
protected Param[] getParams() {
Map<String, String> queries = new LinkedHashMap<String, String>();
for (QueryRequest<?> req: this.queryRequests)
queries.put(req.getName(), req.getFQL());
String json = JSONUtils.toJSON(queries, this.mapper);
return new Param[] { new Param("queries", json) };
} | java | @Override
@JsonIgnore
protected Param[] getParams() {
Map<String, String> queries = new LinkedHashMap<String, String>();
for (QueryRequest<?> req: this.queryRequests)
queries.put(req.getName(), req.getFQL());
String json = JSONUtils.toJSON(queries, this.mapper);
return new Param[] { new Param("queries", json) };
} | [
"@",
"Override",
"@",
"JsonIgnore",
"protected",
"Param",
"[",
"]",
"getParams",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"queries",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"QueryReques... | Generate the parameters approprate to a multiquery from the registered queries | [
"Generate",
"the",
"parameters",
"approprate",
"to",
"a",
"multiquery",
"from",
"the",
"registered",
"queries"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/MultiqueryRequest.java#L38-L48 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/GraphRequestBase.java | GraphRequestBase.getRelativeURL | @JsonProperty("relative_url")
public String getRelativeURL() {
StringBuilder bld = new StringBuilder();
bld.append(this.object);
Param[] params = this.getParams();
if (params != null && params.length > 0) {
bld.append('?');
boolean afterFirst = false;
for (Param param: params) {
if (afterFirst)
bld.append('&');
else
afterFirst = true;
if (param instanceof BinaryParam) {
//call.addParam(param.name, (InputStream)param.value, ((BinaryParam)param).contentType, "irrelevant");
throw new UnsupportedOperationException("Not quite sure what to do with BinaryParam yet");
} else {
String paramValue = StringUtils.stringifyValue(param, this.mapper);
bld.append(StringUtils.urlEncode(param.name));
bld.append('=');
bld.append(StringUtils.urlEncode(paramValue));
}
}
}
return bld.toString();
} | java | @JsonProperty("relative_url")
public String getRelativeURL() {
StringBuilder bld = new StringBuilder();
bld.append(this.object);
Param[] params = this.getParams();
if (params != null && params.length > 0) {
bld.append('?');
boolean afterFirst = false;
for (Param param: params) {
if (afterFirst)
bld.append('&');
else
afterFirst = true;
if (param instanceof BinaryParam) {
//call.addParam(param.name, (InputStream)param.value, ((BinaryParam)param).contentType, "irrelevant");
throw new UnsupportedOperationException("Not quite sure what to do with BinaryParam yet");
} else {
String paramValue = StringUtils.stringifyValue(param, this.mapper);
bld.append(StringUtils.urlEncode(param.name));
bld.append('=');
bld.append(StringUtils.urlEncode(paramValue));
}
}
}
return bld.toString();
} | [
"@",
"JsonProperty",
"(",
"\"relative_url\"",
")",
"public",
"String",
"getRelativeURL",
"(",
")",
"{",
"StringBuilder",
"bld",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"bld",
".",
"append",
"(",
"this",
".",
"object",
")",
";",
"Param",
"[",
"]",
"pa... | What Facebook uses to define the url in a batch | [
"What",
"Facebook",
"uses",
"to",
"define",
"the",
"url",
"in",
"a",
"batch"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/GraphRequestBase.java#L57-L87 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartHandle.java | SmartHandle.findStaticQuiet | public static SmartHandle findStaticQuiet(Lookup lookup, Class<?> target, String name, Signature signature) {
try {
return new SmartHandle(signature, lookup.findStatic(target, name, signature.type()));
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java | public static SmartHandle findStaticQuiet(Lookup lookup, Class<?> target, String name, Signature signature) {
try {
return new SmartHandle(signature, lookup.findStatic(target, name, signature.type()));
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"SmartHandle",
"findStaticQuiet",
"(",
"Lookup",
"lookup",
",",
"Class",
"<",
"?",
">",
"target",
",",
"String",
"name",
",",
"Signature",
"signature",
")",
"{",
"try",
"{",
"return",
"new",
"SmartHandle",
"(",
"signature",
",",
"lookup",... | Create a new SmartHandle by performing a lookup on the given target class
for the given method name with the given signature.
@param lookup the MethodHandles.Lookup object to use
@param target the class where the method is located
@param name the name of the method
@param signature the signature of the method
@return a new SmartHandle based on the signature and looked-up MethodHandle | [
"Create",
"a",
"new",
"SmartHandle",
"by",
"performing",
"a",
"lookup",
"on",
"the",
"given",
"target",
"class",
"for",
"the",
"given",
"method",
"name",
"with",
"the",
"given",
"signature",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartHandle.java#L103-L109 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartHandle.java | SmartHandle.drop | public SmartHandle drop(String beforeName, String newName, Class<?> type) {
return new SmartHandle(signature.insertArg(beforeName, newName, type), MethodHandles.dropArguments(handle, signature.argOffset(beforeName), type));
} | java | public SmartHandle drop(String beforeName, String newName, Class<?> type) {
return new SmartHandle(signature.insertArg(beforeName, newName, type), MethodHandles.dropArguments(handle, signature.argOffset(beforeName), type));
} | [
"public",
"SmartHandle",
"drop",
"(",
"String",
"beforeName",
",",
"String",
"newName",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"new",
"SmartHandle",
"(",
"signature",
".",
"insertArg",
"(",
"beforeName",
",",
"newName",
",",
"type",
")",
... | Drop an argument name and type from the handle at the given index, returning a new
SmartHandle.
@param beforeName name before which the dropped argument goes
@param newName name of the argument
@param type type of the argument
@return a new SmartHandle with the additional argument | [
"Drop",
"an",
"argument",
"name",
"and",
"type",
"from",
"the",
"handle",
"at",
"the",
"given",
"index",
"returning",
"a",
"new",
"SmartHandle",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartHandle.java#L179-L181 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartHandle.java | SmartHandle.drop | public SmartHandle drop(int index, String newName, Class<?> type) {
return new SmartHandle(signature.insertArg(index, newName, type), MethodHandles.dropArguments(handle, index, type));
} | java | public SmartHandle drop(int index, String newName, Class<?> type) {
return new SmartHandle(signature.insertArg(index, newName, type), MethodHandles.dropArguments(handle, index, type));
} | [
"public",
"SmartHandle",
"drop",
"(",
"int",
"index",
",",
"String",
"newName",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"new",
"SmartHandle",
"(",
"signature",
".",
"insertArg",
"(",
"index",
",",
"newName",
",",
"type",
")",
",",
"Met... | Drop an argument from the handle at the given index, returning a new
SmartHandle.
@param index index before which the dropped argument goes
@param newName name of the argument
@param type type of the argument
@return a new SmartHandle with the additional argument | [
"Drop",
"an",
"argument",
"from",
"the",
"handle",
"at",
"the",
"given",
"index",
"returning",
"a",
"new",
"SmartHandle",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartHandle.java#L192-L194 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartHandle.java | SmartHandle.dropLast | public SmartHandle dropLast(String newName, Class<?> type) {
return new SmartHandle(signature.appendArg(newName, type), MethodHandles.dropArguments(handle, signature.argOffset(newName), type));
} | java | public SmartHandle dropLast(String newName, Class<?> type) {
return new SmartHandle(signature.appendArg(newName, type), MethodHandles.dropArguments(handle, signature.argOffset(newName), type));
} | [
"public",
"SmartHandle",
"dropLast",
"(",
"String",
"newName",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"new",
"SmartHandle",
"(",
"signature",
".",
"appendArg",
"(",
"newName",
",",
"type",
")",
",",
"MethodHandles",
".",
"dropArguments",
... | Drop an argument from the handle at the end, returning a new
SmartHandle.
@param newName name of the argument
@param type type of the argument
@return a new SmartHandle with the additional argument | [
"Drop",
"an",
"argument",
"from",
"the",
"handle",
"at",
"the",
"end",
"returning",
"a",
"new",
"SmartHandle",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartHandle.java#L204-L206 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartHandle.java | SmartHandle.bindTo | public SmartHandle bindTo(Object obj) {
return new SmartHandle(signature.dropFirst(), handle.bindTo(obj));
} | java | public SmartHandle bindTo(Object obj) {
return new SmartHandle(signature.dropFirst(), handle.bindTo(obj));
} | [
"public",
"SmartHandle",
"bindTo",
"(",
"Object",
"obj",
")",
"{",
"return",
"new",
"SmartHandle",
"(",
"signature",
".",
"dropFirst",
"(",
")",
",",
"handle",
".",
"bindTo",
"(",
"obj",
")",
")",
";",
"}"
] | Bind the first argument of this SmartHandle to the given object,
returning a new adapted handle.
@param obj the object to which to bind this handle's first argument
@return a new SmartHandle with the first argument dropped in favor of obj | [
"Bind",
"the",
"first",
"argument",
"of",
"this",
"SmartHandle",
"to",
"the",
"given",
"object",
"returning",
"a",
"new",
"adapted",
"handle",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartHandle.java#L237-L239 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartHandle.java | SmartHandle.returnValue | public SmartHandle returnValue(Class<?> type, Object value) {
return new SmartHandle(signature.changeReturn(type), MethodHandles.filterReturnValue(handle, MethodHandles.constant(type, value)));
} | java | public SmartHandle returnValue(Class<?> type, Object value) {
return new SmartHandle(signature.changeReturn(type), MethodHandles.filterReturnValue(handle, MethodHandles.constant(type, value)));
} | [
"public",
"SmartHandle",
"returnValue",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"SmartHandle",
"(",
"signature",
".",
"changeReturn",
"(",
"type",
")",
",",
"MethodHandles",
".",
"filterReturnValue",
"(",
"hand... | Replace the return value with the given value, performing no other
processing of the original value.
@param type the type for the new return value
@param value the new value to return
@return a new SmartHandle that returns the given value | [
"Replace",
"the",
"return",
"value",
"with",
"the",
"given",
"value",
"performing",
"no",
"other",
"processing",
"of",
"the",
"original",
"value",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartHandle.java#L323-L325 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/util/JSONUtils.java | JSONUtils.toJSON | public static String toJSON(Object value, ObjectMapper mapper) {
try {
return mapper.writeValueAsString(value);
} catch (IOException ex) {
throw new FacebookException(ex);
}
} | java | public static String toJSON(Object value, ObjectMapper mapper) {
try {
return mapper.writeValueAsString(value);
} catch (IOException ex) {
throw new FacebookException(ex);
}
} | [
"public",
"static",
"String",
"toJSON",
"(",
"Object",
"value",
",",
"ObjectMapper",
"mapper",
")",
"{",
"try",
"{",
"return",
"mapper",
".",
"writeValueAsString",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
... | Converts the object to a JSON string using the mapper | [
"Converts",
"the",
"object",
"to",
"a",
"JSON",
"string",
"using",
"the",
"mapper"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/util/JSONUtils.java#L41-L47 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/util/JSONUtils.java | JSONUtils.toNode | public static JsonNode toNode(String value, ObjectMapper mapper) {
try {
return mapper.readTree(value);
} catch (IOException ex) {
throw new FacebookException(ex);
}
} | java | public static JsonNode toNode(String value, ObjectMapper mapper) {
try {
return mapper.readTree(value);
} catch (IOException ex) {
throw new FacebookException(ex);
}
} | [
"public",
"static",
"JsonNode",
"toNode",
"(",
"String",
"value",
",",
"ObjectMapper",
"mapper",
")",
"{",
"try",
"{",
"return",
"mapper",
".",
"readTree",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"Faceboo... | Parses a string into a JsonNode using the mapper | [
"Parses",
"a",
"string",
"into",
"a",
"JsonNode",
"using",
"the",
"mapper"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/util/JSONUtils.java#L52-L58 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/util/StringUtils.java | StringUtils.stringifyValue | public static String stringifyValue(Param param, ObjectMapper mapper) {
assert !(param instanceof BinaryParam);
if (param.value instanceof String)
return (String)param.value;
if (param.value instanceof Date)
return Long.toString(((Date)param.value).getTime() / 1000);
else if (param.value instanceof Number)
return param.value.toString();
else
return JSONUtils.toJSON(param.value, mapper);
} | java | public static String stringifyValue(Param param, ObjectMapper mapper) {
assert !(param instanceof BinaryParam);
if (param.value instanceof String)
return (String)param.value;
if (param.value instanceof Date)
return Long.toString(((Date)param.value).getTime() / 1000);
else if (param.value instanceof Number)
return param.value.toString();
else
return JSONUtils.toJSON(param.value, mapper);
} | [
"public",
"static",
"String",
"stringifyValue",
"(",
"Param",
"param",
",",
"ObjectMapper",
"mapper",
")",
"{",
"assert",
"!",
"(",
"param",
"instanceof",
"BinaryParam",
")",
";",
"if",
"(",
"param",
".",
"value",
"instanceof",
"String",
")",
"return",
"(",
... | Stringify the parameter value in an appropriate way. Note that Facebook fucks up dates by using unix time-since-epoch
some places and ISO-8601 others. However, maybe unix times always work as parameters? | [
"Stringify",
"the",
"parameter",
"value",
"in",
"an",
"appropriate",
"way",
".",
"Note",
"that",
"Facebook",
"fucks",
"up",
"dates",
"by",
"using",
"unix",
"time",
"-",
"since",
"-",
"epoch",
"some",
"places",
"and",
"ISO",
"-",
"8601",
"others",
".",
"H... | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/util/StringUtils.java#L70-L81 | train |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/util/StringUtils.java | StringUtils.read | public static String read(InputStream input) {
try {
StringBuilder bld = new StringBuilder();
Reader reader = new InputStreamReader(input, "utf-8");
int ch;
while ((ch = reader.read()) >= 0)
bld.append((char)ch);
return bld.toString();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
} | java | public static String read(InputStream input) {
try {
StringBuilder bld = new StringBuilder();
Reader reader = new InputStreamReader(input, "utf-8");
int ch;
while ((ch = reader.read()) >= 0)
bld.append((char)ch);
return bld.toString();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
} | [
"public",
"static",
"String",
"read",
"(",
"InputStream",
"input",
")",
"{",
"try",
"{",
"StringBuilder",
"bld",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Reader",
"reader",
"=",
"new",
"InputStreamReader",
"(",
"input",
",",
"\"utf-8\"",
")",
";",
"int... | Reads an input stream into a String, encoding with UTF-8 | [
"Reads",
"an",
"input",
"stream",
"into",
"a",
"String",
"encoding",
"with",
"UTF",
"-",
"8"
] | ceeda78aa6d8397eec032ab1d8997adb7378e9e2 | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/util/StringUtils.java#L86-L98 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.from | public static Binder from(MethodHandles.Lookup lookup, Binder start) {
return new Binder(lookup, start);
} | java | public static Binder from(MethodHandles.Lookup lookup, Binder start) {
return new Binder(lookup, start);
} | [
"public",
"static",
"Binder",
"from",
"(",
"MethodHandles",
".",
"Lookup",
"lookup",
",",
"Binder",
"start",
")",
"{",
"return",
"new",
"Binder",
"(",
"lookup",
",",
"start",
")",
";",
"}"
] | Construct a new Binder, starting from a given invokebinder.
@param lookup the Lookup context to use for direct handles
@param start the starting invokebinder; the new one will start with the current endpoint type
of the given invokebinder
@return the Binder object | [
"Construct",
"a",
"new",
"Binder",
"starting",
"from",
"a",
"given",
"invokebinder",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L264-L266 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.to | public Binder to(Binder other) {
assert type().equals(other.start);
Binder newBinder = new Binder(this);
for (ListIterator<Transform> iter = other.transforms.listIterator(other.transforms.size()); iter.hasPrevious(); ) {
Transform t = iter.previous();
newBinder.add(t);
}
return newBinder;
} | java | public Binder to(Binder other) {
assert type().equals(other.start);
Binder newBinder = new Binder(this);
for (ListIterator<Transform> iter = other.transforms.listIterator(other.transforms.size()); iter.hasPrevious(); ) {
Transform t = iter.previous();
newBinder.add(t);
}
return newBinder;
} | [
"public",
"Binder",
"to",
"(",
"Binder",
"other",
")",
"{",
"assert",
"type",
"(",
")",
".",
"equals",
"(",
"other",
".",
"start",
")",
";",
"Binder",
"newBinder",
"=",
"new",
"Binder",
"(",
"this",
")",
";",
"for",
"(",
"ListIterator",
"<",
"Transfo... | Join this binder to an existing one by applying its transformations after
this one.
@param other the Binder containing the set of transformations to append
@return a new Binder combining this Binder with the target Binder | [
"Join",
"this",
"binder",
"to",
"an",
"existing",
"one",
"by",
"applying",
"its",
"transformations",
"after",
"this",
"one",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L275-L286 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.add | private void add(Transform transform, MethodType target) {
types.add(0, target);
transforms.add(0, transform);
} | java | private void add(Transform transform, MethodType target) {
types.add(0, target);
transforms.add(0, transform);
} | [
"private",
"void",
"add",
"(",
"Transform",
"transform",
",",
"MethodType",
"target",
")",
"{",
"types",
".",
"add",
"(",
"0",
",",
"target",
")",
";",
"transforms",
".",
"add",
"(",
"0",
",",
"transform",
")",
";",
"}"
] | Add a Transform with an associated MethodType target to the chain.
@param transform
@param target | [
"Add",
"a",
"Transform",
"with",
"an",
"associated",
"MethodType",
"target",
"to",
"the",
"chain",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L314-L317 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.insert | public Binder insert(int index, Class<?> type, Object value) {
return new Binder(this, new Insert(index, new Class[]{type}, value));
} | java | public Binder insert(int index, Class<?> type, Object value) {
return new Binder(this, new Insert(index, new Class[]{type}, value));
} | [
"public",
"Binder",
"insert",
"(",
"int",
"index",
",",
"Class",
"<",
"?",
">",
"type",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Insert",
"(",
"index",
",",
"new",
"Class",
"[",
"]",
"{",
"type",
"}",
... | Insert at the given index the given argument value.
@param index the index at which to insert the argument value
@param type the actual type to use, rather than getClass
@param value the value to insert
@return a new Binder | [
"Insert",
"at",
"the",
"given",
"index",
"the",
"given",
"argument",
"value",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L465-L467 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.append | public Binder append(Class<?> type, Object value) {
return new Binder(this, new Insert(type().parameterCount(), new Class[]{type}, value));
} | java | public Binder append(Class<?> type, Object value) {
return new Binder(this, new Insert(type().parameterCount(), new Class[]{type}, value));
} | [
"public",
"Binder",
"append",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Insert",
"(",
"type",
"(",
")",
".",
"parameterCount",
"(",
")",
",",
"new",
"Class",
"[",
"]"... | Append to the argument list the given argument value with the specified type.
@param type the actual type to use, rather than getClass
@param value the value to append
@return a new Binder | [
"Append",
"to",
"the",
"argument",
"list",
"the",
"given",
"argument",
"value",
"with",
"the",
"specified",
"type",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L668-L670 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.append | public Binder append(Class<?>[] types, Object... values) {
return new Binder(this, new Insert(type().parameterCount(), types, values));
} | java | public Binder append(Class<?>[] types, Object... values) {
return new Binder(this, new Insert(type().parameterCount(), types, values));
} | [
"public",
"Binder",
"append",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
"types",
",",
"Object",
"...",
"values",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Insert",
"(",
"type",
"(",
")",
".",
"parameterCount",
"(",
")",
",",
"type... | Append to the argument list the given argument values with the specified types.
@param types the actual types to use, rather than getClass
@param values the value(s) to append
@return a new Binder | [
"Append",
"to",
"the",
"argument",
"list",
"the",
"given",
"argument",
"values",
"with",
"the",
"specified",
"types",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L679-L681 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.prepend | public Binder prepend(Class<?> type, Object value) {
return new Binder(this, new Insert(0, new Class[]{type}, value));
} | java | public Binder prepend(Class<?> type, Object value) {
return new Binder(this, new Insert(0, new Class[]{type}, value));
} | [
"public",
"Binder",
"prepend",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Insert",
"(",
"0",
",",
"new",
"Class",
"[",
"]",
"{",
"type",
"}",
",",
"value",
")",
")",... | Prepend to the argument list the given argument value with the specified type
@param type the actual type to use, rather than getClass
@param value the value(s) to prepend
@return a new Binder | [
"Prepend",
"to",
"the",
"argument",
"list",
"the",
"given",
"argument",
"value",
"with",
"the",
"specified",
"type"
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L690-L692 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.prepend | public Binder prepend(Class<?>[] types, Object... values) {
return new Binder(this, new Insert(0, types, values));
} | java | public Binder prepend(Class<?>[] types, Object... values) {
return new Binder(this, new Insert(0, types, values));
} | [
"public",
"Binder",
"prepend",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
"types",
",",
"Object",
"...",
"values",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Insert",
"(",
"0",
",",
"types",
",",
"values",
")",
")",
";",
"}"
] | Prepend to the argument list the given argument values with the specified types.
@param types the actual types to use, rather than getClass
@param values the value(s) to prepend
@return a new Binder | [
"Prepend",
"to",
"the",
"argument",
"list",
"the",
"given",
"argument",
"values",
"with",
"the",
"specified",
"types",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L701-L703 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.drop | public Binder drop(int index, int count) {
return new Binder(this, new Drop(index, Arrays.copyOfRange(type().parameterArray(), index, index + count)));
} | java | public Binder drop(int index, int count) {
return new Binder(this, new Drop(index, Arrays.copyOfRange(type().parameterArray(), index, index + count)));
} | [
"public",
"Binder",
"drop",
"(",
"int",
"index",
",",
"int",
"count",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Drop",
"(",
"index",
",",
"Arrays",
".",
"copyOfRange",
"(",
"type",
"(",
")",
".",
"parameterArray",
"(",
")",
",",
... | Drop from the given index a number of arguments.
@param index the index at which to start dropping
@param count the number of arguments to drop
@return a new Binder | [
"Drop",
"from",
"the",
"given",
"index",
"a",
"number",
"of",
"arguments",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L722-L724 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.dropLast | public Binder dropLast(int count) {
assert count <= type().parameterCount();
return drop(type().parameterCount() - count, count);
} | java | public Binder dropLast(int count) {
assert count <= type().parameterCount();
return drop(type().parameterCount() - count, count);
} | [
"public",
"Binder",
"dropLast",
"(",
"int",
"count",
")",
"{",
"assert",
"count",
"<=",
"type",
"(",
")",
".",
"parameterCount",
"(",
")",
";",
"return",
"drop",
"(",
"type",
"(",
")",
".",
"parameterCount",
"(",
")",
"-",
"count",
",",
"count",
")",... | Drop from the end of the argument list a number of arguments.
@param count the number of arguments to drop
@return a new Binder | [
"Drop",
"from",
"the",
"end",
"of",
"the",
"argument",
"list",
"a",
"number",
"of",
"arguments",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L741-L745 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.spread | public Binder spread(Class<?>... spreadTypes) {
if (spreadTypes.length == 0) {
return dropLast();
}
return new Binder(this, new Spread(type(), spreadTypes));
} | java | public Binder spread(Class<?>... spreadTypes) {
if (spreadTypes.length == 0) {
return dropLast();
}
return new Binder(this, new Spread(type(), spreadTypes));
} | [
"public",
"Binder",
"spread",
"(",
"Class",
"<",
"?",
">",
"...",
"spreadTypes",
")",
"{",
"if",
"(",
"spreadTypes",
".",
"length",
"==",
"0",
")",
"{",
"return",
"dropLast",
"(",
")",
";",
"}",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"... | Spread a trailing array argument into the specified argument types.
@param spreadTypes the types into which to spread the incoming Object[]
@return a new Binder | [
"Spread",
"a",
"trailing",
"array",
"argument",
"into",
"the",
"specified",
"argument",
"types",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L842-L848 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.spread | public Binder spread(int count) {
if (count == 0) {
return dropLast();
}
Class<?> aryType = type().parameterType(type().parameterCount() - 1);
assert aryType.isArray();
Class<?>[] spreadTypes = new Class[count];
Arrays.fill(spreadTypes, aryType.getComponentType());
return spread(spreadTypes);
} | java | public Binder spread(int count) {
if (count == 0) {
return dropLast();
}
Class<?> aryType = type().parameterType(type().parameterCount() - 1);
assert aryType.isArray();
Class<?>[] spreadTypes = new Class[count];
Arrays.fill(spreadTypes, aryType.getComponentType());
return spread(spreadTypes);
} | [
"public",
"Binder",
"spread",
"(",
"int",
"count",
")",
"{",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"return",
"dropLast",
"(",
")",
";",
"}",
"Class",
"<",
"?",
">",
"aryType",
"=",
"type",
"(",
")",
".",
"parameterType",
"(",
"type",
"(",
")",... | Spread a trailing array argument into the given number of arguments of
the type of the array.
@param count the new count of arguments to spread from the trailing array
@return a new Binder | [
"Spread",
"a",
"trailing",
"array",
"argument",
"into",
"the",
"given",
"number",
"of",
"arguments",
"of",
"the",
"type",
"of",
"the",
"array",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L857-L870 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.collect | public Binder collect(int index, Class<?> type) {
return new Binder(this, new Collect(type(), index, type));
} | java | public Binder collect(int index, Class<?> type) {
return new Binder(this, new Collect(type(), index, type));
} | [
"public",
"Binder",
"collect",
"(",
"int",
"index",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Collect",
"(",
"type",
"(",
")",
",",
"index",
",",
"type",
")",
")",
";",
"}"
] | Box all incoming arguments from the given position onward into the given array type.
@param index the index from which to start boxing args
@param type the array type into which the args will be boxed
@return a new Binder | [
"Box",
"all",
"incoming",
"arguments",
"from",
"the",
"given",
"position",
"onward",
"into",
"the",
"given",
"array",
"type",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L879-L881 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.varargs | public Binder varargs(int index, Class<?> type) {
return new Binder(this, new Varargs(type(), index, type));
} | java | public Binder varargs(int index, Class<?> type) {
return new Binder(this, new Varargs(type(), index, type));
} | [
"public",
"Binder",
"varargs",
"(",
"int",
"index",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Varargs",
"(",
"type",
"(",
")",
",",
"index",
",",
"type",
")",
")",
";",
"}"
] | Box all incoming arguments from the given position onward into the given array type.
This version accepts a variable number of incoming arguments.
@param index the index from which to start boxing args
@param type the array type into which the args will be boxed
@return a new Binder | [
"Box",
"all",
"incoming",
"arguments",
"from",
"the",
"given",
"position",
"onward",
"into",
"the",
"given",
"array",
"type",
".",
"This",
"version",
"accepts",
"a",
"variable",
"number",
"of",
"incoming",
"arguments",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L903-L905 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.foldVoid | public Binder foldVoid(MethodHandle function) {
if (type().returnType() == void.class) {
return fold(function);
} else {
return fold(function.asType(function.type().changeReturnType(void.class)));
}
} | java | public Binder foldVoid(MethodHandle function) {
if (type().returnType() == void.class) {
return fold(function);
} else {
return fold(function.asType(function.type().changeReturnType(void.class)));
}
} | [
"public",
"Binder",
"foldVoid",
"(",
"MethodHandle",
"function",
")",
"{",
"if",
"(",
"type",
"(",
")",
".",
"returnType",
"(",
")",
"==",
"void",
".",
"class",
")",
"{",
"return",
"fold",
"(",
"function",
")",
";",
"}",
"else",
"{",
"return",
"fold"... | Process the incoming arguments using the given handle, leaving the argument list
unmodified.
@param function the function that will process the incoming arguments. Its
signature must match the current signature's arguments exactly.
@return a new Binder | [
"Process",
"the",
"incoming",
"arguments",
"using",
"the",
"given",
"handle",
"leaving",
"the",
"argument",
"list",
"unmodified",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L939-L945 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.foldVirtual | public Binder foldVirtual(MethodHandles.Lookup lookup, String method) {
return fold(Binder.from(type()).invokeVirtualQuiet(lookup, method));
} | java | public Binder foldVirtual(MethodHandles.Lookup lookup, String method) {
return fold(Binder.from(type()).invokeVirtualQuiet(lookup, method));
} | [
"public",
"Binder",
"foldVirtual",
"(",
"MethodHandles",
".",
"Lookup",
"lookup",
",",
"String",
"method",
")",
"{",
"return",
"fold",
"(",
"Binder",
".",
"from",
"(",
"type",
"(",
")",
")",
".",
"invokeVirtualQuiet",
"(",
"lookup",
",",
"method",
")",
"... | Process the incoming arguments by calling the given method on the first
argument, inserting the result as the first argument.
@param lookup the java.lang.invoke.MethodHandles.Lookup to use
@param method the method to invoke on the first argument
@return a new Binder | [
"Process",
"the",
"incoming",
"arguments",
"by",
"calling",
"the",
"given",
"method",
"on",
"the",
"first",
"argument",
"inserting",
"the",
"result",
"as",
"the",
"first",
"argument",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L980-L982 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.filterForward | public Binder filterForward(int index, MethodHandle... functions) {
Binder filtered = this;
for (int i = 0; i < functions.length; i++) {
filtered = filtered.filter(index + i, functions[i]);
}
return filtered;
} | java | public Binder filterForward(int index, MethodHandle... functions) {
Binder filtered = this;
for (int i = 0; i < functions.length; i++) {
filtered = filtered.filter(index + i, functions[i]);
}
return filtered;
} | [
"public",
"Binder",
"filterForward",
"(",
"int",
"index",
",",
"MethodHandle",
"...",
"functions",
")",
"{",
"Binder",
"filtered",
"=",
"this",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"functions",
".",
"length",
";",
"i",
"++",
")",
"{"... | Filter incoming arguments, from the given index, replacing each with the
result of calling the associated function in the given list. This version
guarantees left-to-right evaluation of filter functions, potentially at
the cost of a more complex handle tree.
@param index the index of the first argument to filter
@param functions the array of functions to transform the arguments
@return a new Binder | [
"Filter",
"incoming",
"arguments",
"from",
"the",
"given",
"index",
"replacing",
"each",
"with",
"the",
"result",
"of",
"calling",
"the",
"associated",
"function",
"in",
"the",
"given",
"list",
".",
"This",
"version",
"guarantees",
"left",
"-",
"to",
"-",
"r... | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1021-L1029 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.catchException | public Binder catchException(Class<? extends Throwable> throwable, MethodHandle function) {
return new Binder(this, new Catch(throwable, function));
} | java | public Binder catchException(Class<? extends Throwable> throwable, MethodHandle function) {
return new Binder(this, new Catch(throwable, function));
} | [
"public",
"Binder",
"catchException",
"(",
"Class",
"<",
"?",
"extends",
"Throwable",
">",
"throwable",
",",
"MethodHandle",
"function",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Catch",
"(",
"throwable",
",",
"function",
")",
")",
";"... | Catch the given exception type from the downstream chain and handle it with the
given function.
@param throwable the exception type to catch
@param function the function to use for handling the exception
@return a new Binder | [
"Catch",
"the",
"given",
"exception",
"type",
"from",
"the",
"downstream",
"chain",
"and",
"handle",
"it",
"with",
"the",
"given",
"function",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1073-L1075 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.nop | public MethodHandle nop() {
if (type().returnType() != void.class) {
throw new InvalidTransformException("must have void return type to nop: " + type());
}
return invoke(Binder
.from(type())
.drop(0, type().parameterCount())
.cast(Object.class)
.constant(null));
} | java | public MethodHandle nop() {
if (type().returnType() != void.class) {
throw new InvalidTransformException("must have void return type to nop: " + type());
}
return invoke(Binder
.from(type())
.drop(0, type().parameterCount())
.cast(Object.class)
.constant(null));
} | [
"public",
"MethodHandle",
"nop",
"(",
")",
"{",
"if",
"(",
"type",
"(",
")",
".",
"returnType",
"(",
")",
"!=",
"void",
".",
"class",
")",
"{",
"throw",
"new",
"InvalidTransformException",
"(",
"\"must have void return type to nop: \"",
"+",
"type",
"(",
")"... | Apply all transforms to an endpoint that does absolutely nothing. Useful for
creating exception handlers in void methods that simply ignore the exception.
@return a handle that has all transforms applied and does nothing at its endpoint | [
"Apply",
"all",
"transforms",
"to",
"an",
"endpoint",
"that",
"does",
"absolutely",
"nothing",
".",
"Useful",
"for",
"creating",
"exception",
"handlers",
"in",
"void",
"methods",
"that",
"simply",
"ignore",
"the",
"exception",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1083-L1092 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.throwException | public MethodHandle throwException() {
if (type().parameterCount() != 1 || !Throwable.class.isAssignableFrom(type().parameterType(0))) {
throw new InvalidTransformException("incoming signature must have one Throwable type as its sole argument: " + type());
}
return invoke(MethodHandles.throwException(type().returnType(), type().parameterType(0).asSubclass(Throwable.class)));
} | java | public MethodHandle throwException() {
if (type().parameterCount() != 1 || !Throwable.class.isAssignableFrom(type().parameterType(0))) {
throw new InvalidTransformException("incoming signature must have one Throwable type as its sole argument: " + type());
}
return invoke(MethodHandles.throwException(type().returnType(), type().parameterType(0).asSubclass(Throwable.class)));
} | [
"public",
"MethodHandle",
"throwException",
"(",
")",
"{",
"if",
"(",
"type",
"(",
")",
".",
"parameterCount",
"(",
")",
"!=",
"1",
"||",
"!",
"Throwable",
".",
"class",
".",
"isAssignableFrom",
"(",
"type",
"(",
")",
".",
"parameterType",
"(",
"0",
")... | Throw the current signature's sole Throwable argument. Return type
does not matter, since it will never return.
@return a handle that has all transforms applied and which will eventually throw an exception | [
"Throw",
"the",
"current",
"signature",
"s",
"sole",
"Throwable",
"argument",
".",
"Return",
"type",
"does",
"not",
"matter",
"since",
"it",
"will",
"never",
"return",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1100-L1105 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.constant | public MethodHandle constant(Object value) {
return invoke(MethodHandles.constant(type().returnType(), value));
} | java | public MethodHandle constant(Object value) {
return invoke(MethodHandles.constant(type().returnType(), value));
} | [
"public",
"MethodHandle",
"constant",
"(",
"Object",
"value",
")",
"{",
"return",
"invoke",
"(",
"MethodHandles",
".",
"constant",
"(",
"type",
"(",
")",
".",
"returnType",
"(",
")",
",",
"value",
")",
")",
";",
"}"
] | Apply the tranforms, binding them to a constant value that will
propagate back through the chain. The chain's expected return type
at that point must be compatible with the given value's type.
@param value the constant value to put at the end of the chain
@return a handle that has all transforms applied in sequence up to the constant | [
"Apply",
"the",
"tranforms",
"binding",
"them",
"to",
"a",
"constant",
"value",
"that",
"will",
"propagate",
"back",
"through",
"the",
"chain",
".",
"The",
"chain",
"s",
"expected",
"return",
"type",
"at",
"that",
"point",
"must",
"be",
"compatible",
"with",... | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1115-L1117 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.invoke | public MethodHandle invoke(MethodHandle target) {
MethodHandle current = target;
for (Transform t : transforms) {
current = t.up(current);
}
// if resulting handle's type does not match start, attempt one more cast
current = MethodHandles.explicitCastArguments(current, start);
return current;
} | java | public MethodHandle invoke(MethodHandle target) {
MethodHandle current = target;
for (Transform t : transforms) {
current = t.up(current);
}
// if resulting handle's type does not match start, attempt one more cast
current = MethodHandles.explicitCastArguments(current, start);
return current;
} | [
"public",
"MethodHandle",
"invoke",
"(",
"MethodHandle",
"target",
")",
"{",
"MethodHandle",
"current",
"=",
"target",
";",
"for",
"(",
"Transform",
"t",
":",
"transforms",
")",
"{",
"current",
"=",
"t",
".",
"up",
"(",
"current",
")",
";",
"}",
"// if r... | Apply the chain of transforms with the target method handle as the final
endpoint. Produces a handle that has the transforms in given sequence.
If the final handle's type does not exactly match the initial type for
this Binder, an additional cast will be attempted.
@param target the endpoint handle to bind to
@return a handle that has all transforms applied in sequence up to endpoint | [
"Apply",
"the",
"chain",
"of",
"transforms",
"with",
"the",
"target",
"method",
"handle",
"as",
"the",
"final",
"endpoint",
".",
"Produces",
"a",
"handle",
"that",
"has",
"the",
"transforms",
"in",
"given",
"sequence",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1140-L1150 | train |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.arrayAccess | public MethodHandle arrayAccess(VarHandle.AccessMode mode) {
return invoke(MethodHandles.arrayElementVarHandle(type().parameterType(0)).toMethodHandle(mode));
} | java | public MethodHandle arrayAccess(VarHandle.AccessMode mode) {
return invoke(MethodHandles.arrayElementVarHandle(type().parameterType(0)).toMethodHandle(mode));
} | [
"public",
"MethodHandle",
"arrayAccess",
"(",
"VarHandle",
".",
"AccessMode",
"mode",
")",
"{",
"return",
"invoke",
"(",
"MethodHandles",
".",
"arrayElementVarHandle",
"(",
"type",
"(",
")",
".",
"parameterType",
"(",
"0",
")",
")",
".",
"toMethodHandle",
"(",... | Apply the chain of transforms and bind them to an array varhandle operation. The
signature at the endpoint must match the VarHandle access type passed in. | [
"Apply",
"the",
"chain",
"of",
"transforms",
"and",
"bind",
"them",
"to",
"an",
"array",
"varhandle",
"operation",
".",
"The",
"signature",
"at",
"the",
"endpoint",
"must",
"match",
"the",
"VarHandle",
"access",
"type",
"passed",
"in",
"."
] | ce6bfeb8e33265480daa7b797989dd915d51238d | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1636-L1638 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.