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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/FacebookFragment.java | FacebookFragment.openSessionForRead | protected final void openSessionForRead(String applicationId, List<String> permissions,
SessionLoginBehavior behavior, int activityCode) {
openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.READ);
} | java | protected final void openSessionForRead(String applicationId, List<String> permissions,
SessionLoginBehavior behavior, int activityCode) {
openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.READ);
} | [
"protected",
"final",
"void",
"openSessionForRead",
"(",
"String",
"applicationId",
",",
"List",
"<",
"String",
">",
"permissions",
",",
"SessionLoginBehavior",
"behavior",
",",
"int",
"activityCode",
")",
"{",
"openSession",
"(",
"applicationId",
",",
"permissions",
",",
"behavior",
",",
"activityCode",
",",
"SessionAuthorizationType",
".",
"READ",
")",
";",
"}"
] | Opens a new session with read permissions. If either applicationID or permissions
is null, this method will default to using the values from the associated
meta-data value and an empty list respectively.
@param applicationId the applicationID, can be null
@param permissions the permissions list, can be null
@param behavior the login behavior to use with the session
@param activityCode the activity code to use for the SSO activity | [
"Opens",
"a",
"new",
"session",
"with",
"read",
"permissions",
".",
"If",
"either",
"applicationID",
"or",
"permissions",
"is",
"null",
"this",
"method",
"will",
"default",
"to",
"using",
"the",
"values",
"from",
"the",
"associated",
"meta",
"-",
"data",
"value",
"and",
"an",
"empty",
"list",
"respectively",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/FacebookFragment.java#L228-L231 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppLinkData.java | AppLinkData.fetchDeferredAppLinkData | public static void fetchDeferredAppLinkData(
Context context,
String applicationId,
final CompletionHandler completionHandler) {
Validate.notNull(context, "context");
Validate.notNull(completionHandler, "completionHandler");
if (applicationId == null) {
applicationId = Utility.getMetadataApplicationId(context);
}
Validate.notNull(applicationId, "applicationId");
final Context applicationContext = context.getApplicationContext();
final String applicationIdCopy = applicationId;
Settings.getExecutor().execute(new Runnable() {
@Override
public void run() {
fetchDeferredAppLinkFromServer(applicationContext, applicationIdCopy, completionHandler);
}
});
} | java | public static void fetchDeferredAppLinkData(
Context context,
String applicationId,
final CompletionHandler completionHandler) {
Validate.notNull(context, "context");
Validate.notNull(completionHandler, "completionHandler");
if (applicationId == null) {
applicationId = Utility.getMetadataApplicationId(context);
}
Validate.notNull(applicationId, "applicationId");
final Context applicationContext = context.getApplicationContext();
final String applicationIdCopy = applicationId;
Settings.getExecutor().execute(new Runnable() {
@Override
public void run() {
fetchDeferredAppLinkFromServer(applicationContext, applicationIdCopy, completionHandler);
}
});
} | [
"public",
"static",
"void",
"fetchDeferredAppLinkData",
"(",
"Context",
"context",
",",
"String",
"applicationId",
",",
"final",
"CompletionHandler",
"completionHandler",
")",
"{",
"Validate",
".",
"notNull",
"(",
"context",
",",
"\"context\"",
")",
";",
"Validate",
".",
"notNull",
"(",
"completionHandler",
",",
"\"completionHandler\"",
")",
";",
"if",
"(",
"applicationId",
"==",
"null",
")",
"{",
"applicationId",
"=",
"Utility",
".",
"getMetadataApplicationId",
"(",
"context",
")",
";",
"}",
"Validate",
".",
"notNull",
"(",
"applicationId",
",",
"\"applicationId\"",
")",
";",
"final",
"Context",
"applicationContext",
"=",
"context",
".",
"getApplicationContext",
"(",
")",
";",
"final",
"String",
"applicationIdCopy",
"=",
"applicationId",
";",
"Settings",
".",
"getExecutor",
"(",
")",
".",
"execute",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"fetchDeferredAppLinkFromServer",
"(",
"applicationContext",
",",
"applicationIdCopy",
",",
"completionHandler",
")",
";",
"}",
"}",
")",
";",
"}"
] | Asynchronously fetches app link information that might have been stored for use
after installation of the app
@param context The context
@param applicationId Facebook application Id. If null, it is taken from the manifest
@param completionHandler CompletionHandler to be notified with the AppLinkData object or null if none is
available. Must not be null. | [
"Asynchronously",
"fetches",
"app",
"link",
"information",
"that",
"might",
"have",
"been",
"stored",
"for",
"use",
"after",
"installation",
"of",
"the",
"app"
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppLinkData.java#L103-L124 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppLinkData.java | AppLinkData.createFromActivity | public static AppLinkData createFromActivity(Activity activity) {
Validate.notNull(activity, "activity");
Intent intent = activity.getIntent();
if (intent == null) {
return null;
}
AppLinkData appLinkData = createFromAlApplinkData(intent);
if (appLinkData == null) {
String appLinkArgsJsonString = intent.getStringExtra(BUNDLE_APPLINK_ARGS_KEY);
appLinkData = createFromJson(appLinkArgsJsonString);
}
if (appLinkData == null) {
// Try regular app linking
appLinkData = createFromUri(intent.getData());
}
return appLinkData;
} | java | public static AppLinkData createFromActivity(Activity activity) {
Validate.notNull(activity, "activity");
Intent intent = activity.getIntent();
if (intent == null) {
return null;
}
AppLinkData appLinkData = createFromAlApplinkData(intent);
if (appLinkData == null) {
String appLinkArgsJsonString = intent.getStringExtra(BUNDLE_APPLINK_ARGS_KEY);
appLinkData = createFromJson(appLinkArgsJsonString);
}
if (appLinkData == null) {
// Try regular app linking
appLinkData = createFromUri(intent.getData());
}
return appLinkData;
} | [
"public",
"static",
"AppLinkData",
"createFromActivity",
"(",
"Activity",
"activity",
")",
"{",
"Validate",
".",
"notNull",
"(",
"activity",
",",
"\"activity\"",
")",
";",
"Intent",
"intent",
"=",
"activity",
".",
"getIntent",
"(",
")",
";",
"if",
"(",
"intent",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"AppLinkData",
"appLinkData",
"=",
"createFromAlApplinkData",
"(",
"intent",
")",
";",
"if",
"(",
"appLinkData",
"==",
"null",
")",
"{",
"String",
"appLinkArgsJsonString",
"=",
"intent",
".",
"getStringExtra",
"(",
"BUNDLE_APPLINK_ARGS_KEY",
")",
";",
"appLinkData",
"=",
"createFromJson",
"(",
"appLinkArgsJsonString",
")",
";",
"}",
"if",
"(",
"appLinkData",
"==",
"null",
")",
"{",
"// Try regular app linking",
"appLinkData",
"=",
"createFromUri",
"(",
"intent",
".",
"getData",
"(",
")",
")",
";",
"}",
"return",
"appLinkData",
";",
"}"
] | Parses out any app link data from the Intent of the Activity passed in.
@param activity Activity that was started because of an app link
@return AppLinkData if found. null if not. | [
"Parses",
"out",
"any",
"app",
"link",
"data",
"from",
"the",
"Intent",
"of",
"the",
"Activity",
"passed",
"in",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppLinkData.java#L209-L227 | train |
tommyettinger/RegExodus | src/main/java/regexodus/Matcher.java | Matcher.setPattern | public void setPattern(Pattern regex)
{
this.re = regex;
int memregCount, counterCount, lookaheadCount;
if ((memregCount = regex.memregs) > 0) {
MemReg[] memregs = new MemReg[memregCount];
for (int i = 0; i < memregCount; i++) {
memregs[i] = new MemReg(-1); //unlikely to SearchEntry, in this case we know memreg indices by definition
}
this.memregs = memregs;
}
if ((counterCount = regex.counters) > 0) counters = new int[counterCount];
if ((lookaheadCount = regex.lookaheads) > 0) {
LAEntry[] lookaheads = new LAEntry[lookaheadCount];
for (int i = 0; i < lookaheadCount; i++) {
lookaheads[i] = new LAEntry();
}
this.lookaheads = lookaheads;
}
this.memregCount = memregCount;
this.counterCount = counterCount;
this.lookaheadCount = lookaheadCount;
first = new SearchEntry();
defaultEntry = new SearchEntry();
minQueueLength = regex.stringRepr.length() / 2; // just evaluation!!!
} | java | public void setPattern(Pattern regex)
{
this.re = regex;
int memregCount, counterCount, lookaheadCount;
if ((memregCount = regex.memregs) > 0) {
MemReg[] memregs = new MemReg[memregCount];
for (int i = 0; i < memregCount; i++) {
memregs[i] = new MemReg(-1); //unlikely to SearchEntry, in this case we know memreg indices by definition
}
this.memregs = memregs;
}
if ((counterCount = regex.counters) > 0) counters = new int[counterCount];
if ((lookaheadCount = regex.lookaheads) > 0) {
LAEntry[] lookaheads = new LAEntry[lookaheadCount];
for (int i = 0; i < lookaheadCount; i++) {
lookaheads[i] = new LAEntry();
}
this.lookaheads = lookaheads;
}
this.memregCount = memregCount;
this.counterCount = counterCount;
this.lookaheadCount = lookaheadCount;
first = new SearchEntry();
defaultEntry = new SearchEntry();
minQueueLength = regex.stringRepr.length() / 2; // just evaluation!!!
} | [
"public",
"void",
"setPattern",
"(",
"Pattern",
"regex",
")",
"{",
"this",
".",
"re",
"=",
"regex",
";",
"int",
"memregCount",
",",
"counterCount",
",",
"lookaheadCount",
";",
"if",
"(",
"(",
"memregCount",
"=",
"regex",
".",
"memregs",
")",
">",
"0",
")",
"{",
"MemReg",
"[",
"]",
"memregs",
"=",
"new",
"MemReg",
"[",
"memregCount",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"memregCount",
";",
"i",
"++",
")",
"{",
"memregs",
"[",
"i",
"]",
"=",
"new",
"MemReg",
"(",
"-",
"1",
")",
";",
"//unlikely to SearchEntry, in this case we know memreg indices by definition",
"}",
"this",
".",
"memregs",
"=",
"memregs",
";",
"}",
"if",
"(",
"(",
"counterCount",
"=",
"regex",
".",
"counters",
")",
">",
"0",
")",
"counters",
"=",
"new",
"int",
"[",
"counterCount",
"]",
";",
"if",
"(",
"(",
"lookaheadCount",
"=",
"regex",
".",
"lookaheads",
")",
">",
"0",
")",
"{",
"LAEntry",
"[",
"]",
"lookaheads",
"=",
"new",
"LAEntry",
"[",
"lookaheadCount",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lookaheadCount",
";",
"i",
"++",
")",
"{",
"lookaheads",
"[",
"i",
"]",
"=",
"new",
"LAEntry",
"(",
")",
";",
"}",
"this",
".",
"lookaheads",
"=",
"lookaheads",
";",
"}",
"this",
".",
"memregCount",
"=",
"memregCount",
";",
"this",
".",
"counterCount",
"=",
"counterCount",
";",
"this",
".",
"lookaheadCount",
"=",
"lookaheadCount",
";",
"first",
"=",
"new",
"SearchEntry",
"(",
")",
";",
"defaultEntry",
"=",
"new",
"SearchEntry",
"(",
")",
";",
"minQueueLength",
"=",
"regex",
".",
"stringRepr",
".",
"length",
"(",
")",
"/",
"2",
";",
"// just evaluation!!!",
"}"
] | Sets the regex Pattern this tries to match. Won't do anything until the target is set as well.
@param regex the Pattern this should match | [
"Sets",
"the",
"regex",
"Pattern",
"this",
"tries",
"to",
"match",
".",
"Won",
"t",
"do",
"anything",
"until",
"the",
"target",
"is",
"set",
"as",
"well",
"."
] | d4af9bb7c132c5f9d29f45b76121f93b2f89de16 | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/Matcher.java#L166-L197 | train |
tommyettinger/RegExodus | src/main/java/regexodus/Matcher.java | Matcher.skip | public void skip() {
int we = wEnd;
if (wOffset == we) { //requires special handling
//if no variants at 'wOutside',advance pointer and clear
if (top == null) {
wOffset++;
flush();
}
//otherwise, if there exist a variant,
//don't clear(), i.e. allow it to match
return;
} else {
if (we < 0) wOffset = 0;
else wOffset = we;
}
//rflush(); //rflush() works faster on simple regexes (with a small group/branch number)
flush();
} | java | public void skip() {
int we = wEnd;
if (wOffset == we) { //requires special handling
//if no variants at 'wOutside',advance pointer and clear
if (top == null) {
wOffset++;
flush();
}
//otherwise, if there exist a variant,
//don't clear(), i.e. allow it to match
return;
} else {
if (we < 0) wOffset = 0;
else wOffset = we;
}
//rflush(); //rflush() works faster on simple regexes (with a small group/branch number)
flush();
} | [
"public",
"void",
"skip",
"(",
")",
"{",
"int",
"we",
"=",
"wEnd",
";",
"if",
"(",
"wOffset",
"==",
"we",
")",
"{",
"//requires special handling",
"//if no variants at 'wOutside',advance pointer and clear",
"if",
"(",
"top",
"==",
"null",
")",
"{",
"wOffset",
"++",
";",
"flush",
"(",
")",
";",
"}",
"//otherwise, if there exist a variant,",
"//don't clear(), i.e. allow it to match",
"return",
";",
"}",
"else",
"{",
"if",
"(",
"we",
"<",
"0",
")",
"wOffset",
"=",
"0",
";",
"else",
"wOffset",
"=",
"we",
";",
"}",
"//rflush(); //rflush() works faster on simple regexes (with a small group/branch number)",
"flush",
"(",
")",
";",
"}"
] | Sets the current search position just after the end of last match. | [
"Sets",
"the",
"current",
"search",
"position",
"just",
"after",
"the",
"end",
"of",
"last",
"match",
"."
] | d4af9bb7c132c5f9d29f45b76121f93b2f89de16 | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/Matcher.java#L638-L655 | train |
tommyettinger/RegExodus | src/main/java/regexodus/Matcher.java | Matcher.flush | public void flush() {
top = null;
defaultEntry.reset(0);
first.reset(minQueueLength);
for (int i = memregs.length - 1; i > 0; i--) {
MemReg mr = memregs[i];
mr.in = mr.out = -1;
}
/*
for (int i = memregs.length - 1; i > 0; i--) {
MemReg mr = memregs[i];
mr.in = mr.out = -1;
}*/
called = false;
} | java | public void flush() {
top = null;
defaultEntry.reset(0);
first.reset(minQueueLength);
for (int i = memregs.length - 1; i > 0; i--) {
MemReg mr = memregs[i];
mr.in = mr.out = -1;
}
/*
for (int i = memregs.length - 1; i > 0; i--) {
MemReg mr = memregs[i];
mr.in = mr.out = -1;
}*/
called = false;
} | [
"public",
"void",
"flush",
"(",
")",
"{",
"top",
"=",
"null",
";",
"defaultEntry",
".",
"reset",
"(",
"0",
")",
";",
"first",
".",
"reset",
"(",
"minQueueLength",
")",
";",
"for",
"(",
"int",
"i",
"=",
"memregs",
".",
"length",
"-",
"1",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"MemReg",
"mr",
"=",
"memregs",
"[",
"i",
"]",
";",
"mr",
".",
"in",
"=",
"mr",
".",
"out",
"=",
"-",
"1",
";",
"}",
"/*\n for (int i = memregs.length - 1; i > 0; i--) {\n MemReg mr = memregs[i];\n mr.in = mr.out = -1;\n }*/",
"called",
"=",
"false",
";",
"}"
] | Resets the internal state. | [
"Resets",
"the",
"internal",
"state",
"."
] | d4af9bb7c132c5f9d29f45b76121f93b2f89de16 | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/Matcher.java#L668-L683 | train |
tommyettinger/RegExodus | src/main/java/regexodus/Matcher.java | Matcher.start | @Override
public int start(String name) {
Integer id = re.groupId(name);
if (id == null) throw new IllegalArgumentException("<" + name + "> isn't defined");
return start(id);
} | java | @Override
public int start(String name) {
Integer id = re.groupId(name);
if (id == null) throw new IllegalArgumentException("<" + name + "> isn't defined");
return start(id);
} | [
"@",
"Override",
"public",
"int",
"start",
"(",
"String",
"name",
")",
"{",
"Integer",
"id",
"=",
"re",
".",
"groupId",
"(",
"name",
")",
";",
"if",
"(",
"id",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"<\"",
"+",
"name",
"+",
"\"> isn't defined\"",
")",
";",
"return",
"start",
"(",
"id",
")",
";",
"}"
] | Returns the start index of the subsequence captured by the given
named-capturing group during the previous match operation.
@param name The name of a named capturing group in this matcher's pattern
@return The index of the first character captured by the group,
or <tt>-1</tt> if the match was successful but the group
itself did not match anything | [
"Returns",
"the",
"start",
"index",
"of",
"the",
"subsequence",
"captured",
"by",
"the",
"given",
"named",
"-",
"capturing",
"group",
"during",
"the",
"previous",
"match",
"operation",
"."
] | d4af9bb7c132c5f9d29f45b76121f93b2f89de16 | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/Matcher.java#L1112-L1117 | train |
tommyettinger/RegExodus | src/main/java/regexodus/Matcher.java | Matcher.repeat | private static int repeat(char[] data, int off, int out, Term term) {
switch (term.type) {
case Term.CHAR: {
char c = term.c;
int i = off;
while (i < out) {
if (data[i] != c) break;
i++;
}
return i - off;
}
case Term.ANY_CHAR: {
return out - off;
}
case Term.ANY_CHAR_NE: {
int i = off;
char c;
while (i < out) {
if ((c = data[i]) == '\r' || c == '\n') break;
i++;
}
return i - off;
}
case Term.BITSET: {
IntBitSet arr = term.bitset;
int i = off;
char c;
if (term.inverse) while (i < out) {
if ((c = data[i]) <= 255 && arr.get(c)) break;
else i++;
}
else while (i < out) {
if ((c = data[i]) <= 255 && arr.get(c)) i++;
else break;
}
return i - off;
}
case Term.BITSET2: {
int i = off;
IntBitSet[] bitset2 = term.bitset2;
char c;
if (term.inverse) while (i < out) {
IntBitSet arr = bitset2[(c = data[i]) >> 8];
if (arr != null && arr.get(c & 0xff)) break;
else i++;
}
else while (i < out) {
IntBitSet arr = bitset2[(c = data[i]) >> 8];
if (arr != null && arr.get(c & 0xff)) i++;
else break;
}
return i - off;
}
}
throw new Error("this kind of term can't be quantified:" + term.type);
} | java | private static int repeat(char[] data, int off, int out, Term term) {
switch (term.type) {
case Term.CHAR: {
char c = term.c;
int i = off;
while (i < out) {
if (data[i] != c) break;
i++;
}
return i - off;
}
case Term.ANY_CHAR: {
return out - off;
}
case Term.ANY_CHAR_NE: {
int i = off;
char c;
while (i < out) {
if ((c = data[i]) == '\r' || c == '\n') break;
i++;
}
return i - off;
}
case Term.BITSET: {
IntBitSet arr = term.bitset;
int i = off;
char c;
if (term.inverse) while (i < out) {
if ((c = data[i]) <= 255 && arr.get(c)) break;
else i++;
}
else while (i < out) {
if ((c = data[i]) <= 255 && arr.get(c)) i++;
else break;
}
return i - off;
}
case Term.BITSET2: {
int i = off;
IntBitSet[] bitset2 = term.bitset2;
char c;
if (term.inverse) while (i < out) {
IntBitSet arr = bitset2[(c = data[i]) >> 8];
if (arr != null && arr.get(c & 0xff)) break;
else i++;
}
else while (i < out) {
IntBitSet arr = bitset2[(c = data[i]) >> 8];
if (arr != null && arr.get(c & 0xff)) i++;
else break;
}
return i - off;
}
}
throw new Error("this kind of term can't be quantified:" + term.type);
} | [
"private",
"static",
"int",
"repeat",
"(",
"char",
"[",
"]",
"data",
",",
"int",
"off",
",",
"int",
"out",
",",
"Term",
"term",
")",
"{",
"switch",
"(",
"term",
".",
"type",
")",
"{",
"case",
"Term",
".",
"CHAR",
":",
"{",
"char",
"c",
"=",
"term",
".",
"c",
";",
"int",
"i",
"=",
"off",
";",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"if",
"(",
"data",
"[",
"i",
"]",
"!=",
"c",
")",
"break",
";",
"i",
"++",
";",
"}",
"return",
"i",
"-",
"off",
";",
"}",
"case",
"Term",
".",
"ANY_CHAR",
":",
"{",
"return",
"out",
"-",
"off",
";",
"}",
"case",
"Term",
".",
"ANY_CHAR_NE",
":",
"{",
"int",
"i",
"=",
"off",
";",
"char",
"c",
";",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"if",
"(",
"(",
"c",
"=",
"data",
"[",
"i",
"]",
")",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"break",
";",
"i",
"++",
";",
"}",
"return",
"i",
"-",
"off",
";",
"}",
"case",
"Term",
".",
"BITSET",
":",
"{",
"IntBitSet",
"arr",
"=",
"term",
".",
"bitset",
";",
"int",
"i",
"=",
"off",
";",
"char",
"c",
";",
"if",
"(",
"term",
".",
"inverse",
")",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"if",
"(",
"(",
"c",
"=",
"data",
"[",
"i",
"]",
")",
"<=",
"255",
"&&",
"arr",
".",
"get",
"(",
"c",
")",
")",
"break",
";",
"else",
"i",
"++",
";",
"}",
"else",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"if",
"(",
"(",
"c",
"=",
"data",
"[",
"i",
"]",
")",
"<=",
"255",
"&&",
"arr",
".",
"get",
"(",
"c",
")",
")",
"i",
"++",
";",
"else",
"break",
";",
"}",
"return",
"i",
"-",
"off",
";",
"}",
"case",
"Term",
".",
"BITSET2",
":",
"{",
"int",
"i",
"=",
"off",
";",
"IntBitSet",
"[",
"]",
"bitset2",
"=",
"term",
".",
"bitset2",
";",
"char",
"c",
";",
"if",
"(",
"term",
".",
"inverse",
")",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"IntBitSet",
"arr",
"=",
"bitset2",
"[",
"(",
"c",
"=",
"data",
"[",
"i",
"]",
")",
">>",
"8",
"]",
";",
"if",
"(",
"arr",
"!=",
"null",
"&&",
"arr",
".",
"get",
"(",
"c",
"&",
"0xff",
")",
")",
"break",
";",
"else",
"i",
"++",
";",
"}",
"else",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"IntBitSet",
"arr",
"=",
"bitset2",
"[",
"(",
"c",
"=",
"data",
"[",
"i",
"]",
")",
">>",
"8",
"]",
";",
"if",
"(",
"arr",
"!=",
"null",
"&&",
"arr",
".",
"get",
"(",
"c",
"&",
"0xff",
")",
")",
"i",
"++",
";",
"else",
"break",
";",
"}",
"return",
"i",
"-",
"off",
";",
"}",
"}",
"throw",
"new",
"Error",
"(",
"\"this kind of term can't be quantified:\"",
"+",
"term",
".",
"type",
")",
";",
"}"
] | repeat while matches | [
"repeat",
"while",
"matches"
] | d4af9bb7c132c5f9d29f45b76121f93b2f89de16 | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/Matcher.java#L2200-L2255 | train |
tommyettinger/RegExodus | src/main/java/regexodus/Matcher.java | Matcher.find | private static int find(char[] data, int off, int out, Term term) {
if (off >= out) return -1;
switch (term.type) {
case Term.CHAR: {
char c = term.c;
int i = off;
while (i < out) {
if (data[i] == c) break;
i++;
}
return i - off;
}
case Term.BITSET: {
IntBitSet arr = term.bitset;
int i = off;
char c;
if (!term.inverse) while (i < out) {
if ((c = data[i]) <= 255 && arr.get(c)) break;
else i++;
}
else while (i < out) {
if ((c = data[i]) <= 255 && arr.get(c)) i++;
else break;
}
return i - off;
}
case Term.BITSET2: {
int i = off;
IntBitSet[] bitset2 = term.bitset2;
char c;
if (!term.inverse) while (i < out) {
IntBitSet arr = bitset2[(c = data[i]) >> 8];
if (arr != null && arr.get(c & 0xff)) break;
else i++;
}
else while (i < out) {
IntBitSet arr = bitset2[(c = data[i]) >> 8];
if (arr != null && arr.get(c & 0xff)) i++;
else break;
}
return i - off;
}
}
throw new IllegalArgumentException("can't seek this kind of term:" + term.type);
} | java | private static int find(char[] data, int off, int out, Term term) {
if (off >= out) return -1;
switch (term.type) {
case Term.CHAR: {
char c = term.c;
int i = off;
while (i < out) {
if (data[i] == c) break;
i++;
}
return i - off;
}
case Term.BITSET: {
IntBitSet arr = term.bitset;
int i = off;
char c;
if (!term.inverse) while (i < out) {
if ((c = data[i]) <= 255 && arr.get(c)) break;
else i++;
}
else while (i < out) {
if ((c = data[i]) <= 255 && arr.get(c)) i++;
else break;
}
return i - off;
}
case Term.BITSET2: {
int i = off;
IntBitSet[] bitset2 = term.bitset2;
char c;
if (!term.inverse) while (i < out) {
IntBitSet arr = bitset2[(c = data[i]) >> 8];
if (arr != null && arr.get(c & 0xff)) break;
else i++;
}
else while (i < out) {
IntBitSet arr = bitset2[(c = data[i]) >> 8];
if (arr != null && arr.get(c & 0xff)) i++;
else break;
}
return i - off;
}
}
throw new IllegalArgumentException("can't seek this kind of term:" + term.type);
} | [
"private",
"static",
"int",
"find",
"(",
"char",
"[",
"]",
"data",
",",
"int",
"off",
",",
"int",
"out",
",",
"Term",
"term",
")",
"{",
"if",
"(",
"off",
">=",
"out",
")",
"return",
"-",
"1",
";",
"switch",
"(",
"term",
".",
"type",
")",
"{",
"case",
"Term",
".",
"CHAR",
":",
"{",
"char",
"c",
"=",
"term",
".",
"c",
";",
"int",
"i",
"=",
"off",
";",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"if",
"(",
"data",
"[",
"i",
"]",
"==",
"c",
")",
"break",
";",
"i",
"++",
";",
"}",
"return",
"i",
"-",
"off",
";",
"}",
"case",
"Term",
".",
"BITSET",
":",
"{",
"IntBitSet",
"arr",
"=",
"term",
".",
"bitset",
";",
"int",
"i",
"=",
"off",
";",
"char",
"c",
";",
"if",
"(",
"!",
"term",
".",
"inverse",
")",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"if",
"(",
"(",
"c",
"=",
"data",
"[",
"i",
"]",
")",
"<=",
"255",
"&&",
"arr",
".",
"get",
"(",
"c",
")",
")",
"break",
";",
"else",
"i",
"++",
";",
"}",
"else",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"if",
"(",
"(",
"c",
"=",
"data",
"[",
"i",
"]",
")",
"<=",
"255",
"&&",
"arr",
".",
"get",
"(",
"c",
")",
")",
"i",
"++",
";",
"else",
"break",
";",
"}",
"return",
"i",
"-",
"off",
";",
"}",
"case",
"Term",
".",
"BITSET2",
":",
"{",
"int",
"i",
"=",
"off",
";",
"IntBitSet",
"[",
"]",
"bitset2",
"=",
"term",
".",
"bitset2",
";",
"char",
"c",
";",
"if",
"(",
"!",
"term",
".",
"inverse",
")",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"IntBitSet",
"arr",
"=",
"bitset2",
"[",
"(",
"c",
"=",
"data",
"[",
"i",
"]",
")",
">>",
"8",
"]",
";",
"if",
"(",
"arr",
"!=",
"null",
"&&",
"arr",
".",
"get",
"(",
"c",
"&",
"0xff",
")",
")",
"break",
";",
"else",
"i",
"++",
";",
"}",
"else",
"while",
"(",
"i",
"<",
"out",
")",
"{",
"IntBitSet",
"arr",
"=",
"bitset2",
"[",
"(",
"c",
"=",
"data",
"[",
"i",
"]",
")",
">>",
"8",
"]",
";",
"if",
"(",
"arr",
"!=",
"null",
"&&",
"arr",
".",
"get",
"(",
"c",
"&",
"0xff",
")",
")",
"i",
"++",
";",
"else",
"break",
";",
"}",
"return",
"i",
"-",
"off",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"can't seek this kind of term:\"",
"+",
"term",
".",
"type",
")",
";",
"}"
] | repeat while doesn't match | [
"repeat",
"while",
"doesn",
"t",
"match"
] | d4af9bb7c132c5f9d29f45b76121f93b2f89de16 | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/Matcher.java#L2258-L2302 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/FacebookDialog.java | FacebookDialog.present | public PendingCall present() {
logDialogActivity(activity, fragment, getEventName(appCall.getRequestIntent()),
AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED);
if (onPresentCallback != null) {
try {
onPresentCallback.onPresent(activity);
} catch (Exception e) {
throw new FacebookException(e);
}
}
if (fragment != null) {
fragment.startActivityForResult(appCall.getRequestIntent(), appCall.getRequestCode());
} else {
activity.startActivityForResult(appCall.getRequestIntent(), appCall.getRequestCode());
}
return appCall;
} | java | public PendingCall present() {
logDialogActivity(activity, fragment, getEventName(appCall.getRequestIntent()),
AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED);
if (onPresentCallback != null) {
try {
onPresentCallback.onPresent(activity);
} catch (Exception e) {
throw new FacebookException(e);
}
}
if (fragment != null) {
fragment.startActivityForResult(appCall.getRequestIntent(), appCall.getRequestCode());
} else {
activity.startActivityForResult(appCall.getRequestIntent(), appCall.getRequestCode());
}
return appCall;
} | [
"public",
"PendingCall",
"present",
"(",
")",
"{",
"logDialogActivity",
"(",
"activity",
",",
"fragment",
",",
"getEventName",
"(",
"appCall",
".",
"getRequestIntent",
"(",
")",
")",
",",
"AnalyticsEvents",
".",
"PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED",
")",
";",
"if",
"(",
"onPresentCallback",
"!=",
"null",
")",
"{",
"try",
"{",
"onPresentCallback",
".",
"onPresent",
"(",
"activity",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"FacebookException",
"(",
"e",
")",
";",
"}",
"}",
"if",
"(",
"fragment",
"!=",
"null",
")",
"{",
"fragment",
".",
"startActivityForResult",
"(",
"appCall",
".",
"getRequestIntent",
"(",
")",
",",
"appCall",
".",
"getRequestCode",
"(",
")",
")",
";",
"}",
"else",
"{",
"activity",
".",
"startActivityForResult",
"(",
"appCall",
".",
"getRequestIntent",
"(",
")",
",",
"appCall",
".",
"getRequestCode",
"(",
")",
")",
";",
"}",
"return",
"appCall",
";",
"}"
] | Launches an activity in the Facebook application to present the desired dialog. This method returns a
PendingCall that contains a unique ID associated with this call to the Facebook application. In general,
a calling Activity should use UiLifecycleHelper to handle incoming activity results, in order to ensure
proper processing of the results from this dialog.
@return a PendingCall containing the unique call ID corresponding to this call to the Facebook application | [
"Launches",
"an",
"activity",
"in",
"the",
"Facebook",
"application",
"to",
"present",
"the",
"desired",
"dialog",
".",
"This",
"method",
"returns",
"a",
"PendingCall",
"that",
"contains",
"a",
"unique",
"ID",
"associated",
"with",
"this",
"call",
"to",
"the",
"Facebook",
"application",
".",
"In",
"general",
"a",
"calling",
"Activity",
"should",
"use",
"UiLifecycleHelper",
"to",
"handle",
"incoming",
"activity",
"results",
"in",
"order",
"to",
"ensure",
"proper",
"processing",
"of",
"the",
"results",
"from",
"this",
"dialog",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/FacebookDialog.java#L304-L322 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/FacebookDialog.java | FacebookDialog.handleActivityResult | public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
Callback callback) {
if (requestCode != appCall.getRequestCode()) {
return false;
}
if (attachmentStore != null) {
attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
}
if (callback != null) {
if (NativeProtocol.isErrorResult(data)) {
Exception error = NativeProtocol.getErrorFromResult(data);
// TODO - data.getExtras() doesn't work for the bucketed protocol.
callback.onError(appCall, error, data.getExtras());
} else {
callback.onComplete(appCall, NativeProtocol.getSuccessResultsFromIntent(data));
}
}
return true;
} | java | public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
Callback callback) {
if (requestCode != appCall.getRequestCode()) {
return false;
}
if (attachmentStore != null) {
attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
}
if (callback != null) {
if (NativeProtocol.isErrorResult(data)) {
Exception error = NativeProtocol.getErrorFromResult(data);
// TODO - data.getExtras() doesn't work for the bucketed protocol.
callback.onError(appCall, error, data.getExtras());
} else {
callback.onComplete(appCall, NativeProtocol.getSuccessResultsFromIntent(data));
}
}
return true;
} | [
"public",
"static",
"boolean",
"handleActivityResult",
"(",
"Context",
"context",
",",
"PendingCall",
"appCall",
",",
"int",
"requestCode",
",",
"Intent",
"data",
",",
"Callback",
"callback",
")",
"{",
"if",
"(",
"requestCode",
"!=",
"appCall",
".",
"getRequestCode",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"attachmentStore",
"!=",
"null",
")",
"{",
"attachmentStore",
".",
"cleanupAttachmentsForCall",
"(",
"context",
",",
"appCall",
".",
"getCallId",
"(",
")",
")",
";",
"}",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"if",
"(",
"NativeProtocol",
".",
"isErrorResult",
"(",
"data",
")",
")",
"{",
"Exception",
"error",
"=",
"NativeProtocol",
".",
"getErrorFromResult",
"(",
"data",
")",
";",
"// TODO - data.getExtras() doesn't work for the bucketed protocol.",
"callback",
".",
"onError",
"(",
"appCall",
",",
"error",
",",
"data",
".",
"getExtras",
"(",
")",
")",
";",
"}",
"else",
"{",
"callback",
".",
"onComplete",
"(",
"appCall",
",",
"NativeProtocol",
".",
"getSuccessResultsFromIntent",
"(",
"data",
")",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
@param context the Context that is handling the activity result
@param appCall an PendingCall containing the call ID and original Intent used to launch the dialog
@param requestCode the request code for the activity result
@param data the result Intent
@param callback a callback to call after parsing the results
@return true if the activity result was handled, false if not | [
"Parses",
"the",
"results",
"of",
"a",
"dialog",
"activity",
"and",
"calls",
"the",
"appropriate",
"method",
"on",
"the",
"provided",
"Callback",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/FacebookDialog.java#L334-L356 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/FacebookDialog.java | FacebookDialog.canPresentShareDialog | public static boolean canPresentShareDialog(Context context, ShareDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(ShareDialogFeature.SHARE_DIALOG, features));
} | java | public static boolean canPresentShareDialog(Context context, ShareDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(ShareDialogFeature.SHARE_DIALOG, features));
} | [
"public",
"static",
"boolean",
"canPresentShareDialog",
"(",
"Context",
"context",
",",
"ShareDialogFeature",
"...",
"features",
")",
"{",
"return",
"handleCanPresent",
"(",
"context",
",",
"EnumSet",
".",
"of",
"(",
"ShareDialogFeature",
".",
"SHARE_DIALOG",
",",
"features",
")",
")",
";",
"}"
] | Determines whether the version of the Facebook application installed on the user's device is recent
enough to support specific features of the native Share dialog, which in turn may be used to determine
which UI, etc., to present to the user.
@param context the calling Context
@param features zero or more features to check for; {@link ShareDialogFeature#SHARE_DIALOG} is implicitly checked
if not explicitly specified
@return true if all of the specified features are supported by the currently installed version of the
Facebook application; false if any of the features are not supported | [
"Determines",
"whether",
"the",
"version",
"of",
"the",
"Facebook",
"application",
"installed",
"on",
"the",
"user",
"s",
"device",
"is",
"recent",
"enough",
"to",
"support",
"specific",
"features",
"of",
"the",
"native",
"Share",
"dialog",
"which",
"in",
"turn",
"may",
"be",
"used",
"to",
"determine",
"which",
"UI",
"etc",
".",
"to",
"present",
"to",
"the",
"user",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/FacebookDialog.java#L369-L371 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/FacebookDialog.java | FacebookDialog.canPresentMessageDialog | public static boolean canPresentMessageDialog(Context context, MessageDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(MessageDialogFeature.MESSAGE_DIALOG, features));
} | java | public static boolean canPresentMessageDialog(Context context, MessageDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(MessageDialogFeature.MESSAGE_DIALOG, features));
} | [
"public",
"static",
"boolean",
"canPresentMessageDialog",
"(",
"Context",
"context",
",",
"MessageDialogFeature",
"...",
"features",
")",
"{",
"return",
"handleCanPresent",
"(",
"context",
",",
"EnumSet",
".",
"of",
"(",
"MessageDialogFeature",
".",
"MESSAGE_DIALOG",
",",
"features",
")",
")",
";",
"}"
] | Determines whether the version of the Facebook application installed on the user's device is recent
enough to support specific features of the native Message dialog, which in turn may be used to determine
which UI, etc., to present to the user.
@param context the calling Context
@param features zero or more features to check for; {@link com.facebook.widget.FacebookDialog.MessageDialogFeature#MESSAGE_DIALOG} is implicitly
checked if not explicitly specified
@return true if all of the specified features are supported by the currently installed version of the
Facebook application; false if any of the features are not supported | [
"Determines",
"whether",
"the",
"version",
"of",
"the",
"Facebook",
"application",
"installed",
"on",
"the",
"user",
"s",
"device",
"is",
"recent",
"enough",
"to",
"support",
"specific",
"features",
"of",
"the",
"native",
"Message",
"dialog",
"which",
"in",
"turn",
"may",
"be",
"used",
"to",
"determine",
"which",
"UI",
"etc",
".",
"to",
"present",
"to",
"the",
"user",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/FacebookDialog.java#L384-L386 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/FacebookDialog.java | FacebookDialog.canPresentOpenGraphActionDialog | public static boolean canPresentOpenGraphActionDialog(Context context, OpenGraphActionDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(OpenGraphActionDialogFeature.OG_ACTION_DIALOG, features));
} | java | public static boolean canPresentOpenGraphActionDialog(Context context, OpenGraphActionDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(OpenGraphActionDialogFeature.OG_ACTION_DIALOG, features));
} | [
"public",
"static",
"boolean",
"canPresentOpenGraphActionDialog",
"(",
"Context",
"context",
",",
"OpenGraphActionDialogFeature",
"...",
"features",
")",
"{",
"return",
"handleCanPresent",
"(",
"context",
",",
"EnumSet",
".",
"of",
"(",
"OpenGraphActionDialogFeature",
".",
"OG_ACTION_DIALOG",
",",
"features",
")",
")",
";",
"}"
] | Determines whether the version of the Facebook application installed on the user's device is recent
enough to support specific features of the native Open Graph action dialog, which in turn may be used to
determine which UI, etc., to present to the user.
@param context the calling Context
@param features zero or more features to check for; {@link OpenGraphActionDialogFeature#OG_ACTION_DIALOG} is implicitly
checked if not explicitly specified
@return true if all of the specified features are supported by the currently installed version of the
Facebook application; false if any of the features are not supported | [
"Determines",
"whether",
"the",
"version",
"of",
"the",
"Facebook",
"application",
"installed",
"on",
"the",
"user",
"s",
"device",
"is",
"recent",
"enough",
"to",
"support",
"specific",
"features",
"of",
"the",
"native",
"Open",
"Graph",
"action",
"dialog",
"which",
"in",
"turn",
"may",
"be",
"used",
"to",
"determine",
"which",
"UI",
"etc",
".",
"to",
"present",
"to",
"the",
"user",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/FacebookDialog.java#L399-L401 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/FacebookDialog.java | FacebookDialog.canPresentOpenGraphMessageDialog | public static boolean canPresentOpenGraphMessageDialog(Context context, OpenGraphMessageDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(OpenGraphMessageDialogFeature.OG_MESSAGE_DIALOG, features));
} | java | public static boolean canPresentOpenGraphMessageDialog(Context context, OpenGraphMessageDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(OpenGraphMessageDialogFeature.OG_MESSAGE_DIALOG, features));
} | [
"public",
"static",
"boolean",
"canPresentOpenGraphMessageDialog",
"(",
"Context",
"context",
",",
"OpenGraphMessageDialogFeature",
"...",
"features",
")",
"{",
"return",
"handleCanPresent",
"(",
"context",
",",
"EnumSet",
".",
"of",
"(",
"OpenGraphMessageDialogFeature",
".",
"OG_MESSAGE_DIALOG",
",",
"features",
")",
")",
";",
"}"
] | Determines whether the version of the Facebook application installed on the user's device is recent
enough to support specific features of the native Open Graph Message dialog, which in turn may be used to
determine which UI, etc., to present to the user.
@param context the calling Context
@param features zero or more features to check for; {@link com.facebook.widget.FacebookDialog.OpenGraphMessageDialogFeature#OG_MESSAGE_DIALOG} is
implicitly checked if not explicitly specified
@return true if all of the specified features are supported by the currently installed version of the
Facebook application; false if any of the features are not supported | [
"Determines",
"whether",
"the",
"version",
"of",
"the",
"Facebook",
"application",
"installed",
"on",
"the",
"user",
"s",
"device",
"is",
"recent",
"enough",
"to",
"support",
"specific",
"features",
"of",
"the",
"native",
"Open",
"Graph",
"Message",
"dialog",
"which",
"in",
"turn",
"may",
"be",
"used",
"to",
"determine",
"which",
"UI",
"etc",
".",
"to",
"present",
"to",
"the",
"user",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/FacebookDialog.java#L414-L416 | train |
anotheria/configureme | src/main/java/org/configureme/environments/LocaleBasedEnvironment.java | LocaleBasedEnvironment.reduceVariant | private static String reduceVariant(final String variant){
if (isEmpty(variant))
throw new AssertionError("Shouldn't happen, can't reduce non existent variant");
int indexOfUnderscore = variant.lastIndexOf('_');
if (indexOfUnderscore==-1)
return "";
return variant.substring(0, indexOfUnderscore);
} | java | private static String reduceVariant(final String variant){
if (isEmpty(variant))
throw new AssertionError("Shouldn't happen, can't reduce non existent variant");
int indexOfUnderscore = variant.lastIndexOf('_');
if (indexOfUnderscore==-1)
return "";
return variant.substring(0, indexOfUnderscore);
} | [
"private",
"static",
"String",
"reduceVariant",
"(",
"final",
"String",
"variant",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"variant",
")",
")",
"throw",
"new",
"AssertionError",
"(",
"\"Shouldn't happen, can't reduce non existent variant\"",
")",
";",
"int",
"indexOfUnderscore",
"=",
"variant",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"indexOfUnderscore",
"==",
"-",
"1",
")",
"return",
"\"\"",
";",
"return",
"variant",
".",
"substring",
"(",
"0",
",",
"indexOfUnderscore",
")",
";",
"}"
] | This function is used internally to reduce the variant -> a_b_c -> a_b.
@param variant the variant to reduce
@return reduced variant | [
"This",
"function",
"is",
"used",
"internally",
"to",
"reduce",
"the",
"variant",
"-",
">",
"a_b_c",
"-",
">",
"a_b",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/environments/LocaleBasedEnvironment.java#L146-L154 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/TypedIdKey.java | TypedIdKey.associate | @SuppressWarnings({ "unchecked" })
public static <V> V associate(Associator associator, Serializable id,
V value) {
associator.setAssociated(
new TypedIdKey<V>((Class<V>) value.getClass(), id), value);
return value;
} | java | @SuppressWarnings({ "unchecked" })
public static <V> V associate(Associator associator, Serializable id,
V value) {
associator.setAssociated(
new TypedIdKey<V>((Class<V>) value.getClass(), id), value);
return value;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
"}",
")",
"public",
"static",
"<",
"V",
">",
"V",
"associate",
"(",
"Associator",
"associator",
",",
"Serializable",
"id",
",",
"V",
"value",
")",
"{",
"associator",
".",
"setAssociated",
"(",
"new",
"TypedIdKey",
"<",
"V",
">",
"(",
"(",
"Class",
"<",
"V",
">",
")",
"value",
".",
"getClass",
"(",
")",
",",
"id",
")",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] | Associates the given value's type and the id with the given value
using the given associator.
@param <V> the value type
@param associator the associator
@param id the id
@param value the value
@return the value for easy chaining | [
"Associates",
"the",
"given",
"value",
"s",
"type",
"and",
"the",
"id",
"with",
"the",
"given",
"value",
"using",
"the",
"given",
"associator",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/TypedIdKey.java#L53-L59 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/TypedIdKey.java | TypedIdKey.put | @SuppressWarnings({ "unchecked" })
public static <V> V put(Map<? super TypedIdKey<V>, ? super V> map,
Serializable id, V value) {
map.put(new TypedIdKey<V>((Class<V>) value.getClass(), id), value);
return value;
} | java | @SuppressWarnings({ "unchecked" })
public static <V> V put(Map<? super TypedIdKey<V>, ? super V> map,
Serializable id, V value) {
map.put(new TypedIdKey<V>((Class<V>) value.getClass(), id), value);
return value;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
"}",
")",
"public",
"static",
"<",
"V",
">",
"V",
"put",
"(",
"Map",
"<",
"?",
"super",
"TypedIdKey",
"<",
"V",
">",
",",
"?",
"super",
"V",
">",
"map",
",",
"Serializable",
"id",
",",
"V",
"value",
")",
"{",
"map",
".",
"put",
"(",
"new",
"TypedIdKey",
"<",
"V",
">",
"(",
"(",
"Class",
"<",
"V",
">",
")",
"value",
".",
"getClass",
"(",
")",
",",
"id",
")",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] | Associates the given value's type and the id with the given value
using the given map.
@param <V> the value type
@param map the map
@param id the id
@param value the value
@return the value for easy chaining | [
"Associates",
"the",
"given",
"value",
"s",
"type",
"and",
"the",
"id",
"with",
"the",
"given",
"value",
"using",
"the",
"given",
"map",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/TypedIdKey.java#L71-L76 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/TypedIdKey.java | TypedIdKey.associated | public static <V> Optional<V> associated(Associator associator,
Class<V> type, Serializable id) {
return associator.associated(new TypedIdKey<>(type, id), type);
} | java | public static <V> Optional<V> associated(Associator associator,
Class<V> type, Serializable id) {
return associator.associated(new TypedIdKey<>(type, id), type);
} | [
"public",
"static",
"<",
"V",
">",
"Optional",
"<",
"V",
">",
"associated",
"(",
"Associator",
"associator",
",",
"Class",
"<",
"V",
">",
"type",
",",
"Serializable",
"id",
")",
"{",
"return",
"associator",
".",
"associated",
"(",
"new",
"TypedIdKey",
"<>",
"(",
"type",
",",
"id",
")",
",",
"type",
")",
";",
"}"
] | Retrieves a value with the given type and id from the given associator.
@param <V> the value type
@param associator the associator
@param type the type
@param id the id
@return the associated value, if any | [
"Retrieves",
"a",
"value",
"with",
"the",
"given",
"type",
"and",
"id",
"from",
"the",
"given",
"associator",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/TypedIdKey.java#L87-L90 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/TypedIdKey.java | TypedIdKey.get | @SuppressWarnings({ "unchecked" })
public static <V> Optional<V> get(Map<?, ?> map, Class<V> type,
Serializable id) {
return Optional
.ofNullable((V) map.get(new TypedIdKey<>(type, id)));
} | java | @SuppressWarnings({ "unchecked" })
public static <V> Optional<V> get(Map<?, ?> map, Class<V> type,
Serializable id) {
return Optional
.ofNullable((V) map.get(new TypedIdKey<>(type, id)));
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
"}",
")",
"public",
"static",
"<",
"V",
">",
"Optional",
"<",
"V",
">",
"get",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"map",
",",
"Class",
"<",
"V",
">",
"type",
",",
"Serializable",
"id",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"(",
"V",
")",
"map",
".",
"get",
"(",
"new",
"TypedIdKey",
"<>",
"(",
"type",
",",
"id",
")",
")",
")",
";",
"}"
] | Retrieves a value with the given type and id from the given map.
@param <V> the value type
@param map the map
@param type the type
@param id the id
@return the associated value, if any | [
"Retrieves",
"a",
"value",
"with",
"the",
"given",
"type",
"and",
"id",
"from",
"the",
"given",
"map",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/TypedIdKey.java#L101-L106 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/media/BaseFolder.java | BaseFolder.with | public static BaseFolder with(String first, String... more) {
return new BaseFolder(Paths.get(first, more));
} | java | public static BaseFolder with(String first, String... more) {
return new BaseFolder(Paths.get(first, more));
} | [
"public",
"static",
"BaseFolder",
"with",
"(",
"String",
"first",
",",
"String",
"...",
"more",
")",
"{",
"return",
"new",
"BaseFolder",
"(",
"Paths",
".",
"get",
"(",
"first",
",",
"more",
")",
")",
";",
"}"
] | Creates a new base folder at the specified location.
@param first the path string or initial part of the path string
@param more additional strings to be joined to form the path string
@return the new instance | [
"Creates",
"a",
"new",
"base",
"folder",
"at",
"the",
"specified",
"location",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/media/BaseFolder.java#L33-L35 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/GeneratorRegistry.java | GeneratorRegistry.add | @SuppressWarnings({ "PMD.GuardLogStatement", "PMD.AvoidDuplicateLiterals" })
public void add(Object obj) {
synchronized (this) {
running += 1;
if (generators != null) {
generators.put(obj, null);
generatorTracking.finest(() -> "Added generator " + obj
+ ", " + generators.size() + " generators registered: "
+ generators.keySet());
}
if (running == 1) { // NOPMD, no, not using a constant for this.
keepAlive = new Thread("GeneratorRegistry") {
@Override
public void run() {
try {
while (true) {
Thread.sleep(Long.MAX_VALUE);
}
} catch (InterruptedException e) {
// Okay, then stop
}
}
};
keepAlive.start();
}
}
} | java | @SuppressWarnings({ "PMD.GuardLogStatement", "PMD.AvoidDuplicateLiterals" })
public void add(Object obj) {
synchronized (this) {
running += 1;
if (generators != null) {
generators.put(obj, null);
generatorTracking.finest(() -> "Added generator " + obj
+ ", " + generators.size() + " generators registered: "
+ generators.keySet());
}
if (running == 1) { // NOPMD, no, not using a constant for this.
keepAlive = new Thread("GeneratorRegistry") {
@Override
public void run() {
try {
while (true) {
Thread.sleep(Long.MAX_VALUE);
}
} catch (InterruptedException e) {
// Okay, then stop
}
}
};
keepAlive.start();
}
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"PMD.GuardLogStatement\"",
",",
"\"PMD.AvoidDuplicateLiterals\"",
"}",
")",
"public",
"void",
"add",
"(",
"Object",
"obj",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"running",
"+=",
"1",
";",
"if",
"(",
"generators",
"!=",
"null",
")",
"{",
"generators",
".",
"put",
"(",
"obj",
",",
"null",
")",
";",
"generatorTracking",
".",
"finest",
"(",
"(",
")",
"->",
"\"Added generator \"",
"+",
"obj",
"+",
"\", \"",
"+",
"generators",
".",
"size",
"(",
")",
"+",
"\" generators registered: \"",
"+",
"generators",
".",
"keySet",
"(",
")",
")",
";",
"}",
"if",
"(",
"running",
"==",
"1",
")",
"{",
"// NOPMD, no, not using a constant for this.",
"keepAlive",
"=",
"new",
"Thread",
"(",
"\"GeneratorRegistry\"",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"while",
"(",
"true",
")",
"{",
"Thread",
".",
"sleep",
"(",
"Long",
".",
"MAX_VALUE",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// Okay, then stop",
"}",
"}",
"}",
";",
"keepAlive",
".",
"start",
"(",
")",
";",
"}",
"}",
"}"
] | Adds a generator.
@param obj the obj | [
"Adds",
"a",
"generator",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/GeneratorRegistry.java#L72-L98 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/GeneratorRegistry.java | GeneratorRegistry.remove | @SuppressWarnings("PMD.GuardLogStatement")
public void remove(Object obj) {
synchronized (this) {
running -= 1;
if (generators != null) {
generators.remove(obj);
generatorTracking.finest(() -> "Removed generator " + obj
+ ", " + generators.size() + " generators registered: "
+ generators.keySet());
}
if (running == 0) {
generatorTracking
.finest(() -> "Zero generators, notifying all.");
keepAlive.interrupt();
notifyAll();
}
}
} | java | @SuppressWarnings("PMD.GuardLogStatement")
public void remove(Object obj) {
synchronized (this) {
running -= 1;
if (generators != null) {
generators.remove(obj);
generatorTracking.finest(() -> "Removed generator " + obj
+ ", " + generators.size() + " generators registered: "
+ generators.keySet());
}
if (running == 0) {
generatorTracking
.finest(() -> "Zero generators, notifying all.");
keepAlive.interrupt();
notifyAll();
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.GuardLogStatement\"",
")",
"public",
"void",
"remove",
"(",
"Object",
"obj",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"running",
"-=",
"1",
";",
"if",
"(",
"generators",
"!=",
"null",
")",
"{",
"generators",
".",
"remove",
"(",
"obj",
")",
";",
"generatorTracking",
".",
"finest",
"(",
"(",
")",
"->",
"\"Removed generator \"",
"+",
"obj",
"+",
"\", \"",
"+",
"generators",
".",
"size",
"(",
")",
"+",
"\" generators registered: \"",
"+",
"generators",
".",
"keySet",
"(",
")",
")",
";",
"}",
"if",
"(",
"running",
"==",
"0",
")",
"{",
"generatorTracking",
".",
"finest",
"(",
"(",
")",
"->",
"\"Zero generators, notifying all.\"",
")",
";",
"keepAlive",
".",
"interrupt",
"(",
")",
";",
"notifyAll",
"(",
")",
";",
"}",
"}",
"}"
] | Removes the generator.
@param obj the generator | [
"Removes",
"the",
"generator",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/GeneratorRegistry.java#L105-L122 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/GeneratorRegistry.java | GeneratorRegistry.awaitExhaustion | @SuppressWarnings({ "PMD.CollapsibleIfStatements",
"PMD.GuardLogStatement" })
public void awaitExhaustion() throws InterruptedException {
synchronized (this) {
if (generators != null) {
if (running != generators.size()) {
generatorTracking
.severe(() -> "Generator count doesn't match tracked.");
}
}
while (running > 0) {
if (generators != null) {
generatorTracking
.fine(() -> "Thread " + Thread.currentThread().getName()
+ " is waiting, " + generators.size()
+ " generators registered: "
+ generators.keySet());
}
wait();
}
generatorTracking
.finest("Thread " + Thread.currentThread().getName()
+ " continues.");
}
} | java | @SuppressWarnings({ "PMD.CollapsibleIfStatements",
"PMD.GuardLogStatement" })
public void awaitExhaustion() throws InterruptedException {
synchronized (this) {
if (generators != null) {
if (running != generators.size()) {
generatorTracking
.severe(() -> "Generator count doesn't match tracked.");
}
}
while (running > 0) {
if (generators != null) {
generatorTracking
.fine(() -> "Thread " + Thread.currentThread().getName()
+ " is waiting, " + generators.size()
+ " generators registered: "
+ generators.keySet());
}
wait();
}
generatorTracking
.finest("Thread " + Thread.currentThread().getName()
+ " continues.");
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"PMD.CollapsibleIfStatements\"",
",",
"\"PMD.GuardLogStatement\"",
"}",
")",
"public",
"void",
"awaitExhaustion",
"(",
")",
"throws",
"InterruptedException",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"generators",
"!=",
"null",
")",
"{",
"if",
"(",
"running",
"!=",
"generators",
".",
"size",
"(",
")",
")",
"{",
"generatorTracking",
".",
"severe",
"(",
"(",
")",
"->",
"\"Generator count doesn't match tracked.\"",
")",
";",
"}",
"}",
"while",
"(",
"running",
">",
"0",
")",
"{",
"if",
"(",
"generators",
"!=",
"null",
")",
"{",
"generatorTracking",
".",
"fine",
"(",
"(",
")",
"->",
"\"Thread \"",
"+",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" is waiting, \"",
"+",
"generators",
".",
"size",
"(",
")",
"+",
"\" generators registered: \"",
"+",
"generators",
".",
"keySet",
"(",
")",
")",
";",
"}",
"wait",
"(",
")",
";",
"}",
"generatorTracking",
".",
"finest",
"(",
"\"Thread \"",
"+",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" continues.\"",
")",
";",
"}",
"}"
] | Await exhaustion.
@throws InterruptedException the interrupted exception | [
"Await",
"exhaustion",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/GeneratorRegistry.java#L138-L162 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/GeneratorRegistry.java | GeneratorRegistry.awaitExhaustion | @SuppressWarnings({ "PMD.CollapsibleIfStatements",
"PMD.GuardLogStatement" })
public boolean awaitExhaustion(long timeout)
throws InterruptedException {
synchronized (this) {
if (generators != null) {
if (running != generators.size()) {
generatorTracking.severe(
"Generator count doesn't match tracked.");
}
}
if (isExhausted()) {
return true;
}
if (generators != null) {
generatorTracking
.fine(() -> "Waiting, generators: " + generators.keySet());
}
wait(timeout);
if (generators != null) {
generatorTracking
.fine(() -> "Waited, generators: " + generators.keySet());
}
return isExhausted();
}
} | java | @SuppressWarnings({ "PMD.CollapsibleIfStatements",
"PMD.GuardLogStatement" })
public boolean awaitExhaustion(long timeout)
throws InterruptedException {
synchronized (this) {
if (generators != null) {
if (running != generators.size()) {
generatorTracking.severe(
"Generator count doesn't match tracked.");
}
}
if (isExhausted()) {
return true;
}
if (generators != null) {
generatorTracking
.fine(() -> "Waiting, generators: " + generators.keySet());
}
wait(timeout);
if (generators != null) {
generatorTracking
.fine(() -> "Waited, generators: " + generators.keySet());
}
return isExhausted();
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"PMD.CollapsibleIfStatements\"",
",",
"\"PMD.GuardLogStatement\"",
"}",
")",
"public",
"boolean",
"awaitExhaustion",
"(",
"long",
"timeout",
")",
"throws",
"InterruptedException",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"generators",
"!=",
"null",
")",
"{",
"if",
"(",
"running",
"!=",
"generators",
".",
"size",
"(",
")",
")",
"{",
"generatorTracking",
".",
"severe",
"(",
"\"Generator count doesn't match tracked.\"",
")",
";",
"}",
"}",
"if",
"(",
"isExhausted",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"generators",
"!=",
"null",
")",
"{",
"generatorTracking",
".",
"fine",
"(",
"(",
")",
"->",
"\"Waiting, generators: \"",
"+",
"generators",
".",
"keySet",
"(",
")",
")",
";",
"}",
"wait",
"(",
"timeout",
")",
";",
"if",
"(",
"generators",
"!=",
"null",
")",
"{",
"generatorTracking",
".",
"fine",
"(",
"(",
")",
"->",
"\"Waited, generators: \"",
"+",
"generators",
".",
"keySet",
"(",
")",
")",
";",
"}",
"return",
"isExhausted",
"(",
")",
";",
"}",
"}"
] | Await exhaustion with a timeout.
@param timeout the timeout
@return true, if successful
@throws InterruptedException the interrupted exception | [
"Await",
"exhaustion",
"with",
"a",
"timeout",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/GeneratorRegistry.java#L171-L196 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/tasks/TaskSystemInformation.java | TaskSystemInformation.matchesLocale | public boolean matchesLocale(String loc) {
return getLocale()==null || (getLocale().isPresent() && getLocale().get().startsWith(loc));
} | java | public boolean matchesLocale(String loc) {
return getLocale()==null || (getLocale().isPresent() && getLocale().get().startsWith(loc));
} | [
"public",
"boolean",
"matchesLocale",
"(",
"String",
"loc",
")",
"{",
"return",
"getLocale",
"(",
")",
"==",
"null",
"||",
"(",
"getLocale",
"(",
")",
".",
"isPresent",
"(",
")",
"&&",
"getLocale",
"(",
")",
".",
"get",
"(",
")",
".",
"startsWith",
"(",
"loc",
")",
")",
";",
"}"
] | Returns true if the information matches the specified locale.
@param loc the locale to test
@return returns true if the information is a match for the locale, false otherwise | [
"Returns",
"true",
"if",
"the",
"information",
"matches",
"the",
"specified",
"locale",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/tasks/TaskSystemInformation.java#L93-L95 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newPostRequest | public static Request newPostRequest(Session session, String graphPath, GraphObject graphObject, Callback callback) {
Request request = new Request(session, graphPath, null, HttpMethod.POST , callback);
request.setGraphObject(graphObject);
return request;
} | java | public static Request newPostRequest(Session session, String graphPath, GraphObject graphObject, Callback callback) {
Request request = new Request(session, graphPath, null, HttpMethod.POST , callback);
request.setGraphObject(graphObject);
return request;
} | [
"public",
"static",
"Request",
"newPostRequest",
"(",
"Session",
"session",
",",
"String",
"graphPath",
",",
"GraphObject",
"graphObject",
",",
"Callback",
"callback",
")",
"{",
"Request",
"request",
"=",
"new",
"Request",
"(",
"session",
",",
"graphPath",
",",
"null",
",",
"HttpMethod",
".",
"POST",
",",
"callback",
")",
";",
"request",
".",
"setGraphObject",
"(",
"graphObject",
")",
";",
"return",
"request",
";",
"}"
] | Creates a new Request configured to post a GraphObject to a particular graph path, to either create or update the
object at that path.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param graphPath
the graph path to retrieve, create, or delete
@param graphObject
the GraphObject to create or update
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"post",
"a",
"GraphObject",
"to",
"a",
"particular",
"graph",
"path",
"to",
"either",
"create",
"or",
"update",
"the",
"object",
"at",
"that",
"path",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L260-L264 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newMeRequest | public static Request newMeRequest(Session session, final GraphUserCallback callback) {
Callback wrapper = new Callback() {
@Override
public void onCompleted(Response response) {
if (callback != null) {
callback.onCompleted(response.getGraphObjectAs(GraphUser.class), response);
}
}
};
return new Request(session, ME, null, null, wrapper);
} | java | public static Request newMeRequest(Session session, final GraphUserCallback callback) {
Callback wrapper = new Callback() {
@Override
public void onCompleted(Response response) {
if (callback != null) {
callback.onCompleted(response.getGraphObjectAs(GraphUser.class), response);
}
}
};
return new Request(session, ME, null, null, wrapper);
} | [
"public",
"static",
"Request",
"newMeRequest",
"(",
"Session",
"session",
",",
"final",
"GraphUserCallback",
"callback",
")",
"{",
"Callback",
"wrapper",
"=",
"new",
"Callback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onCompleted",
"(",
"Response",
"response",
")",
"{",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback",
".",
"onCompleted",
"(",
"response",
".",
"getGraphObjectAs",
"(",
"GraphUser",
".",
"class",
")",
",",
"response",
")",
";",
"}",
"}",
"}",
";",
"return",
"new",
"Request",
"(",
"session",
",",
"ME",
",",
"null",
",",
"null",
",",
"wrapper",
")",
";",
"}"
] | Creates a new Request configured to retrieve a user's own profile.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"retrieve",
"a",
"user",
"s",
"own",
"profile",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L275-L285 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newMyFriendsRequest | public static Request newMyFriendsRequest(Session session, final GraphUserListCallback callback) {
Callback wrapper = new Callback() {
@Override
public void onCompleted(Response response) {
if (callback != null) {
callback.onCompleted(typedListFromResponse(response, GraphUser.class), response);
}
}
};
return new Request(session, MY_FRIENDS, null, null, wrapper);
} | java | public static Request newMyFriendsRequest(Session session, final GraphUserListCallback callback) {
Callback wrapper = new Callback() {
@Override
public void onCompleted(Response response) {
if (callback != null) {
callback.onCompleted(typedListFromResponse(response, GraphUser.class), response);
}
}
};
return new Request(session, MY_FRIENDS, null, null, wrapper);
} | [
"public",
"static",
"Request",
"newMyFriendsRequest",
"(",
"Session",
"session",
",",
"final",
"GraphUserListCallback",
"callback",
")",
"{",
"Callback",
"wrapper",
"=",
"new",
"Callback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onCompleted",
"(",
"Response",
"response",
")",
"{",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback",
".",
"onCompleted",
"(",
"typedListFromResponse",
"(",
"response",
",",
"GraphUser",
".",
"class",
")",
",",
"response",
")",
";",
"}",
"}",
"}",
";",
"return",
"new",
"Request",
"(",
"session",
",",
"MY_FRIENDS",
",",
"null",
",",
"null",
",",
"wrapper",
")",
";",
"}"
] | Creates a new Request configured to retrieve a user's friend list.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"retrieve",
"a",
"user",
"s",
"friend",
"list",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L296-L306 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newUploadPhotoRequest | public static Request newUploadPhotoRequest(Session session, Bitmap image, Callback callback) {
Bundle parameters = new Bundle(1);
parameters.putParcelable(PICTURE_PARAM, image);
return new Request(session, MY_PHOTOS, parameters, HttpMethod.POST, callback);
} | java | public static Request newUploadPhotoRequest(Session session, Bitmap image, Callback callback) {
Bundle parameters = new Bundle(1);
parameters.putParcelable(PICTURE_PARAM, image);
return new Request(session, MY_PHOTOS, parameters, HttpMethod.POST, callback);
} | [
"public",
"static",
"Request",
"newUploadPhotoRequest",
"(",
"Session",
"session",
",",
"Bitmap",
"image",
",",
"Callback",
"callback",
")",
"{",
"Bundle",
"parameters",
"=",
"new",
"Bundle",
"(",
"1",
")",
";",
"parameters",
".",
"putParcelable",
"(",
"PICTURE_PARAM",
",",
"image",
")",
";",
"return",
"new",
"Request",
"(",
"session",
",",
"MY_PHOTOS",
",",
"parameters",
",",
"HttpMethod",
".",
"POST",
",",
"callback",
")",
";",
"}"
] | Creates a new Request configured to upload a photo to the user's default photo album.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param image
the image to upload
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"upload",
"a",
"photo",
"to",
"the",
"user",
"s",
"default",
"photo",
"album",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L319-L324 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newUploadPhotoRequest | public static Request newUploadPhotoRequest(Session session, File file,
Callback callback) throws FileNotFoundException {
ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
Bundle parameters = new Bundle(1);
parameters.putParcelable(PICTURE_PARAM, descriptor);
return new Request(session, MY_PHOTOS, parameters, HttpMethod.POST, callback);
} | java | public static Request newUploadPhotoRequest(Session session, File file,
Callback callback) throws FileNotFoundException {
ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
Bundle parameters = new Bundle(1);
parameters.putParcelable(PICTURE_PARAM, descriptor);
return new Request(session, MY_PHOTOS, parameters, HttpMethod.POST, callback);
} | [
"public",
"static",
"Request",
"newUploadPhotoRequest",
"(",
"Session",
"session",
",",
"File",
"file",
",",
"Callback",
"callback",
")",
"throws",
"FileNotFoundException",
"{",
"ParcelFileDescriptor",
"descriptor",
"=",
"ParcelFileDescriptor",
".",
"open",
"(",
"file",
",",
"ParcelFileDescriptor",
".",
"MODE_READ_ONLY",
")",
";",
"Bundle",
"parameters",
"=",
"new",
"Bundle",
"(",
"1",
")",
";",
"parameters",
".",
"putParcelable",
"(",
"PICTURE_PARAM",
",",
"descriptor",
")",
";",
"return",
"new",
"Request",
"(",
"session",
",",
"MY_PHOTOS",
",",
"parameters",
",",
"HttpMethod",
".",
"POST",
",",
"callback",
")",
";",
"}"
] | Creates a new Request configured to upload a photo to the user's default photo album. The photo
will be read from the specified stream.
@param session the Session to use, or null; if non-null, the session must be in an opened state
@param file the file containing the photo to upload
@param callback a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"upload",
"a",
"photo",
"to",
"the",
"user",
"s",
"default",
"photo",
"album",
".",
"The",
"photo",
"will",
"be",
"read",
"from",
"the",
"specified",
"stream",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L335-L342 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newUploadVideoRequest | public static Request newUploadVideoRequest(Session session, File file,
Callback callback) throws FileNotFoundException {
ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
Bundle parameters = new Bundle(1);
parameters.putParcelable(file.getName(), descriptor);
return new Request(session, MY_VIDEOS, parameters, HttpMethod.POST, callback);
} | java | public static Request newUploadVideoRequest(Session session, File file,
Callback callback) throws FileNotFoundException {
ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
Bundle parameters = new Bundle(1);
parameters.putParcelable(file.getName(), descriptor);
return new Request(session, MY_VIDEOS, parameters, HttpMethod.POST, callback);
} | [
"public",
"static",
"Request",
"newUploadVideoRequest",
"(",
"Session",
"session",
",",
"File",
"file",
",",
"Callback",
"callback",
")",
"throws",
"FileNotFoundException",
"{",
"ParcelFileDescriptor",
"descriptor",
"=",
"ParcelFileDescriptor",
".",
"open",
"(",
"file",
",",
"ParcelFileDescriptor",
".",
"MODE_READ_ONLY",
")",
";",
"Bundle",
"parameters",
"=",
"new",
"Bundle",
"(",
"1",
")",
";",
"parameters",
".",
"putParcelable",
"(",
"file",
".",
"getName",
"(",
")",
",",
"descriptor",
")",
";",
"return",
"new",
"Request",
"(",
"session",
",",
"MY_VIDEOS",
",",
"parameters",
",",
"HttpMethod",
".",
"POST",
",",
"callback",
")",
";",
"}"
] | Creates a new Request configured to upload a photo to the user's default photo album. The photo
will be read from the specified file descriptor.
@param session the Session to use, or null; if non-null, the session must be in an opened state
@param file the file to upload
@param callback a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"upload",
"a",
"photo",
"to",
"the",
"user",
"s",
"default",
"photo",
"album",
".",
"The",
"photo",
"will",
"be",
"read",
"from",
"the",
"specified",
"file",
"descriptor",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L353-L360 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newGraphPathRequest | public static Request newGraphPathRequest(Session session, String graphPath, Callback callback) {
return new Request(session, graphPath, null, null, callback);
} | java | public static Request newGraphPathRequest(Session session, String graphPath, Callback callback) {
return new Request(session, graphPath, null, null, callback);
} | [
"public",
"static",
"Request",
"newGraphPathRequest",
"(",
"Session",
"session",
",",
"String",
"graphPath",
",",
"Callback",
"callback",
")",
"{",
"return",
"new",
"Request",
"(",
"session",
",",
"graphPath",
",",
"null",
",",
"null",
",",
"callback",
")",
";",
"}"
] | Creates a new Request configured to retrieve a particular graph path.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param graphPath
the graph path to retrieve
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"retrieve",
"a",
"particular",
"graph",
"path",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L373-L375 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newPlacesSearchRequest | public static Request newPlacesSearchRequest(Session session, Location location, int radiusInMeters,
int resultsLimit, String searchText, final GraphPlaceListCallback callback) {
if (location == null && Utility.isNullOrEmpty(searchText)) {
throw new FacebookException("Either location or searchText must be specified.");
}
Bundle parameters = new Bundle(5);
parameters.putString("type", "place");
parameters.putInt("limit", resultsLimit);
if (location != null) {
parameters.putString("center",
String.format(Locale.US, "%f,%f", location.getLatitude(), location.getLongitude()));
parameters.putInt("distance", radiusInMeters);
}
if (!Utility.isNullOrEmpty(searchText)) {
parameters.putString("q", searchText);
}
Callback wrapper = new Callback() {
@Override
public void onCompleted(Response response) {
if (callback != null) {
callback.onCompleted(typedListFromResponse(response, GraphPlace.class), response);
}
}
};
return new Request(session, SEARCH, parameters, HttpMethod.GET, wrapper);
} | java | public static Request newPlacesSearchRequest(Session session, Location location, int radiusInMeters,
int resultsLimit, String searchText, final GraphPlaceListCallback callback) {
if (location == null && Utility.isNullOrEmpty(searchText)) {
throw new FacebookException("Either location or searchText must be specified.");
}
Bundle parameters = new Bundle(5);
parameters.putString("type", "place");
parameters.putInt("limit", resultsLimit);
if (location != null) {
parameters.putString("center",
String.format(Locale.US, "%f,%f", location.getLatitude(), location.getLongitude()));
parameters.putInt("distance", radiusInMeters);
}
if (!Utility.isNullOrEmpty(searchText)) {
parameters.putString("q", searchText);
}
Callback wrapper = new Callback() {
@Override
public void onCompleted(Response response) {
if (callback != null) {
callback.onCompleted(typedListFromResponse(response, GraphPlace.class), response);
}
}
};
return new Request(session, SEARCH, parameters, HttpMethod.GET, wrapper);
} | [
"public",
"static",
"Request",
"newPlacesSearchRequest",
"(",
"Session",
"session",
",",
"Location",
"location",
",",
"int",
"radiusInMeters",
",",
"int",
"resultsLimit",
",",
"String",
"searchText",
",",
"final",
"GraphPlaceListCallback",
"callback",
")",
"{",
"if",
"(",
"location",
"==",
"null",
"&&",
"Utility",
".",
"isNullOrEmpty",
"(",
"searchText",
")",
")",
"{",
"throw",
"new",
"FacebookException",
"(",
"\"Either location or searchText must be specified.\"",
")",
";",
"}",
"Bundle",
"parameters",
"=",
"new",
"Bundle",
"(",
"5",
")",
";",
"parameters",
".",
"putString",
"(",
"\"type\"",
",",
"\"place\"",
")",
";",
"parameters",
".",
"putInt",
"(",
"\"limit\"",
",",
"resultsLimit",
")",
";",
"if",
"(",
"location",
"!=",
"null",
")",
"{",
"parameters",
".",
"putString",
"(",
"\"center\"",
",",
"String",
".",
"format",
"(",
"Locale",
".",
"US",
",",
"\"%f,%f\"",
",",
"location",
".",
"getLatitude",
"(",
")",
",",
"location",
".",
"getLongitude",
"(",
")",
")",
")",
";",
"parameters",
".",
"putInt",
"(",
"\"distance\"",
",",
"radiusInMeters",
")",
";",
"}",
"if",
"(",
"!",
"Utility",
".",
"isNullOrEmpty",
"(",
"searchText",
")",
")",
"{",
"parameters",
".",
"putString",
"(",
"\"q\"",
",",
"searchText",
")",
";",
"}",
"Callback",
"wrapper",
"=",
"new",
"Callback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onCompleted",
"(",
"Response",
"response",
")",
"{",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback",
".",
"onCompleted",
"(",
"typedListFromResponse",
"(",
"response",
",",
"GraphPlace",
".",
"class",
")",
",",
"response",
")",
";",
"}",
"}",
"}",
";",
"return",
"new",
"Request",
"(",
"session",
",",
"SEARCH",
",",
"parameters",
",",
"HttpMethod",
".",
"GET",
",",
"wrapper",
")",
";",
"}"
] | Creates a new Request that is configured to perform a search for places near a specified location via the Graph
API. At least one of location or searchText must be specified.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param location
the location around which to search; only the latitude and longitude components of the location are
meaningful
@param radiusInMeters
the radius around the location to search, specified in meters; this is ignored if
no location is specified
@param resultsLimit
the maximum number of results to return
@param searchText
optional text to search for as part of the name or type of an object
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute
@throws FacebookException If neither location nor searchText is specified | [
"Creates",
"a",
"new",
"Request",
"that",
"is",
"configured",
"to",
"perform",
"a",
"search",
"for",
"places",
"near",
"a",
"specified",
"location",
"via",
"the",
"Graph",
"API",
".",
"At",
"least",
"one",
"of",
"location",
"or",
"searchText",
"must",
"be",
"specified",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L399-L427 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newPostOpenGraphActionRequest | public static Request newPostOpenGraphActionRequest(Session session, OpenGraphAction openGraphAction,
Callback callback) {
if (openGraphAction == null) {
throw new FacebookException("openGraphAction cannot be null");
}
if (Utility.isNullOrEmpty(openGraphAction.getType())) {
throw new FacebookException("openGraphAction must have non-null 'type' property");
}
String path = String.format(MY_ACTION_FORMAT, openGraphAction.getType());
return newPostRequest(session, path, openGraphAction, callback);
} | java | public static Request newPostOpenGraphActionRequest(Session session, OpenGraphAction openGraphAction,
Callback callback) {
if (openGraphAction == null) {
throw new FacebookException("openGraphAction cannot be null");
}
if (Utility.isNullOrEmpty(openGraphAction.getType())) {
throw new FacebookException("openGraphAction must have non-null 'type' property");
}
String path = String.format(MY_ACTION_FORMAT, openGraphAction.getType());
return newPostRequest(session, path, openGraphAction, callback);
} | [
"public",
"static",
"Request",
"newPostOpenGraphActionRequest",
"(",
"Session",
"session",
",",
"OpenGraphAction",
"openGraphAction",
",",
"Callback",
"callback",
")",
"{",
"if",
"(",
"openGraphAction",
"==",
"null",
")",
"{",
"throw",
"new",
"FacebookException",
"(",
"\"openGraphAction cannot be null\"",
")",
";",
"}",
"if",
"(",
"Utility",
".",
"isNullOrEmpty",
"(",
"openGraphAction",
".",
"getType",
"(",
")",
")",
")",
"{",
"throw",
"new",
"FacebookException",
"(",
"\"openGraphAction must have non-null 'type' property\"",
")",
";",
"}",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"MY_ACTION_FORMAT",
",",
"openGraphAction",
".",
"getType",
"(",
")",
")",
";",
"return",
"newPostRequest",
"(",
"session",
",",
"path",
",",
"openGraphAction",
",",
"callback",
")",
";",
"}"
] | Creates a new Request configured to publish an Open Graph action.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param openGraphAction
the Open Graph object to create; must not be null, and must have a non-empty 'type'
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"publish",
"an",
"Open",
"Graph",
"action",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L742-L753 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.newDeleteObjectRequest | public static Request newDeleteObjectRequest(Session session, String id, Callback callback) {
return new Request(session, id, null, HttpMethod.DELETE, callback);
} | java | public static Request newDeleteObjectRequest(Session session, String id, Callback callback) {
return new Request(session, id, null, HttpMethod.DELETE, callback);
} | [
"public",
"static",
"Request",
"newDeleteObjectRequest",
"(",
"Session",
"session",
",",
"String",
"id",
",",
"Callback",
"callback",
")",
"{",
"return",
"new",
"Request",
"(",
"session",
",",
"id",
",",
"null",
",",
"HttpMethod",
".",
"DELETE",
",",
"callback",
")",
";",
"}"
] | Creates a new Request configured to delete a resource through the Graph API.
@param session
the Session to use, or null; if non-null, the session must be in an opened state
@param id
the id of the object to delete
@param callback
a callback that will be called when the request is completed to handle success or error conditions
@return a Request that is ready to execute | [
"Creates",
"a",
"new",
"Request",
"configured",
"to",
"delete",
"a",
"resource",
"through",
"the",
"Graph",
"API",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L766-L768 | train |
anotheria/configureme | src/main/java/org/configureme/sources/ConfigurationSourceKey.java | ConfigurationSourceKey.propertyFile | public static final ConfigurationSourceKey propertyFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.PROPERTIES, name);
} | java | public static final ConfigurationSourceKey propertyFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.PROPERTIES, name);
} | [
"public",
"static",
"final",
"ConfigurationSourceKey",
"propertyFile",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"ConfigurationSourceKey",
"(",
"Type",
".",
"FILE",
",",
"Format",
".",
"PROPERTIES",
",",
"name",
")",
";",
"}"
] | Creates a new configuration source key for property files.
@param name name of the property file.
@return a new configuration source key instance for property files | [
"Creates",
"a",
"new",
"configuration",
"source",
"key",
"for",
"property",
"files",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/sources/ConfigurationSourceKey.java#L201-L203 | train |
anotheria/configureme | src/main/java/org/configureme/sources/ConfigurationSourceKey.java | ConfigurationSourceKey.xmlFile | public static final ConfigurationSourceKey xmlFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.XML, name);
} | java | public static final ConfigurationSourceKey xmlFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.XML, name);
} | [
"public",
"static",
"final",
"ConfigurationSourceKey",
"xmlFile",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"ConfigurationSourceKey",
"(",
"Type",
".",
"FILE",
",",
"Format",
".",
"XML",
",",
"name",
")",
";",
"}"
] | Creates a new configuration source key for xml files.
@param name name of the xml file.
@return a new configuration source key instance for xml files | [
"Creates",
"a",
"new",
"configuration",
"source",
"key",
"for",
"xml",
"files",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/sources/ConfigurationSourceKey.java#L211-L213 | train |
anotheria/configureme | src/main/java/org/configureme/sources/ConfigurationSourceKey.java | ConfigurationSourceKey.jsonFile | public static final ConfigurationSourceKey jsonFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.JSON, name);
} | java | public static final ConfigurationSourceKey jsonFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.JSON, name);
} | [
"public",
"static",
"final",
"ConfigurationSourceKey",
"jsonFile",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"ConfigurationSourceKey",
"(",
"Type",
".",
"FILE",
",",
"Format",
".",
"JSON",
",",
"name",
")",
";",
"}"
] | Creates a new configuration source key for json files.
@param name name of the json file.
@return a new configuration source key instance for json files | [
"Creates",
"a",
"new",
"configuration",
"source",
"key",
"for",
"json",
"files",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/sources/ConfigurationSourceKey.java#L221-L223 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/internal/Utility.java | Utility.isSubset | public static <T> boolean isSubset(Collection<T> subset, Collection<T> superset) {
if ((superset == null) || (superset.size() == 0)) {
return ((subset == null) || (subset.size() == 0));
}
HashSet<T> hash = new HashSet<T>(superset);
for (T t : subset) {
if (!hash.contains(t)) {
return false;
}
}
return true;
} | java | public static <T> boolean isSubset(Collection<T> subset, Collection<T> superset) {
if ((superset == null) || (superset.size() == 0)) {
return ((subset == null) || (subset.size() == 0));
}
HashSet<T> hash = new HashSet<T>(superset);
for (T t : subset) {
if (!hash.contains(t)) {
return false;
}
}
return true;
} | [
"public",
"static",
"<",
"T",
">",
"boolean",
"isSubset",
"(",
"Collection",
"<",
"T",
">",
"subset",
",",
"Collection",
"<",
"T",
">",
"superset",
")",
"{",
"if",
"(",
"(",
"superset",
"==",
"null",
")",
"||",
"(",
"superset",
".",
"size",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
"(",
"(",
"subset",
"==",
"null",
")",
"||",
"(",
"subset",
".",
"size",
"(",
")",
"==",
"0",
")",
")",
";",
"}",
"HashSet",
"<",
"T",
">",
"hash",
"=",
"new",
"HashSet",
"<",
"T",
">",
"(",
"superset",
")",
";",
"for",
"(",
"T",
"t",
":",
"subset",
")",
"{",
"if",
"(",
"!",
"hash",
".",
"contains",
"(",
"t",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | the same. | [
"the",
"same",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/internal/Utility.java#L116-L128 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/internal/ImageResponseCache.java | ImageResponseCache.getCachedImageStream | static InputStream getCachedImageStream(URI url, Context context) {
InputStream imageStream = null;
if (url != null) {
if (isCDNURL(url)) {
try {
FileLruCache cache = getCache(context);
imageStream = cache.get(url.toString());
} catch (IOException e) {
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, e.toString());
}
}
}
return imageStream;
} | java | static InputStream getCachedImageStream(URI url, Context context) {
InputStream imageStream = null;
if (url != null) {
if (isCDNURL(url)) {
try {
FileLruCache cache = getCache(context);
imageStream = cache.get(url.toString());
} catch (IOException e) {
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, e.toString());
}
}
}
return imageStream;
} | [
"static",
"InputStream",
"getCachedImageStream",
"(",
"URI",
"url",
",",
"Context",
"context",
")",
"{",
"InputStream",
"imageStream",
"=",
"null",
";",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
"if",
"(",
"isCDNURL",
"(",
"url",
")",
")",
"{",
"try",
"{",
"FileLruCache",
"cache",
"=",
"getCache",
"(",
"context",
")",
";",
"imageStream",
"=",
"cache",
".",
"get",
"(",
"url",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"Logger",
".",
"log",
"(",
"LoggingBehavior",
".",
"CACHE",
",",
"Log",
".",
"WARN",
",",
"TAG",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"imageStream",
";",
"}"
] | Does not throw if there was an error. | [
"Does",
"not",
"throw",
"if",
"there",
"was",
"an",
"error",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/internal/ImageResponseCache.java#L45-L59 | train |
anotheria/configureme | src/main/java/org/configureme/environments/DynamicEnvironment.java | DynamicEnvironment.reduceThis | public void reduceThis(){
if (elements==null || elements.isEmpty())
throw new AssertionError("Can't reduce this environment");
elements.remove(elements.size()-1);
} | java | public void reduceThis(){
if (elements==null || elements.isEmpty())
throw new AssertionError("Can't reduce this environment");
elements.remove(elements.size()-1);
} | [
"public",
"void",
"reduceThis",
"(",
")",
"{",
"if",
"(",
"elements",
"==",
"null",
"||",
"elements",
".",
"isEmpty",
"(",
")",
")",
"throw",
"new",
"AssertionError",
"(",
"\"Can't reduce this environment\"",
")",
";",
"elements",
".",
"remove",
"(",
"elements",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}"
] | Reduces current environment. Modifies current object, hence NOT THREADSAFE. | [
"Reduces",
"current",
"environment",
".",
"Modifies",
"current",
"object",
"hence",
"NOT",
"THREADSAFE",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/environments/DynamicEnvironment.java#L100-L104 | train |
anotheria/configureme | src/main/java/org/configureme/environments/DynamicEnvironment.java | DynamicEnvironment.parse | public static Environment parse(final String s){
if (s==null || s.isEmpty() || s.trim().isEmpty())
return GlobalEnvironment.INSTANCE;
final String[] tokens = StringUtils.tokenize(s, '_');
final DynamicEnvironment env = new DynamicEnvironment();
for (final String t : tokens) {
env.add(t);
}
return env;
} | java | public static Environment parse(final String s){
if (s==null || s.isEmpty() || s.trim().isEmpty())
return GlobalEnvironment.INSTANCE;
final String[] tokens = StringUtils.tokenize(s, '_');
final DynamicEnvironment env = new DynamicEnvironment();
for (final String t : tokens) {
env.add(t);
}
return env;
} | [
"public",
"static",
"Environment",
"parse",
"(",
"final",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
"||",
"s",
".",
"isEmpty",
"(",
")",
"||",
"s",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"return",
"GlobalEnvironment",
".",
"INSTANCE",
";",
"final",
"String",
"[",
"]",
"tokens",
"=",
"StringUtils",
".",
"tokenize",
"(",
"s",
",",
"'",
"'",
")",
";",
"final",
"DynamicEnvironment",
"env",
"=",
"new",
"DynamicEnvironment",
"(",
")",
";",
"for",
"(",
"final",
"String",
"t",
":",
"tokens",
")",
"{",
"env",
".",
"add",
"(",
"t",
")",
";",
"}",
"return",
"env",
";",
"}"
] | Parses a string and creates a new Environment which corresponds the string.
@param s string to parse
@return new Environment which corresponds the string | [
"Parses",
"a",
"string",
"and",
"creates",
"a",
"new",
"Environment",
"which",
"corresponds",
"the",
"string",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/environments/DynamicEnvironment.java#L137-L146 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/internal/ImageDownloader.java | ImageDownloader.downloadAsync | public static void downloadAsync(ImageRequest request) {
if (request == null) {
return;
}
// NOTE: This is the ONLY place where the original request's Url is read. From here on,
// we will keep track of the Url separately. This is because we might be dealing with a
// redirect response and the Url might change. We can't create our own new ImageRequests
// for these changed Urls since the caller might be doing some book-keeping with the request's
// object reference. So we keep the old references and just map them to new urls in the downloader
RequestKey key = new RequestKey(request.getImageUri(), request.getCallerTag());
synchronized (pendingRequests) {
DownloaderContext downloaderContext = pendingRequests.get(key);
if (downloaderContext != null) {
downloaderContext.request = request;
downloaderContext.isCancelled = false;
downloaderContext.workItem.moveToFront();
} else {
enqueueCacheRead(request, key, request.isCachedRedirectAllowed());
}
}
} | java | public static void downloadAsync(ImageRequest request) {
if (request == null) {
return;
}
// NOTE: This is the ONLY place where the original request's Url is read. From here on,
// we will keep track of the Url separately. This is because we might be dealing with a
// redirect response and the Url might change. We can't create our own new ImageRequests
// for these changed Urls since the caller might be doing some book-keeping with the request's
// object reference. So we keep the old references and just map them to new urls in the downloader
RequestKey key = new RequestKey(request.getImageUri(), request.getCallerTag());
synchronized (pendingRequests) {
DownloaderContext downloaderContext = pendingRequests.get(key);
if (downloaderContext != null) {
downloaderContext.request = request;
downloaderContext.isCancelled = false;
downloaderContext.workItem.moveToFront();
} else {
enqueueCacheRead(request, key, request.isCachedRedirectAllowed());
}
}
} | [
"public",
"static",
"void",
"downloadAsync",
"(",
"ImageRequest",
"request",
")",
"{",
"if",
"(",
"request",
"==",
"null",
")",
"{",
"return",
";",
"}",
"// NOTE: This is the ONLY place where the original request's Url is read. From here on,",
"// we will keep track of the Url separately. This is because we might be dealing with a",
"// redirect response and the Url might change. We can't create our own new ImageRequests",
"// for these changed Urls since the caller might be doing some book-keeping with the request's",
"// object reference. So we keep the old references and just map them to new urls in the downloader",
"RequestKey",
"key",
"=",
"new",
"RequestKey",
"(",
"request",
".",
"getImageUri",
"(",
")",
",",
"request",
".",
"getCallerTag",
"(",
")",
")",
";",
"synchronized",
"(",
"pendingRequests",
")",
"{",
"DownloaderContext",
"downloaderContext",
"=",
"pendingRequests",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"downloaderContext",
"!=",
"null",
")",
"{",
"downloaderContext",
".",
"request",
"=",
"request",
";",
"downloaderContext",
".",
"isCancelled",
"=",
"false",
";",
"downloaderContext",
".",
"workItem",
".",
"moveToFront",
"(",
")",
";",
"}",
"else",
"{",
"enqueueCacheRead",
"(",
"request",
",",
"key",
",",
"request",
".",
"isCachedRedirectAllowed",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Downloads the image specified in the passed in request.
If a callback is specified, it is guaranteed to be invoked on the calling thread.
@param request Request to process | [
"Downloads",
"the",
"image",
"specified",
"in",
"the",
"passed",
"in",
"request",
".",
"If",
"a",
"callback",
"is",
"specified",
"it",
"is",
"guaranteed",
"to",
"be",
"invoked",
"on",
"the",
"calling",
"thread",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/internal/ImageDownloader.java#L50-L71 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppEventsLogger.java | AppEventsLogger.newLogger | public static AppEventsLogger newLogger(Context context, String applicationId) {
return new AppEventsLogger(context, applicationId, null);
} | java | public static AppEventsLogger newLogger(Context context, String applicationId) {
return new AppEventsLogger(context, applicationId, null);
} | [
"public",
"static",
"AppEventsLogger",
"newLogger",
"(",
"Context",
"context",
",",
"String",
"applicationId",
")",
"{",
"return",
"new",
"AppEventsLogger",
"(",
"context",
",",
"applicationId",
",",
"null",
")",
";",
"}"
] | Build an AppEventsLogger instance to log events that are attributed to the application but not to
any particular Session.
@param context Used to access the attributionId for non-authenticated users.
@param applicationId Explicitly specified Facebook applicationId to log events against. If null, the default
app ID specified
in the package metadata will be used.
@return AppEventsLogger instance to invoke log* methods on. | [
"Build",
"an",
"AppEventsLogger",
"instance",
"to",
"log",
"events",
"that",
"are",
"attributed",
"to",
"the",
"application",
"but",
"not",
"to",
"any",
"particular",
"Session",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppEventsLogger.java#L385-L387 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppEventsLogger.java | AppEventsLogger.logEvent | public void logEvent(String eventName, Bundle parameters) {
logEvent(eventName, null, parameters, false);
} | java | public void logEvent(String eventName, Bundle parameters) {
logEvent(eventName, null, parameters, false);
} | [
"public",
"void",
"logEvent",
"(",
"String",
"eventName",
",",
"Bundle",
"parameters",
")",
"{",
"logEvent",
"(",
"eventName",
",",
"null",
",",
"parameters",
",",
"false",
")",
";",
"}"
] | Log an app event with the specified name and set of parameters.
@param eventName eventName used to denote the event. Choose amongst the EVENT_NAME_* constants in
{@link AppEventsConstants} when possible. Or create your own if none of the EVENT_NAME_*
constants are applicable.
Event names should be 40 characters or less, alphanumeric, and can include spaces, underscores
or hyphens, but mustn't have a space or hyphen as the first character. Any given app should
have no more than ~300 distinct event names.
@param parameters A Bundle of parameters to log with the event. Insights will allow looking at the logs of these
events via different parameter values. You can log on the order of 10 parameters with each
distinct eventName. It's advisable to keep the number of unique values provided for each
parameter in the, at most, thousands. As an example, don't attempt to provide a unique
parameter value for each unique user in your app. You won't get meaningful aggregate reporting
on so many parameter values. The values in the bundles should be Strings or numeric values. | [
"Log",
"an",
"app",
"event",
"with",
"the",
"specified",
"name",
"and",
"set",
"of",
"parameters",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppEventsLogger.java#L470-L472 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppEventsLogger.java | AppEventsLogger.logEvent | public void logEvent(String eventName, double valueToSum, Bundle parameters) {
logEvent(eventName, valueToSum, parameters, false);
} | java | public void logEvent(String eventName, double valueToSum, Bundle parameters) {
logEvent(eventName, valueToSum, parameters, false);
} | [
"public",
"void",
"logEvent",
"(",
"String",
"eventName",
",",
"double",
"valueToSum",
",",
"Bundle",
"parameters",
")",
"{",
"logEvent",
"(",
"eventName",
",",
"valueToSum",
",",
"parameters",
",",
"false",
")",
";",
"}"
] | Log an app event with the specified name, supplied value, and set of parameters.
@param eventName eventName used to denote the event. Choose amongst the EVENT_NAME_* constants in
{@link AppEventsConstants} when possible. Or create your own if none of the EVENT_NAME_*
constants are applicable.
Event names should be 40 characters or less, alphanumeric, and can include spaces, underscores
or hyphens, but mustn't have a space or hyphen as the first character. Any given app should
have no more than ~300 distinct event names.
@param valueToSum a value to associate with the event which will be summed up in Insights for across all
instances of the event, so that average values can be determined, etc.
@param parameters A Bundle of parameters to log with the event. Insights will allow looking at the logs of these
events via different parameter values. You can log on the order of 10 parameters with each
distinct eventName. It's advisable to keep the number of unique values provided for each
parameter in the, at most, thousands. As an example, don't attempt to provide a unique
parameter value for each unique user in your app. You won't get meaningful aggregate reporting
on so many parameter values. The values in the bundles should be Strings or numeric values. | [
"Log",
"an",
"app",
"event",
"with",
"the",
"specified",
"name",
"supplied",
"value",
"and",
"set",
"of",
"parameters",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppEventsLogger.java#L492-L494 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppEventsLogger.java | AppEventsLogger.logPurchase | public void logPurchase(BigDecimal purchaseAmount, Currency currency, Bundle parameters) {
if (purchaseAmount == null) {
notifyDeveloperError("purchaseAmount cannot be null");
return;
} else if (currency == null) {
notifyDeveloperError("currency cannot be null");
return;
}
if (parameters == null) {
parameters = new Bundle();
}
parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, currency.getCurrencyCode());
logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, purchaseAmount.doubleValue(), parameters);
eagerFlush();
} | java | public void logPurchase(BigDecimal purchaseAmount, Currency currency, Bundle parameters) {
if (purchaseAmount == null) {
notifyDeveloperError("purchaseAmount cannot be null");
return;
} else if (currency == null) {
notifyDeveloperError("currency cannot be null");
return;
}
if (parameters == null) {
parameters = new Bundle();
}
parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, currency.getCurrencyCode());
logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, purchaseAmount.doubleValue(), parameters);
eagerFlush();
} | [
"public",
"void",
"logPurchase",
"(",
"BigDecimal",
"purchaseAmount",
",",
"Currency",
"currency",
",",
"Bundle",
"parameters",
")",
"{",
"if",
"(",
"purchaseAmount",
"==",
"null",
")",
"{",
"notifyDeveloperError",
"(",
"\"purchaseAmount cannot be null\"",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"currency",
"==",
"null",
")",
"{",
"notifyDeveloperError",
"(",
"\"currency cannot be null\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"parameters",
"==",
"null",
")",
"{",
"parameters",
"=",
"new",
"Bundle",
"(",
")",
";",
"}",
"parameters",
".",
"putString",
"(",
"AppEventsConstants",
".",
"EVENT_PARAM_CURRENCY",
",",
"currency",
".",
"getCurrencyCode",
"(",
")",
")",
";",
"logEvent",
"(",
"AppEventsConstants",
".",
"EVENT_NAME_PURCHASED",
",",
"purchaseAmount",
".",
"doubleValue",
"(",
")",
",",
"parameters",
")",
";",
"eagerFlush",
"(",
")",
";",
"}"
] | Logs a purchase event with Facebook, in the specified amount and with the specified currency. Additional
detail about the purchase can be passed in through the parameters bundle.
@param purchaseAmount Amount of purchase, in the currency specified by the 'currency' parameter. This value
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
@param currency Currency used to specify the amount.
@param parameters Arbitrary additional information for describing this event. Should have no more than
10 entries, and keys should be mostly consistent from one purchase event to the next. | [
"Logs",
"a",
"purchase",
"event",
"with",
"Facebook",
"in",
"the",
"specified",
"amount",
"and",
"with",
"the",
"specified",
"currency",
".",
"Additional",
"detail",
"about",
"the",
"purchase",
"can",
"be",
"passed",
"in",
"through",
"the",
"parameters",
"bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppEventsLogger.java#L517-L534 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppEventsLogger.java | AppEventsLogger.logSdkEvent | public void logSdkEvent(String eventName, Double valueToSum, Bundle parameters) {
logEvent(eventName, valueToSum, parameters, true);
} | java | public void logSdkEvent(String eventName, Double valueToSum, Bundle parameters) {
logEvent(eventName, valueToSum, parameters, true);
} | [
"public",
"void",
"logSdkEvent",
"(",
"String",
"eventName",
",",
"Double",
"valueToSum",
",",
"Bundle",
"parameters",
")",
"{",
"logEvent",
"(",
"eventName",
",",
"valueToSum",
",",
"parameters",
",",
"true",
")",
";",
"}"
] | This method is intended only for internal use by the Facebook SDK and other use is unsupported. | [
"This",
"method",
"is",
"intended",
"only",
"for",
"internal",
"use",
"by",
"the",
"Facebook",
"SDK",
"and",
"other",
"use",
"is",
"unsupported",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppEventsLogger.java#L564-L566 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppEventsLogger.java | AppEventsLogger.getSessionEventsState | private static SessionEventsState getSessionEventsState(Context context, AccessTokenAppIdPair accessTokenAppId) {
// Do this work outside of the lock to prevent deadlocks in implementation of
// AdvertisingIdClient.getAdvertisingIdInfo, because that implementation blocks waiting on the main thread,
// which may also grab this staticLock.
SessionEventsState state = stateMap.get(accessTokenAppId);
AttributionIdentifiers attributionIdentifiers = null;
if (state == null) {
// Retrieve attributionId, but we will only send it if attribution is supported for the app.
attributionIdentifiers = AttributionIdentifiers.getAttributionIdentifiers(context);
}
synchronized (staticLock) {
// Check state again while we're locked.
state = stateMap.get(accessTokenAppId);
if (state == null) {
state = new SessionEventsState(attributionIdentifiers, context.getPackageName(), hashedDeviceAndAppId);
stateMap.put(accessTokenAppId, state);
}
return state;
}
} | java | private static SessionEventsState getSessionEventsState(Context context, AccessTokenAppIdPair accessTokenAppId) {
// Do this work outside of the lock to prevent deadlocks in implementation of
// AdvertisingIdClient.getAdvertisingIdInfo, because that implementation blocks waiting on the main thread,
// which may also grab this staticLock.
SessionEventsState state = stateMap.get(accessTokenAppId);
AttributionIdentifiers attributionIdentifiers = null;
if (state == null) {
// Retrieve attributionId, but we will only send it if attribution is supported for the app.
attributionIdentifiers = AttributionIdentifiers.getAttributionIdentifiers(context);
}
synchronized (staticLock) {
// Check state again while we're locked.
state = stateMap.get(accessTokenAppId);
if (state == null) {
state = new SessionEventsState(attributionIdentifiers, context.getPackageName(), hashedDeviceAndAppId);
stateMap.put(accessTokenAppId, state);
}
return state;
}
} | [
"private",
"static",
"SessionEventsState",
"getSessionEventsState",
"(",
"Context",
"context",
",",
"AccessTokenAppIdPair",
"accessTokenAppId",
")",
"{",
"// Do this work outside of the lock to prevent deadlocks in implementation of",
"// AdvertisingIdClient.getAdvertisingIdInfo, because that implementation blocks waiting on the main thread,",
"// which may also grab this staticLock.",
"SessionEventsState",
"state",
"=",
"stateMap",
".",
"get",
"(",
"accessTokenAppId",
")",
";",
"AttributionIdentifiers",
"attributionIdentifiers",
"=",
"null",
";",
"if",
"(",
"state",
"==",
"null",
")",
"{",
"// Retrieve attributionId, but we will only send it if attribution is supported for the app.",
"attributionIdentifiers",
"=",
"AttributionIdentifiers",
".",
"getAttributionIdentifiers",
"(",
"context",
")",
";",
"}",
"synchronized",
"(",
"staticLock",
")",
"{",
"// Check state again while we're locked.",
"state",
"=",
"stateMap",
".",
"get",
"(",
"accessTokenAppId",
")",
";",
"if",
"(",
"state",
"==",
"null",
")",
"{",
"state",
"=",
"new",
"SessionEventsState",
"(",
"attributionIdentifiers",
",",
"context",
".",
"getPackageName",
"(",
")",
",",
"hashedDeviceAndAppId",
")",
";",
"stateMap",
".",
"put",
"(",
"accessTokenAppId",
",",
"state",
")",
";",
"}",
"return",
"state",
";",
"}",
"}"
] | Creates a new SessionEventsState if not already in the map. | [
"Creates",
"a",
"new",
"SessionEventsState",
"if",
"not",
"already",
"in",
"the",
"map",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppEventsLogger.java#L731-L751 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppEventsLogger.java | AppEventsLogger.setSourceApplication | private static void setSourceApplication(Activity activity) {
ComponentName callingApplication = activity.getCallingActivity();
if (callingApplication != null) {
String callingApplicationPackage = callingApplication.getPackageName();
if (callingApplicationPackage.equals(activity.getPackageName())) {
// open by own app.
resetSourceApplication();
return;
}
sourceApplication = callingApplicationPackage;
}
// Tap icon to open an app will still get the old intent if the activity was opened by an intent before.
// Introduce an extra field in the intent to force clear the sourceApplication.
Intent openIntent = activity.getIntent();
if (openIntent == null || openIntent.getBooleanExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, false)) {
resetSourceApplication();
return;
}
Bundle applinkData = AppLinks.getAppLinkData(openIntent);
if (applinkData == null) {
resetSourceApplication();
return;
}
isOpenedByApplink = true;
Bundle applinkReferrerData = applinkData.getBundle("referer_app_link");
if (applinkReferrerData == null) {
sourceApplication = null;
return;
}
String applinkReferrerPackage = applinkReferrerData.getString("package");
sourceApplication = applinkReferrerPackage;
// Mark this intent has been used to avoid use this intent again and again.
openIntent.putExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, true);
return;
} | java | private static void setSourceApplication(Activity activity) {
ComponentName callingApplication = activity.getCallingActivity();
if (callingApplication != null) {
String callingApplicationPackage = callingApplication.getPackageName();
if (callingApplicationPackage.equals(activity.getPackageName())) {
// open by own app.
resetSourceApplication();
return;
}
sourceApplication = callingApplicationPackage;
}
// Tap icon to open an app will still get the old intent if the activity was opened by an intent before.
// Introduce an extra field in the intent to force clear the sourceApplication.
Intent openIntent = activity.getIntent();
if (openIntent == null || openIntent.getBooleanExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, false)) {
resetSourceApplication();
return;
}
Bundle applinkData = AppLinks.getAppLinkData(openIntent);
if (applinkData == null) {
resetSourceApplication();
return;
}
isOpenedByApplink = true;
Bundle applinkReferrerData = applinkData.getBundle("referer_app_link");
if (applinkReferrerData == null) {
sourceApplication = null;
return;
}
String applinkReferrerPackage = applinkReferrerData.getString("package");
sourceApplication = applinkReferrerPackage;
// Mark this intent has been used to avoid use this intent again and again.
openIntent.putExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, true);
return;
} | [
"private",
"static",
"void",
"setSourceApplication",
"(",
"Activity",
"activity",
")",
"{",
"ComponentName",
"callingApplication",
"=",
"activity",
".",
"getCallingActivity",
"(",
")",
";",
"if",
"(",
"callingApplication",
"!=",
"null",
")",
"{",
"String",
"callingApplicationPackage",
"=",
"callingApplication",
".",
"getPackageName",
"(",
")",
";",
"if",
"(",
"callingApplicationPackage",
".",
"equals",
"(",
"activity",
".",
"getPackageName",
"(",
")",
")",
")",
"{",
"// open by own app.",
"resetSourceApplication",
"(",
")",
";",
"return",
";",
"}",
"sourceApplication",
"=",
"callingApplicationPackage",
";",
"}",
"// Tap icon to open an app will still get the old intent if the activity was opened by an intent before.",
"// Introduce an extra field in the intent to force clear the sourceApplication.",
"Intent",
"openIntent",
"=",
"activity",
".",
"getIntent",
"(",
")",
";",
"if",
"(",
"openIntent",
"==",
"null",
"||",
"openIntent",
".",
"getBooleanExtra",
"(",
"SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT",
",",
"false",
")",
")",
"{",
"resetSourceApplication",
"(",
")",
";",
"return",
";",
"}",
"Bundle",
"applinkData",
"=",
"AppLinks",
".",
"getAppLinkData",
"(",
"openIntent",
")",
";",
"if",
"(",
"applinkData",
"==",
"null",
")",
"{",
"resetSourceApplication",
"(",
")",
";",
"return",
";",
"}",
"isOpenedByApplink",
"=",
"true",
";",
"Bundle",
"applinkReferrerData",
"=",
"applinkData",
".",
"getBundle",
"(",
"\"referer_app_link\"",
")",
";",
"if",
"(",
"applinkReferrerData",
"==",
"null",
")",
"{",
"sourceApplication",
"=",
"null",
";",
"return",
";",
"}",
"String",
"applinkReferrerPackage",
"=",
"applinkReferrerData",
".",
"getString",
"(",
"\"package\"",
")",
";",
"sourceApplication",
"=",
"applinkReferrerPackage",
";",
"// Mark this intent has been used to avoid use this intent again and again.",
"openIntent",
".",
"putExtra",
"(",
"SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT",
",",
"true",
")",
";",
"return",
";",
"}"
] | Source Application setters and getters | [
"Source",
"Application",
"setters",
"and",
"getters"
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppEventsLogger.java#L963-L1007 | train |
meridor/perspective-backend | perspective-sql/src/main/java/org/meridor/perspective/sql/impl/QueryPlannerImpl.java | QueryPlannerImpl.extractWhereConditions | private Pair<List<BooleanExpression>, Optional<BooleanExpression>> extractWhereConditions(SelectQueryAware selectQueryAware) {
List<BooleanExpression> whereConditions = new ArrayList<>();
Optional<BooleanExpression> whereExpressionCandidate = selectQueryAware.getWhereExpression();
if (whereExpressionCandidate.isPresent()) {
whereConditions.add(whereExpressionCandidate.get());
}
boolean noGroupByTaskExists = selectQueryAware.getGroupByExpressions().isEmpty();
Optional<BooleanExpression> havingExpressionCandidate = selectQueryAware.getHavingExpression();
if (havingExpressionCandidate.isPresent() && noGroupByTaskExists) {
whereConditions.add(havingExpressionCandidate.get());
return new Pair<>(whereConditions, Optional.empty());
} else {
return new Pair<>(whereConditions, havingExpressionCandidate);
}
} | java | private Pair<List<BooleanExpression>, Optional<BooleanExpression>> extractWhereConditions(SelectQueryAware selectQueryAware) {
List<BooleanExpression> whereConditions = new ArrayList<>();
Optional<BooleanExpression> whereExpressionCandidate = selectQueryAware.getWhereExpression();
if (whereExpressionCandidate.isPresent()) {
whereConditions.add(whereExpressionCandidate.get());
}
boolean noGroupByTaskExists = selectQueryAware.getGroupByExpressions().isEmpty();
Optional<BooleanExpression> havingExpressionCandidate = selectQueryAware.getHavingExpression();
if (havingExpressionCandidate.isPresent() && noGroupByTaskExists) {
whereConditions.add(havingExpressionCandidate.get());
return new Pair<>(whereConditions, Optional.empty());
} else {
return new Pair<>(whereConditions, havingExpressionCandidate);
}
} | [
"private",
"Pair",
"<",
"List",
"<",
"BooleanExpression",
">",
",",
"Optional",
"<",
"BooleanExpression",
">",
">",
"extractWhereConditions",
"(",
"SelectQueryAware",
"selectQueryAware",
")",
"{",
"List",
"<",
"BooleanExpression",
">",
"whereConditions",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Optional",
"<",
"BooleanExpression",
">",
"whereExpressionCandidate",
"=",
"selectQueryAware",
".",
"getWhereExpression",
"(",
")",
";",
"if",
"(",
"whereExpressionCandidate",
".",
"isPresent",
"(",
")",
")",
"{",
"whereConditions",
".",
"add",
"(",
"whereExpressionCandidate",
".",
"get",
"(",
")",
")",
";",
"}",
"boolean",
"noGroupByTaskExists",
"=",
"selectQueryAware",
".",
"getGroupByExpressions",
"(",
")",
".",
"isEmpty",
"(",
")",
";",
"Optional",
"<",
"BooleanExpression",
">",
"havingExpressionCandidate",
"=",
"selectQueryAware",
".",
"getHavingExpression",
"(",
")",
";",
"if",
"(",
"havingExpressionCandidate",
".",
"isPresent",
"(",
")",
"&&",
"noGroupByTaskExists",
")",
"{",
"whereConditions",
".",
"add",
"(",
"havingExpressionCandidate",
".",
"get",
"(",
")",
")",
";",
"return",
"new",
"Pair",
"<>",
"(",
"whereConditions",
",",
"Optional",
".",
"empty",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Pair",
"<>",
"(",
"whereConditions",
",",
"havingExpressionCandidate",
")",
";",
"}",
"}"
] | Deciding whether having clause can be moved to where clause | [
"Deciding",
"whether",
"having",
"clause",
"can",
"be",
"moved",
"to",
"where",
"clause"
] | 5f98083977a57115988678e97d1642ee83431258 | https://github.com/meridor/perspective-backend/blob/5f98083977a57115988678e97d1642ee83431258/perspective-sql/src/main/java/org/meridor/perspective/sql/impl/QueryPlannerImpl.java#L161-L177 | train |
meridor/perspective-backend | perspective-sql/src/main/java/org/meridor/perspective/sql/impl/QueryPlannerImpl.java | QueryPlannerImpl.optimizeDataSource | private Pair<DataSource, Optional<BooleanExpression>> optimizeDataSource(
DataSource originalDataSource,
List<BooleanExpression> originalWhereConditions,
Map<String, Object> selectionMap,
Map<String, String> tableAliases
) {
OptimizationContext optimizationContext = analyzeOriginalData(originalDataSource, originalWhereConditions, tableAliases);
DataSource optimizedDataSource = createOptimizedDataSource(originalDataSource, optimizationContext, selectionMap, tableAliases);
Optional<BooleanExpression> optimizedWhereCondition = createOptimizedWhereCondition(optimizationContext);
return new Pair<>(optimizedDataSource, optimizedWhereCondition);
} | java | private Pair<DataSource, Optional<BooleanExpression>> optimizeDataSource(
DataSource originalDataSource,
List<BooleanExpression> originalWhereConditions,
Map<String, Object> selectionMap,
Map<String, String> tableAliases
) {
OptimizationContext optimizationContext = analyzeOriginalData(originalDataSource, originalWhereConditions, tableAliases);
DataSource optimizedDataSource = createOptimizedDataSource(originalDataSource, optimizationContext, selectionMap, tableAliases);
Optional<BooleanExpression> optimizedWhereCondition = createOptimizedWhereCondition(optimizationContext);
return new Pair<>(optimizedDataSource, optimizedWhereCondition);
} | [
"private",
"Pair",
"<",
"DataSource",
",",
"Optional",
"<",
"BooleanExpression",
">",
">",
"optimizeDataSource",
"(",
"DataSource",
"originalDataSource",
",",
"List",
"<",
"BooleanExpression",
">",
"originalWhereConditions",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"selectionMap",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tableAliases",
")",
"{",
"OptimizationContext",
"optimizationContext",
"=",
"analyzeOriginalData",
"(",
"originalDataSource",
",",
"originalWhereConditions",
",",
"tableAliases",
")",
";",
"DataSource",
"optimizedDataSource",
"=",
"createOptimizedDataSource",
"(",
"originalDataSource",
",",
"optimizationContext",
",",
"selectionMap",
",",
"tableAliases",
")",
";",
"Optional",
"<",
"BooleanExpression",
">",
"optimizedWhereCondition",
"=",
"createOptimizedWhereCondition",
"(",
"optimizationContext",
")",
";",
"return",
"new",
"Pair",
"<>",
"(",
"optimizedDataSource",
",",
"optimizedWhereCondition",
")",
";",
"}"
] | Deciding whether parts of where clause can be moved to data sources | [
"Deciding",
"whether",
"parts",
"of",
"where",
"clause",
"can",
"be",
"moved",
"to",
"data",
"sources"
] | 5f98083977a57115988678e97d1642ee83431258 | https://github.com/meridor/perspective-backend/blob/5f98083977a57115988678e97d1642ee83431258/perspective-sql/src/main/java/org/meridor/perspective/sql/impl/QueryPlannerImpl.java#L180-L194 | train |
anotheria/configureme | src/main/java/org/configureme/sources/configurationrepository/ReplyObject.java | ReplyObject.success | public static ReplyObject success(final String name, final Object result) {
final ReplyObject ret = new ReplyObject(name, result);
ret.success = true;
return ret;
} | java | public static ReplyObject success(final String name, final Object result) {
final ReplyObject ret = new ReplyObject(name, result);
ret.success = true;
return ret;
} | [
"public",
"static",
"ReplyObject",
"success",
"(",
"final",
"String",
"name",
",",
"final",
"Object",
"result",
")",
"{",
"final",
"ReplyObject",
"ret",
"=",
"new",
"ReplyObject",
"(",
"name",
",",
"result",
")",
";",
"ret",
".",
"success",
"=",
"true",
";",
"return",
"ret",
";",
"}"
] | Factory method that creates a new reply object for successful request.
@param name a {@link java.lang.String} object.
@param result a {@link java.lang.Object} object.
@return a {@link org.configureme.sources.configurationrepository.ReplyObject} object. | [
"Factory",
"method",
"that",
"creates",
"a",
"new",
"reply",
"object",
"for",
"successful",
"request",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/sources/configurationrepository/ReplyObject.java#L71-L75 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Session.java | Session.close | public final void close() {
synchronized (this.lock) {
final SessionState oldState = this.state;
switch (this.state) {
case CREATED:
case OPENING:
this.state = SessionState.CLOSED_LOGIN_FAILED;
postStateChange(oldState, this.state, new FacebookException(
"Log in attempt aborted."));
break;
case CREATED_TOKEN_LOADED:
case OPENED:
case OPENED_TOKEN_UPDATED:
this.state = SessionState.CLOSED;
postStateChange(oldState, this.state, null);
break;
case CLOSED:
case CLOSED_LOGIN_FAILED:
break;
}
}
} | java | public final void close() {
synchronized (this.lock) {
final SessionState oldState = this.state;
switch (this.state) {
case CREATED:
case OPENING:
this.state = SessionState.CLOSED_LOGIN_FAILED;
postStateChange(oldState, this.state, new FacebookException(
"Log in attempt aborted."));
break;
case CREATED_TOKEN_LOADED:
case OPENED:
case OPENED_TOKEN_UPDATED:
this.state = SessionState.CLOSED;
postStateChange(oldState, this.state, null);
break;
case CLOSED:
case CLOSED_LOGIN_FAILED:
break;
}
}
} | [
"public",
"final",
"void",
"close",
"(",
")",
"{",
"synchronized",
"(",
"this",
".",
"lock",
")",
"{",
"final",
"SessionState",
"oldState",
"=",
"this",
".",
"state",
";",
"switch",
"(",
"this",
".",
"state",
")",
"{",
"case",
"CREATED",
":",
"case",
"OPENING",
":",
"this",
".",
"state",
"=",
"SessionState",
".",
"CLOSED_LOGIN_FAILED",
";",
"postStateChange",
"(",
"oldState",
",",
"this",
".",
"state",
",",
"new",
"FacebookException",
"(",
"\"Log in attempt aborted.\"",
")",
")",
";",
"break",
";",
"case",
"CREATED_TOKEN_LOADED",
":",
"case",
"OPENED",
":",
"case",
"OPENED_TOKEN_UPDATED",
":",
"this",
".",
"state",
"=",
"SessionState",
".",
"CLOSED",
";",
"postStateChange",
"(",
"oldState",
",",
"this",
".",
"state",
",",
"null",
")",
";",
"break",
";",
"case",
"CLOSED",
":",
"case",
"CLOSED_LOGIN_FAILED",
":",
"break",
";",
"}",
"}",
"}"
] | Closes the local in-memory Session object, but does not clear the
persisted token cache. | [
"Closes",
"the",
"local",
"in",
"-",
"memory",
"Session",
"object",
"but",
"does",
"not",
"clear",
"the",
"persisted",
"token",
"cache",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Session.java#L767-L791 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Session.java | Session.closeAndClearTokenInformation | public final void closeAndClearTokenInformation() {
if (this.tokenCachingStrategy != null) {
this.tokenCachingStrategy.clear();
}
Utility.clearFacebookCookies(staticContext);
Utility.clearCaches(staticContext);
close();
} | java | public final void closeAndClearTokenInformation() {
if (this.tokenCachingStrategy != null) {
this.tokenCachingStrategy.clear();
}
Utility.clearFacebookCookies(staticContext);
Utility.clearCaches(staticContext);
close();
} | [
"public",
"final",
"void",
"closeAndClearTokenInformation",
"(",
")",
"{",
"if",
"(",
"this",
".",
"tokenCachingStrategy",
"!=",
"null",
")",
"{",
"this",
".",
"tokenCachingStrategy",
".",
"clear",
"(",
")",
";",
"}",
"Utility",
".",
"clearFacebookCookies",
"(",
"staticContext",
")",
";",
"Utility",
".",
"clearCaches",
"(",
"staticContext",
")",
";",
"close",
"(",
")",
";",
"}"
] | Closes the local in-memory Session object and clears any persisted token
cache related to the Session. | [
"Closes",
"the",
"local",
"in",
"-",
"memory",
"Session",
"object",
"and",
"clears",
"any",
"persisted",
"token",
"cache",
"related",
"to",
"the",
"Session",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Session.java#L797-L804 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Session.java | Session.addCallback | public final void addCallback(StatusCallback callback) {
synchronized (callbacks) {
if (callback != null && !callbacks.contains(callback)) {
callbacks.add(callback);
}
}
} | java | public final void addCallback(StatusCallback callback) {
synchronized (callbacks) {
if (callback != null && !callbacks.contains(callback)) {
callbacks.add(callback);
}
}
} | [
"public",
"final",
"void",
"addCallback",
"(",
"StatusCallback",
"callback",
")",
"{",
"synchronized",
"(",
"callbacks",
")",
"{",
"if",
"(",
"callback",
"!=",
"null",
"&&",
"!",
"callbacks",
".",
"contains",
"(",
"callback",
")",
")",
"{",
"callbacks",
".",
"add",
"(",
"callback",
")",
";",
"}",
"}",
"}"
] | Adds a callback that will be called when the state of this Session changes.
@param callback the callback | [
"Adds",
"a",
"callback",
"that",
"will",
"be",
"called",
"when",
"the",
"state",
"of",
"this",
"Session",
"changes",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Session.java#L811-L817 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Session.java | Session.saveSession | public static final void saveSession(Session session, Bundle bundle) {
if (bundle != null && session != null && !bundle.containsKey(SESSION_BUNDLE_SAVE_KEY)) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
new ObjectOutputStream(outputStream).writeObject(session);
} catch (IOException e) {
throw new FacebookException("Unable to save session.", e);
}
bundle.putByteArray(SESSION_BUNDLE_SAVE_KEY, outputStream.toByteArray());
bundle.putBundle(AUTH_BUNDLE_SAVE_KEY, session.authorizationBundle);
}
} | java | public static final void saveSession(Session session, Bundle bundle) {
if (bundle != null && session != null && !bundle.containsKey(SESSION_BUNDLE_SAVE_KEY)) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
new ObjectOutputStream(outputStream).writeObject(session);
} catch (IOException e) {
throw new FacebookException("Unable to save session.", e);
}
bundle.putByteArray(SESSION_BUNDLE_SAVE_KEY, outputStream.toByteArray());
bundle.putBundle(AUTH_BUNDLE_SAVE_KEY, session.authorizationBundle);
}
} | [
"public",
"static",
"final",
"void",
"saveSession",
"(",
"Session",
"session",
",",
"Bundle",
"bundle",
")",
"{",
"if",
"(",
"bundle",
"!=",
"null",
"&&",
"session",
"!=",
"null",
"&&",
"!",
"bundle",
".",
"containsKey",
"(",
"SESSION_BUNDLE_SAVE_KEY",
")",
")",
"{",
"ByteArrayOutputStream",
"outputStream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"try",
"{",
"new",
"ObjectOutputStream",
"(",
"outputStream",
")",
".",
"writeObject",
"(",
"session",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"FacebookException",
"(",
"\"Unable to save session.\"",
",",
"e",
")",
";",
"}",
"bundle",
".",
"putByteArray",
"(",
"SESSION_BUNDLE_SAVE_KEY",
",",
"outputStream",
".",
"toByteArray",
"(",
")",
")",
";",
"bundle",
".",
"putBundle",
"(",
"AUTH_BUNDLE_SAVE_KEY",
",",
"session",
".",
"authorizationBundle",
")",
";",
"}",
"}"
] | Save the Session object into the supplied Bundle. This method is intended to be called from an
Activity or Fragment's onSaveInstanceState method in order to preserve Sessions across Activity lifecycle events.
@param session the Session to save
@param bundle the Bundle to save the Session to | [
"Save",
"the",
"Session",
"object",
"into",
"the",
"supplied",
"Bundle",
".",
"This",
"method",
"is",
"intended",
"to",
"be",
"called",
"from",
"an",
"Activity",
"or",
"Fragment",
"s",
"onSaveInstanceState",
"method",
"in",
"order",
"to",
"preserve",
"Sessions",
"across",
"Activity",
"lifecycle",
"events",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Session.java#L877-L888 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Session.java | Session.restoreSession | public static final Session restoreSession(
Context context, TokenCachingStrategy cachingStrategy, StatusCallback callback, Bundle bundle) {
if (bundle == null) {
return null;
}
byte[] data = bundle.getByteArray(SESSION_BUNDLE_SAVE_KEY);
if (data != null) {
ByteArrayInputStream is = new ByteArrayInputStream(data);
try {
Session session = (Session) (new ObjectInputStream(is)).readObject();
initializeStaticContext(context);
if (cachingStrategy != null) {
session.tokenCachingStrategy = cachingStrategy;
} else {
session.tokenCachingStrategy = new SharedPreferencesTokenCachingStrategy(context);
}
if (callback != null) {
session.addCallback(callback);
}
session.authorizationBundle = bundle.getBundle(AUTH_BUNDLE_SAVE_KEY);
return session;
} catch (ClassNotFoundException e) {
Log.w(TAG, "Unable to restore session", e);
} catch (IOException e) {
Log.w(TAG, "Unable to restore session.", e);
}
}
return null;
} | java | public static final Session restoreSession(
Context context, TokenCachingStrategy cachingStrategy, StatusCallback callback, Bundle bundle) {
if (bundle == null) {
return null;
}
byte[] data = bundle.getByteArray(SESSION_BUNDLE_SAVE_KEY);
if (data != null) {
ByteArrayInputStream is = new ByteArrayInputStream(data);
try {
Session session = (Session) (new ObjectInputStream(is)).readObject();
initializeStaticContext(context);
if (cachingStrategy != null) {
session.tokenCachingStrategy = cachingStrategy;
} else {
session.tokenCachingStrategy = new SharedPreferencesTokenCachingStrategy(context);
}
if (callback != null) {
session.addCallback(callback);
}
session.authorizationBundle = bundle.getBundle(AUTH_BUNDLE_SAVE_KEY);
return session;
} catch (ClassNotFoundException e) {
Log.w(TAG, "Unable to restore session", e);
} catch (IOException e) {
Log.w(TAG, "Unable to restore session.", e);
}
}
return null;
} | [
"public",
"static",
"final",
"Session",
"restoreSession",
"(",
"Context",
"context",
",",
"TokenCachingStrategy",
"cachingStrategy",
",",
"StatusCallback",
"callback",
",",
"Bundle",
"bundle",
")",
"{",
"if",
"(",
"bundle",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"byte",
"[",
"]",
"data",
"=",
"bundle",
".",
"getByteArray",
"(",
"SESSION_BUNDLE_SAVE_KEY",
")",
";",
"if",
"(",
"data",
"!=",
"null",
")",
"{",
"ByteArrayInputStream",
"is",
"=",
"new",
"ByteArrayInputStream",
"(",
"data",
")",
";",
"try",
"{",
"Session",
"session",
"=",
"(",
"Session",
")",
"(",
"new",
"ObjectInputStream",
"(",
"is",
")",
")",
".",
"readObject",
"(",
")",
";",
"initializeStaticContext",
"(",
"context",
")",
";",
"if",
"(",
"cachingStrategy",
"!=",
"null",
")",
"{",
"session",
".",
"tokenCachingStrategy",
"=",
"cachingStrategy",
";",
"}",
"else",
"{",
"session",
".",
"tokenCachingStrategy",
"=",
"new",
"SharedPreferencesTokenCachingStrategy",
"(",
"context",
")",
";",
"}",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"session",
".",
"addCallback",
"(",
"callback",
")",
";",
"}",
"session",
".",
"authorizationBundle",
"=",
"bundle",
".",
"getBundle",
"(",
"AUTH_BUNDLE_SAVE_KEY",
")",
";",
"return",
"session",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"Log",
".",
"w",
"(",
"TAG",
",",
"\"Unable to restore session\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"Log",
".",
"w",
"(",
"TAG",
",",
"\"Unable to restore session.\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Restores the saved session from a Bundle, if any. Returns the restored Session or
null if it could not be restored. This method is intended to be called from an Activity or Fragment's
onCreate method when a Session has previously been saved into a Bundle via saveState to preserve a Session
across Activity lifecycle events.
@param context the Activity or Service creating the Session, must not be null
@param cachingStrategy the TokenCachingStrategy to use to load and store the token. If this is
null, a default token cachingStrategy that stores data in
SharedPreferences will be used
@param callback the callback to notify for Session state changes, can be null
@param bundle the bundle to restore the Session from
@return the restored Session, or null | [
"Restores",
"the",
"saved",
"session",
"from",
"a",
"Bundle",
"if",
"any",
".",
"Returns",
"the",
"restored",
"Session",
"or",
"null",
"if",
"it",
"could",
"not",
"be",
"restored",
".",
"This",
"method",
"is",
"intended",
"to",
"be",
"called",
"from",
"an",
"Activity",
"or",
"Fragment",
"s",
"onCreate",
"method",
"when",
"a",
"Session",
"has",
"previously",
"been",
"saved",
"into",
"a",
"Bundle",
"via",
"saveState",
"to",
"preserve",
"a",
"Session",
"across",
"Activity",
"lifecycle",
"events",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Session.java#L904-L932 | train |
dmerkushov/log-helper | src/main/java/ru/dmerkushov/loghelper/configure/loggerwrapper/LoggerWrapperConfigurator.java | LoggerWrapperConfigurator.getConfigurationOption | public Node getConfigurationOption (String optionName) {
NodeList children = configuration.getChildNodes ();
Node configurationOption = null;
for (int childIndex = 0; childIndex < children.getLength (); childIndex++) {
if (children.item (childIndex).getNodeName ().equals (optionName)) {
configurationOption = children.item (childIndex);
break;
}
}
return configurationOption;
} | java | public Node getConfigurationOption (String optionName) {
NodeList children = configuration.getChildNodes ();
Node configurationOption = null;
for (int childIndex = 0; childIndex < children.getLength (); childIndex++) {
if (children.item (childIndex).getNodeName ().equals (optionName)) {
configurationOption = children.item (childIndex);
break;
}
}
return configurationOption;
} | [
"public",
"Node",
"getConfigurationOption",
"(",
"String",
"optionName",
")",
"{",
"NodeList",
"children",
"=",
"configuration",
".",
"getChildNodes",
"(",
")",
";",
"Node",
"configurationOption",
"=",
"null",
";",
"for",
"(",
"int",
"childIndex",
"=",
"0",
";",
"childIndex",
"<",
"children",
".",
"getLength",
"(",
")",
";",
"childIndex",
"++",
")",
"{",
"if",
"(",
"children",
".",
"item",
"(",
"childIndex",
")",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"optionName",
")",
")",
"{",
"configurationOption",
"=",
"children",
".",
"item",
"(",
"childIndex",
")",
";",
"break",
";",
"}",
"}",
"return",
"configurationOption",
";",
"}"
] | Get a configuration option of this configurator.
@param optionName
@return The configuration option node. <code>null</code> if it does not exist | [
"Get",
"a",
"configuration",
"option",
"of",
"this",
"configurator",
"."
] | 3b7d3d30faa7f1437b27cd07c10fa579a995de23 | https://github.com/dmerkushov/log-helper/blob/3b7d3d30faa7f1437b27cd07c10fa579a995de23/src/main/java/ru/dmerkushov/loghelper/configure/loggerwrapper/LoggerWrapperConfigurator.java#L82-L92 | train |
dmerkushov/log-helper | src/main/java/ru/dmerkushov/loghelper/configure/loggerwrapper/LoggerWrapperConfigurator.java | LoggerWrapperConfigurator.getConfigurationOptionValue | public String getConfigurationOptionValue (String optionName, String defaultValue) {
String optionValue;
Node configurationOption = this.getConfigurationOption (optionName);
if (configurationOption != null) {
optionValue = configurationOption.getTextContent ();
} else {
optionValue = defaultValue;
}
return optionValue;
} | java | public String getConfigurationOptionValue (String optionName, String defaultValue) {
String optionValue;
Node configurationOption = this.getConfigurationOption (optionName);
if (configurationOption != null) {
optionValue = configurationOption.getTextContent ();
} else {
optionValue = defaultValue;
}
return optionValue;
} | [
"public",
"String",
"getConfigurationOptionValue",
"(",
"String",
"optionName",
",",
"String",
"defaultValue",
")",
"{",
"String",
"optionValue",
";",
"Node",
"configurationOption",
"=",
"this",
".",
"getConfigurationOption",
"(",
"optionName",
")",
";",
"if",
"(",
"configurationOption",
"!=",
"null",
")",
"{",
"optionValue",
"=",
"configurationOption",
".",
"getTextContent",
"(",
")",
";",
"}",
"else",
"{",
"optionValue",
"=",
"defaultValue",
";",
"}",
"return",
"optionValue",
";",
"}"
] | Get a configuration option value as String.
@param optionName
@param defaultValue
@return The configuration option node value, or <code>defaultValue</code> if it does not exist | [
"Get",
"a",
"configuration",
"option",
"value",
"as",
"String",
"."
] | 3b7d3d30faa7f1437b27cd07c10fa579a995de23 | https://github.com/dmerkushov/log-helper/blob/3b7d3d30faa7f1437b27cd07c10fa579a995de23/src/main/java/ru/dmerkushov/loghelper/configure/loggerwrapper/LoggerWrapperConfigurator.java#L100-L109 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/internal/FileLruCache.java | FileLruCache.interceptAndPut | public InputStream interceptAndPut(String key, InputStream input) throws IOException {
OutputStream output = openPutStream(key);
return new CopyingInputStream(input, output);
} | java | public InputStream interceptAndPut(String key, InputStream input) throws IOException {
OutputStream output = openPutStream(key);
return new CopyingInputStream(input, output);
} | [
"public",
"InputStream",
"interceptAndPut",
"(",
"String",
"key",
",",
"InputStream",
"input",
")",
"throws",
"IOException",
"{",
"OutputStream",
"output",
"=",
"openPutStream",
"(",
"key",
")",
";",
"return",
"new",
"CopyingInputStream",
"(",
"input",
",",
"output",
")",
";",
"}"
] | copy of input, and associate that data with key. | [
"copy",
"of",
"input",
"and",
"associate",
"that",
"data",
"with",
"key",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/internal/FileLruCache.java#L257-L260 | train |
A-pZ/struts2-thymeleaf3-plugin | src/main/java/serendip/struts/plugins/thymeleaf/spi/DefaultTemplateEngineProvider.java | DefaultTemplateEngineProvider.configure | public void configure() {
ServletContext servletContext = ServletActionContext.getServletContext();
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(servletContext);
templateResolver.setTemplateMode(templateMode);
templateResolver.setCharacterEncoding(characterEncoding);
templateResolver.setPrefix(prefix);
templateResolver.setSuffix(suffix);
templateResolver.setCacheable(cacheable);
templateResolver.setCacheTTLMs(cacheTtlMillis);
templateEngine.setTemplateResolver(templateResolver);
StrutsMessageResolver messageResolver = new StrutsMessageResolver();
templateEngine.setMessageResolver(new StrutsMessageResolver());
if (templateEngine instanceof SpringTemplateEngine) {
((SpringTemplateEngine) templateEngine).setMessageSource(messageResolver.getMessageSource());
}
// extension diarects.
FieldDialect fieldDialect = new FieldDialect(TemplateMode.HTML ,"sth");
templateEngine.addDialect(fieldDialect);
} | java | public void configure() {
ServletContext servletContext = ServletActionContext.getServletContext();
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(servletContext);
templateResolver.setTemplateMode(templateMode);
templateResolver.setCharacterEncoding(characterEncoding);
templateResolver.setPrefix(prefix);
templateResolver.setSuffix(suffix);
templateResolver.setCacheable(cacheable);
templateResolver.setCacheTTLMs(cacheTtlMillis);
templateEngine.setTemplateResolver(templateResolver);
StrutsMessageResolver messageResolver = new StrutsMessageResolver();
templateEngine.setMessageResolver(new StrutsMessageResolver());
if (templateEngine instanceof SpringTemplateEngine) {
((SpringTemplateEngine) templateEngine).setMessageSource(messageResolver.getMessageSource());
}
// extension diarects.
FieldDialect fieldDialect = new FieldDialect(TemplateMode.HTML ,"sth");
templateEngine.addDialect(fieldDialect);
} | [
"public",
"void",
"configure",
"(",
")",
"{",
"ServletContext",
"servletContext",
"=",
"ServletActionContext",
".",
"getServletContext",
"(",
")",
";",
"ServletContextTemplateResolver",
"templateResolver",
"=",
"new",
"ServletContextTemplateResolver",
"(",
"servletContext",
")",
";",
"templateResolver",
".",
"setTemplateMode",
"(",
"templateMode",
")",
";",
"templateResolver",
".",
"setCharacterEncoding",
"(",
"characterEncoding",
")",
";",
"templateResolver",
".",
"setPrefix",
"(",
"prefix",
")",
";",
"templateResolver",
".",
"setSuffix",
"(",
"suffix",
")",
";",
"templateResolver",
".",
"setCacheable",
"(",
"cacheable",
")",
";",
"templateResolver",
".",
"setCacheTTLMs",
"(",
"cacheTtlMillis",
")",
";",
"templateEngine",
".",
"setTemplateResolver",
"(",
"templateResolver",
")",
";",
"StrutsMessageResolver",
"messageResolver",
"=",
"new",
"StrutsMessageResolver",
"(",
")",
";",
"templateEngine",
".",
"setMessageResolver",
"(",
"new",
"StrutsMessageResolver",
"(",
")",
")",
";",
"if",
"(",
"templateEngine",
"instanceof",
"SpringTemplateEngine",
")",
"{",
"(",
"(",
"SpringTemplateEngine",
")",
"templateEngine",
")",
".",
"setMessageSource",
"(",
"messageResolver",
".",
"getMessageSource",
"(",
")",
")",
";",
"}",
"// extension diarects.\r",
"FieldDialect",
"fieldDialect",
"=",
"new",
"FieldDialect",
"(",
"TemplateMode",
".",
"HTML",
",",
"\"sth\"",
")",
";",
"templateEngine",
".",
"addDialect",
"(",
"fieldDialect",
")",
";",
"}"
] | Configure settings from the struts.xml or struts.properties, using
sensible defaults if values are not provided. | [
"Configure",
"settings",
"from",
"the",
"struts",
".",
"xml",
"or",
"struts",
".",
"properties",
"using",
"sensible",
"defaults",
"if",
"values",
"are",
"not",
"provided",
"."
] | 36a4609c1d0a36019784c6dba951c9b27dcc8802 | https://github.com/A-pZ/struts2-thymeleaf3-plugin/blob/36a4609c1d0a36019784c6dba951c9b27dcc8802/src/main/java/serendip/struts/plugins/thymeleaf/spi/DefaultTemplateEngineProvider.java#L65-L86 | train |
A-pZ/struts2-thymeleaf3-plugin | src/main/java/serendip/struts/plugins/thymeleaf/spi/DefaultTemplateEngineProvider.java | DefaultTemplateEngineProvider.setContainer | public void setContainer(Container container) {
this.container = container;
Map<String, TemplateEngine> map = new HashMap<String, TemplateEngine>();
// loading TemplateEngine class from DI Container.
Set<String> prefixes = container.getInstanceNames(TemplateEngine.class);
for (String prefix : prefixes) {
TemplateEngine engine = (TemplateEngine) container.getInstance(TemplateEngine.class, prefix);
map.put(prefix, engine);
}
this.templateEngines = Collections.unmodifiableMap(map);
} | java | public void setContainer(Container container) {
this.container = container;
Map<String, TemplateEngine> map = new HashMap<String, TemplateEngine>();
// loading TemplateEngine class from DI Container.
Set<String> prefixes = container.getInstanceNames(TemplateEngine.class);
for (String prefix : prefixes) {
TemplateEngine engine = (TemplateEngine) container.getInstance(TemplateEngine.class, prefix);
map.put(prefix, engine);
}
this.templateEngines = Collections.unmodifiableMap(map);
} | [
"public",
"void",
"setContainer",
"(",
"Container",
"container",
")",
"{",
"this",
".",
"container",
"=",
"container",
";",
"Map",
"<",
"String",
",",
"TemplateEngine",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"TemplateEngine",
">",
"(",
")",
";",
"// loading TemplateEngine class from DI Container.\r",
"Set",
"<",
"String",
">",
"prefixes",
"=",
"container",
".",
"getInstanceNames",
"(",
"TemplateEngine",
".",
"class",
")",
";",
"for",
"(",
"String",
"prefix",
":",
"prefixes",
")",
"{",
"TemplateEngine",
"engine",
"=",
"(",
"TemplateEngine",
")",
"container",
".",
"getInstance",
"(",
"TemplateEngine",
".",
"class",
",",
"prefix",
")",
";",
"map",
".",
"put",
"(",
"prefix",
",",
"engine",
")",
";",
"}",
"this",
".",
"templateEngines",
"=",
"Collections",
".",
"unmodifiableMap",
"(",
"map",
")",
";",
"}"
] | loading di container configulation from struts-plugin.xml , choise thymeleaf template engine.
@param container Struts2Container | [
"loading",
"di",
"container",
"configulation",
"from",
"struts",
"-",
"plugin",
".",
"xml",
"choise",
"thymeleaf",
"template",
"engine",
"."
] | 36a4609c1d0a36019784c6dba951c9b27dcc8802 | https://github.com/A-pZ/struts2-thymeleaf3-plugin/blob/36a4609c1d0a36019784c6dba951c9b27dcc8802/src/main/java/serendip/struts/plugins/thymeleaf/spi/DefaultTemplateEngineProvider.java#L136-L148 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.hasTokenInformation | public static boolean hasTokenInformation(Bundle bundle) {
if (bundle == null) {
return false;
}
String token = bundle.getString(TOKEN_KEY);
if ((token == null) || (token.length() == 0)) {
return false;
}
long expiresMilliseconds = bundle.getLong(EXPIRATION_DATE_KEY, 0L);
if (expiresMilliseconds == 0L) {
return false;
}
return true;
} | java | public static boolean hasTokenInformation(Bundle bundle) {
if (bundle == null) {
return false;
}
String token = bundle.getString(TOKEN_KEY);
if ((token == null) || (token.length() == 0)) {
return false;
}
long expiresMilliseconds = bundle.getLong(EXPIRATION_DATE_KEY, 0L);
if (expiresMilliseconds == 0L) {
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"hasTokenInformation",
"(",
"Bundle",
"bundle",
")",
"{",
"if",
"(",
"bundle",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"String",
"token",
"=",
"bundle",
".",
"getString",
"(",
"TOKEN_KEY",
")",
";",
"if",
"(",
"(",
"token",
"==",
"null",
")",
"||",
"(",
"token",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
"false",
";",
"}",
"long",
"expiresMilliseconds",
"=",
"bundle",
".",
"getLong",
"(",
"EXPIRATION_DATE_KEY",
",",
"0L",
")",
";",
"if",
"(",
"expiresMilliseconds",
"==",
"0L",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Returns a boolean indicating whether a Bundle contains properties that
could be a valid saved token.
@param bundle
A Bundle to check for token information.
@return a boolean indicating whether a Bundle contains properties that
could be a valid saved token. | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"a",
"Bundle",
"contains",
"properties",
"that",
"could",
"be",
"a",
"valid",
"saved",
"token",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L128-L144 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.getToken | public static String getToken(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return bundle.getString(TOKEN_KEY);
} | java | public static String getToken(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return bundle.getString(TOKEN_KEY);
} | [
"public",
"static",
"String",
"getToken",
"(",
"Bundle",
"bundle",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"return",
"bundle",
".",
"getString",
"(",
"TOKEN_KEY",
")",
";",
"}"
] | Gets the cached token value from a Bundle.
@param bundle
A Bundle in which the token value was stored.
@return the cached token value, or null.
@throws NullPointerException if the passed in Bundle is null | [
"Gets",
"the",
"cached",
"token",
"value",
"from",
"a",
"Bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L155-L158 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.putToken | public static void putToken(Bundle bundle, String value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
bundle.putString(TOKEN_KEY, value);
} | java | public static void putToken(Bundle bundle, String value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
bundle.putString(TOKEN_KEY, value);
} | [
"public",
"static",
"void",
"putToken",
"(",
"Bundle",
"bundle",
",",
"String",
"value",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"Validate",
".",
"notNull",
"(",
"value",
",",
"\"value\"",
")",
";",
"bundle",
".",
"putString",
"(",
"TOKEN_KEY",
",",
"value",
")",
";",
"}"
] | Puts the token value into a Bundle.
@param bundle
A Bundle in which the token value should be stored.
@param value
The String representing the token value, or null.
@throws NullPointerException if the passed in Bundle or token value are null | [
"Puts",
"the",
"token",
"value",
"into",
"a",
"Bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L170-L174 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.getExpirationDate | public static Date getExpirationDate(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return getDate(bundle, EXPIRATION_DATE_KEY);
} | java | public static Date getExpirationDate(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return getDate(bundle, EXPIRATION_DATE_KEY);
} | [
"public",
"static",
"Date",
"getExpirationDate",
"(",
"Bundle",
"bundle",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"return",
"getDate",
"(",
"bundle",
",",
"EXPIRATION_DATE_KEY",
")",
";",
"}"
] | Gets the cached expiration date from a Bundle.
@param bundle
A Bundle in which the expiration date was stored.
@return the cached expiration date, or null.
@throws NullPointerException if the passed in Bundle is null | [
"Gets",
"the",
"cached",
"expiration",
"date",
"from",
"a",
"Bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L185-L188 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.getPermissions | public static List<String> getPermissions(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return bundle.getStringArrayList(PERMISSIONS_KEY);
} | java | public static List<String> getPermissions(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return bundle.getStringArrayList(PERMISSIONS_KEY);
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getPermissions",
"(",
"Bundle",
"bundle",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"return",
"bundle",
".",
"getStringArrayList",
"(",
"PERMISSIONS_KEY",
")",
";",
"}"
] | Gets the cached list of permissions from a Bundle.
@param bundle
A Bundle in which the list of permissions was stored.
@return the cached list of permissions.
@throws NullPointerException if the passed in Bundle is null | [
"Gets",
"the",
"cached",
"list",
"of",
"permissions",
"from",
"a",
"Bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L246-L249 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.putPermissions | public static void putPermissions(Bundle bundle, List<String> value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
ArrayList<String> arrayList;
if (value instanceof ArrayList<?>) {
arrayList = (ArrayList<String>) value;
} else {
arrayList = new ArrayList<String>(value);
}
bundle.putStringArrayList(PERMISSIONS_KEY, arrayList);
} | java | public static void putPermissions(Bundle bundle, List<String> value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
ArrayList<String> arrayList;
if (value instanceof ArrayList<?>) {
arrayList = (ArrayList<String>) value;
} else {
arrayList = new ArrayList<String>(value);
}
bundle.putStringArrayList(PERMISSIONS_KEY, arrayList);
} | [
"public",
"static",
"void",
"putPermissions",
"(",
"Bundle",
"bundle",
",",
"List",
"<",
"String",
">",
"value",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"Validate",
".",
"notNull",
"(",
"value",
",",
"\"value\"",
")",
";",
"ArrayList",
"<",
"String",
">",
"arrayList",
";",
"if",
"(",
"value",
"instanceof",
"ArrayList",
"<",
"?",
">",
")",
"{",
"arrayList",
"=",
"(",
"ArrayList",
"<",
"String",
">",
")",
"value",
";",
"}",
"else",
"{",
"arrayList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"value",
")",
";",
"}",
"bundle",
".",
"putStringArrayList",
"(",
"PERMISSIONS_KEY",
",",
"arrayList",
")",
";",
"}"
] | Puts the list of permissions into a Bundle.
@param bundle
A Bundle in which the list of permissions should be stored.
@param value
The List<String> representing the list of permissions,
or null.
@throws NullPointerException if the passed in Bundle or permissions list are null | [
"Puts",
"the",
"list",
"of",
"permissions",
"into",
"a",
"Bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L262-L273 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.putDeclinedPermissions | public static void putDeclinedPermissions(Bundle bundle, List<String> value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
ArrayList<String> arrayList;
if (value instanceof ArrayList<?>) {
arrayList = (ArrayList<String>) value;
} else {
arrayList = new ArrayList<String>(value);
}
bundle.putStringArrayList(DECLINED_PERMISSIONS_KEY, arrayList);
} | java | public static void putDeclinedPermissions(Bundle bundle, List<String> value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
ArrayList<String> arrayList;
if (value instanceof ArrayList<?>) {
arrayList = (ArrayList<String>) value;
} else {
arrayList = new ArrayList<String>(value);
}
bundle.putStringArrayList(DECLINED_PERMISSIONS_KEY, arrayList);
} | [
"public",
"static",
"void",
"putDeclinedPermissions",
"(",
"Bundle",
"bundle",
",",
"List",
"<",
"String",
">",
"value",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"Validate",
".",
"notNull",
"(",
"value",
",",
"\"value\"",
")",
";",
"ArrayList",
"<",
"String",
">",
"arrayList",
";",
"if",
"(",
"value",
"instanceof",
"ArrayList",
"<",
"?",
">",
")",
"{",
"arrayList",
"=",
"(",
"ArrayList",
"<",
"String",
">",
")",
"value",
";",
"}",
"else",
"{",
"arrayList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"value",
")",
";",
"}",
"bundle",
".",
"putStringArrayList",
"(",
"DECLINED_PERMISSIONS_KEY",
",",
"arrayList",
")",
";",
"}"
] | Puts the list of declined permissions into a Bundle.
@param bundle
A Bundle in which the list of permissions should be stored.
@param value
The List<String> representing the list of permissions,
or null.
@throws NullPointerException if the passed in Bundle or permissions list are null | [
"Puts",
"the",
"list",
"of",
"declined",
"permissions",
"into",
"a",
"Bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L286-L297 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.getSource | public static AccessTokenSource getSource(Bundle bundle) {
Validate.notNull(bundle, "bundle");
if (bundle.containsKey(TokenCachingStrategy.TOKEN_SOURCE_KEY)) {
return (AccessTokenSource) bundle.getSerializable(TokenCachingStrategy.TOKEN_SOURCE_KEY);
} else {
boolean isSSO = bundle.getBoolean(TokenCachingStrategy.IS_SSO_KEY);
return isSSO ? AccessTokenSource.FACEBOOK_APPLICATION_WEB : AccessTokenSource.WEB_VIEW;
}
} | java | public static AccessTokenSource getSource(Bundle bundle) {
Validate.notNull(bundle, "bundle");
if (bundle.containsKey(TokenCachingStrategy.TOKEN_SOURCE_KEY)) {
return (AccessTokenSource) bundle.getSerializable(TokenCachingStrategy.TOKEN_SOURCE_KEY);
} else {
boolean isSSO = bundle.getBoolean(TokenCachingStrategy.IS_SSO_KEY);
return isSSO ? AccessTokenSource.FACEBOOK_APPLICATION_WEB : AccessTokenSource.WEB_VIEW;
}
} | [
"public",
"static",
"AccessTokenSource",
"getSource",
"(",
"Bundle",
"bundle",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"if",
"(",
"bundle",
".",
"containsKey",
"(",
"TokenCachingStrategy",
".",
"TOKEN_SOURCE_KEY",
")",
")",
"{",
"return",
"(",
"AccessTokenSource",
")",
"bundle",
".",
"getSerializable",
"(",
"TokenCachingStrategy",
".",
"TOKEN_SOURCE_KEY",
")",
";",
"}",
"else",
"{",
"boolean",
"isSSO",
"=",
"bundle",
".",
"getBoolean",
"(",
"TokenCachingStrategy",
".",
"IS_SSO_KEY",
")",
";",
"return",
"isSSO",
"?",
"AccessTokenSource",
".",
"FACEBOOK_APPLICATION_WEB",
":",
"AccessTokenSource",
".",
"WEB_VIEW",
";",
"}",
"}"
] | Gets the cached enum indicating the source of the token from the Bundle.
@param bundle
A Bundle in which the enum was stored.
@return enum indicating the source of the token
@throws NullPointerException if the passed in Bundle is null | [
"Gets",
"the",
"cached",
"enum",
"indicating",
"the",
"source",
"of",
"the",
"token",
"from",
"the",
"Bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L309-L317 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.putSource | public static void putSource(Bundle bundle, AccessTokenSource value) {
Validate.notNull(bundle, "bundle");
bundle.putSerializable(TOKEN_SOURCE_KEY, value);
} | java | public static void putSource(Bundle bundle, AccessTokenSource value) {
Validate.notNull(bundle, "bundle");
bundle.putSerializable(TOKEN_SOURCE_KEY, value);
} | [
"public",
"static",
"void",
"putSource",
"(",
"Bundle",
"bundle",
",",
"AccessTokenSource",
"value",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"bundle",
".",
"putSerializable",
"(",
"TOKEN_SOURCE_KEY",
",",
"value",
")",
";",
"}"
] | Puts the enum indicating the source of the token into a Bundle.
@param bundle
A Bundle in which the enum should be stored.
@param value
enum indicating the source of the token
@throws NullPointerException if the passed in Bundle is null | [
"Puts",
"the",
"enum",
"indicating",
"the",
"source",
"of",
"the",
"token",
"into",
"a",
"Bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L328-L331 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/TokenCachingStrategy.java | TokenCachingStrategy.getLastRefreshDate | public static Date getLastRefreshDate(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return getDate(bundle, LAST_REFRESH_DATE_KEY);
} | java | public static Date getLastRefreshDate(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return getDate(bundle, LAST_REFRESH_DATE_KEY);
} | [
"public",
"static",
"Date",
"getLastRefreshDate",
"(",
"Bundle",
"bundle",
")",
"{",
"Validate",
".",
"notNull",
"(",
"bundle",
",",
"\"bundle\"",
")",
";",
"return",
"getDate",
"(",
"bundle",
",",
"LAST_REFRESH_DATE_KEY",
")",
";",
"}"
] | Gets the cached last refresh date from a Bundle.
@param bundle
A Bundle in which the last refresh date was stored.
@return the cached last refresh Date, or null.
@throws NullPointerException if the passed in Bundle is null | [
"Gets",
"the",
"cached",
"last",
"refresh",
"date",
"from",
"a",
"Bundle",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/TokenCachingStrategy.java#L342-L345 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/tasks/TaskGroupInformation.java | TaskGroupInformation.newCopyBuilder | public Builder newCopyBuilder() {
return new Builder(getInputFormat(), getOutputFormat(), getActivity()).locale(getLocale()).setRequiredOptions(keys);
} | java | public Builder newCopyBuilder() {
return new Builder(getInputFormat(), getOutputFormat(), getActivity()).locale(getLocale()).setRequiredOptions(keys);
} | [
"public",
"Builder",
"newCopyBuilder",
"(",
")",
"{",
"return",
"new",
"Builder",
"(",
"getInputFormat",
"(",
")",
",",
"getOutputFormat",
"(",
")",
",",
"getActivity",
"(",
")",
")",
".",
"locale",
"(",
"getLocale",
"(",
")",
")",
".",
"setRequiredOptions",
"(",
"keys",
")",
";",
"}"
] | Creates a new builder with the same settings as this information.
@return returns a new builder | [
"Creates",
"a",
"new",
"builder",
"with",
"the",
"same",
"settings",
"as",
"this",
"information",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/tasks/TaskGroupInformation.java#L113-L115 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/tasks/TaskGroupInformation.java | TaskGroupInformation.newConvertBuilder | public static Builder newConvertBuilder(String input, String output) {
return new Builder(input, output, TaskGroupActivity.CONVERT);
} | java | public static Builder newConvertBuilder(String input, String output) {
return new Builder(input, output, TaskGroupActivity.CONVERT);
} | [
"public",
"static",
"Builder",
"newConvertBuilder",
"(",
"String",
"input",
",",
"String",
"output",
")",
"{",
"return",
"new",
"Builder",
"(",
"input",
",",
"output",
",",
"TaskGroupActivity",
".",
"CONVERT",
")",
";",
"}"
] | Creates a new builder of convert type with the specified parameters.
@param input the input format
@param output the output format
@return returns a new builder | [
"Creates",
"a",
"new",
"builder",
"of",
"convert",
"type",
"with",
"the",
"specified",
"parameters",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/tasks/TaskGroupInformation.java#L123-L125 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/ErrorPrinter.java | ErrorPrinter.printError | @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis",
"PMD.AvoidCatchingGenericException",
"PMD.UseStringBufferForStringAppends", "PMD.SystemPrintln" })
public void printError(Error event) {
String msg = "Unhandled " + event;
System.err.println(msg);
if (event.throwable() == null) {
System.err.println("No stack trace available.");
} else {
event.throwable().printStackTrace();
}
} | java | @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis",
"PMD.AvoidCatchingGenericException",
"PMD.UseStringBufferForStringAppends", "PMD.SystemPrintln" })
public void printError(Error event) {
String msg = "Unhandled " + event;
System.err.println(msg);
if (event.throwable() == null) {
System.err.println("No stack trace available.");
} else {
event.throwable().printStackTrace();
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"PMD.DataflowAnomalyAnalysis\"",
",",
"\"PMD.AvoidCatchingGenericException\"",
",",
"\"PMD.UseStringBufferForStringAppends\"",
",",
"\"PMD.SystemPrintln\"",
"}",
")",
"public",
"void",
"printError",
"(",
"Error",
"event",
")",
"{",
"String",
"msg",
"=",
"\"Unhandled \"",
"+",
"event",
";",
"System",
".",
"err",
".",
"println",
"(",
"msg",
")",
";",
"if",
"(",
"event",
".",
"throwable",
"(",
")",
"==",
"null",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"No stack trace available.\"",
")",
";",
"}",
"else",
"{",
"event",
".",
"throwable",
"(",
")",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | Prints the error.
@param event the event | [
"Prints",
"the",
"error",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/ErrorPrinter.java#L34-L45 | train |
kormide/recipe | recipe-java-runtime/src/main/java/ca/derekcormier/recipe/Recipe.java | Recipe.segment | protected List<Segment> segment() {
List<Segment> segments = new ArrayList<>();
List<Recipe> recipeStack = new ArrayList<>();
recipeStack.add(this);
_segment(new Recipe(), recipeStack, null, segments);
return segments;
} | java | protected List<Segment> segment() {
List<Segment> segments = new ArrayList<>();
List<Recipe> recipeStack = new ArrayList<>();
recipeStack.add(this);
_segment(new Recipe(), recipeStack, null, segments);
return segments;
} | [
"protected",
"List",
"<",
"Segment",
">",
"segment",
"(",
")",
"{",
"List",
"<",
"Segment",
">",
"segments",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"Recipe",
">",
"recipeStack",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"recipeStack",
".",
"add",
"(",
"this",
")",
";",
"_segment",
"(",
"new",
"Recipe",
"(",
")",
",",
"recipeStack",
",",
"null",
",",
"segments",
")",
";",
"return",
"segments",
";",
"}"
] | original recipe, but more efficient for sending payloads of ingredients to different services. | [
"original",
"recipe",
"but",
"more",
"efficient",
"for",
"sending",
"payloads",
"of",
"ingredients",
"to",
"different",
"services",
"."
] | 19f12328f562f57e08dfb23ce4936e337d552f3b | https://github.com/kormide/recipe/blob/19f12328f562f57e08dfb23ce4936e337d552f3b/recipe-java-runtime/src/main/java/ca/derekcormier/recipe/Recipe.java#L69-L75 | train |
mnlipp/jgrapes | examples/src/org/jgrapes/http/demo/httpserver/WsEchoServer.java | WsEchoServer.onGet | @RequestHandler(patterns = "/ws/echo", priority = 100)
public void onGet(Request.In.Get event, IOSubchannel channel)
throws InterruptedException {
final HttpRequest request = event.httpRequest();
if (!request.findField(
HttpField.UPGRADE, Converters.STRING_LIST)
.map(f -> f.value().containsIgnoreCase("websocket"))
.orElse(false)) {
return;
}
openChannels.add(channel);
channel.respond(new ProtocolSwitchAccepted(event, "websocket"));
event.stop();
} | java | @RequestHandler(patterns = "/ws/echo", priority = 100)
public void onGet(Request.In.Get event, IOSubchannel channel)
throws InterruptedException {
final HttpRequest request = event.httpRequest();
if (!request.findField(
HttpField.UPGRADE, Converters.STRING_LIST)
.map(f -> f.value().containsIgnoreCase("websocket"))
.orElse(false)) {
return;
}
openChannels.add(channel);
channel.respond(new ProtocolSwitchAccepted(event, "websocket"));
event.stop();
} | [
"@",
"RequestHandler",
"(",
"patterns",
"=",
"\"/ws/echo\"",
",",
"priority",
"=",
"100",
")",
"public",
"void",
"onGet",
"(",
"Request",
".",
"In",
".",
"Get",
"event",
",",
"IOSubchannel",
"channel",
")",
"throws",
"InterruptedException",
"{",
"final",
"HttpRequest",
"request",
"=",
"event",
".",
"httpRequest",
"(",
")",
";",
"if",
"(",
"!",
"request",
".",
"findField",
"(",
"HttpField",
".",
"UPGRADE",
",",
"Converters",
".",
"STRING_LIST",
")",
".",
"map",
"(",
"f",
"->",
"f",
".",
"value",
"(",
")",
".",
"containsIgnoreCase",
"(",
"\"websocket\"",
")",
")",
".",
"orElse",
"(",
"false",
")",
")",
"{",
"return",
";",
"}",
"openChannels",
".",
"add",
"(",
"channel",
")",
";",
"channel",
".",
"respond",
"(",
"new",
"ProtocolSwitchAccepted",
"(",
"event",
",",
"\"websocket\"",
")",
")",
";",
"event",
".",
"stop",
"(",
")",
";",
"}"
] | Handle `GET` requests.
@param event the event
@param channel the channel
@throws InterruptedException the interrupted exception | [
"Handle",
"GET",
"requests",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/examples/src/org/jgrapes/http/demo/httpserver/WsEchoServer.java#L65-L78 | train |
mnlipp/jgrapes | examples/src/org/jgrapes/http/demo/httpserver/WsEchoServer.java | WsEchoServer.onUpgraded | @Handler
public void onUpgraded(Upgraded event, IOSubchannel channel) {
if (!openChannels.contains(channel)) {
return;
}
channel.respond(Output.from("/Greetings!", true));
} | java | @Handler
public void onUpgraded(Upgraded event, IOSubchannel channel) {
if (!openChannels.contains(channel)) {
return;
}
channel.respond(Output.from("/Greetings!", true));
} | [
"@",
"Handler",
"public",
"void",
"onUpgraded",
"(",
"Upgraded",
"event",
",",
"IOSubchannel",
"channel",
")",
"{",
"if",
"(",
"!",
"openChannels",
".",
"contains",
"(",
"channel",
")",
")",
"{",
"return",
";",
"}",
"channel",
".",
"respond",
"(",
"Output",
".",
"from",
"(",
"\"/Greetings!\"",
",",
"true",
")",
")",
";",
"}"
] | Handle upgrade confirmation.
@param event the event
@param channel the channel | [
"Handle",
"upgrade",
"confirmation",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/examples/src/org/jgrapes/http/demo/httpserver/WsEchoServer.java#L86-L92 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/net/SslCodec.java | SslCodec.onOutput | @Handler
public void onOutput(Output<ByteBuffer> event,
PlainChannel plainChannel)
throws InterruptedException, SSLException, ExecutionException {
if (plainChannel.hub() != this) {
return;
}
plainChannel.sendUpstream(event);
} | java | @Handler
public void onOutput(Output<ByteBuffer> event,
PlainChannel plainChannel)
throws InterruptedException, SSLException, ExecutionException {
if (plainChannel.hub() != this) {
return;
}
plainChannel.sendUpstream(event);
} | [
"@",
"Handler",
"public",
"void",
"onOutput",
"(",
"Output",
"<",
"ByteBuffer",
">",
"event",
",",
"PlainChannel",
"plainChannel",
")",
"throws",
"InterruptedException",
",",
"SSLException",
",",
"ExecutionException",
"{",
"if",
"(",
"plainChannel",
".",
"hub",
"(",
")",
"!=",
"this",
")",
"{",
"return",
";",
"}",
"plainChannel",
".",
"sendUpstream",
"(",
"event",
")",
";",
"}"
] | Sends decrypted data through the engine and then upstream.
@param event
the event with the data
@throws InterruptedException if the execution was interrupted
@throws SSLException if some SSL related problem occurs
@throws ExecutionException | [
"Sends",
"decrypted",
"data",
"through",
"the",
"engine",
"and",
"then",
"upstream",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/net/SslCodec.java#L272-L280 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/net/SslCodec.java | SslCodec.onClose | @Handler
public void onClose(Close event, PlainChannel plainChannel)
throws InterruptedException, SSLException {
if (plainChannel.hub() != this) {
return;
}
plainChannel.close(event);
} | java | @Handler
public void onClose(Close event, PlainChannel plainChannel)
throws InterruptedException, SSLException {
if (plainChannel.hub() != this) {
return;
}
plainChannel.close(event);
} | [
"@",
"Handler",
"public",
"void",
"onClose",
"(",
"Close",
"event",
",",
"PlainChannel",
"plainChannel",
")",
"throws",
"InterruptedException",
",",
"SSLException",
"{",
"if",
"(",
"plainChannel",
".",
"hub",
"(",
")",
"!=",
"this",
")",
"{",
"return",
";",
"}",
"plainChannel",
".",
"close",
"(",
"event",
")",
";",
"}"
] | Forwards a close event upstream.
@param event
the close event
@throws SSLException if an SSL related problem occurs
@throws InterruptedException if the execution was interrupted | [
"Forwards",
"a",
"close",
"event",
"upstream",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/net/SslCodec.java#L290-L297 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/FileStorage.java | FileStorage.onInput | @Handler
public void onInput(Input<ByteBuffer> event, Channel channel) {
Writer writer = inputWriters.get(channel);
if (writer != null) {
writer.write(event.buffer());
}
} | java | @Handler
public void onInput(Input<ByteBuffer> event, Channel channel) {
Writer writer = inputWriters.get(channel);
if (writer != null) {
writer.write(event.buffer());
}
} | [
"@",
"Handler",
"public",
"void",
"onInput",
"(",
"Input",
"<",
"ByteBuffer",
">",
"event",
",",
"Channel",
"channel",
")",
"{",
"Writer",
"writer",
"=",
"inputWriters",
".",
"get",
"(",
"channel",
")",
";",
"if",
"(",
"writer",
"!=",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"event",
".",
"buffer",
"(",
")",
")",
";",
"}",
"}"
] | Handle input by writing it to the file, if a channel exists.
@param event the event
@param channel the channel | [
"Handle",
"input",
"by",
"writing",
"it",
"to",
"the",
"file",
"if",
"a",
"channel",
"exists",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/FileStorage.java#L327-L333 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/FileStorage.java | FileStorage.onClose | @Handler
public void onClose(Close event, Channel channel)
throws InterruptedException {
Writer writer = inputWriters.get(channel);
if (writer != null) {
writer.close(event);
}
writer = outputWriters.get(channel);
if (writer != null) {
writer.close(event);
}
} | java | @Handler
public void onClose(Close event, Channel channel)
throws InterruptedException {
Writer writer = inputWriters.get(channel);
if (writer != null) {
writer.close(event);
}
writer = outputWriters.get(channel);
if (writer != null) {
writer.close(event);
}
} | [
"@",
"Handler",
"public",
"void",
"onClose",
"(",
"Close",
"event",
",",
"Channel",
"channel",
")",
"throws",
"InterruptedException",
"{",
"Writer",
"writer",
"=",
"inputWriters",
".",
"get",
"(",
"channel",
")",
";",
"if",
"(",
"writer",
"!=",
"null",
")",
"{",
"writer",
".",
"close",
"(",
"event",
")",
";",
"}",
"writer",
"=",
"outputWriters",
".",
"get",
"(",
"channel",
")",
";",
"if",
"(",
"writer",
"!=",
"null",
")",
"{",
"writer",
".",
"close",
"(",
"event",
")",
";",
"}",
"}"
] | Handle close by closing the file associated with the channel.
@param event the event
@param channel the channel
@throws InterruptedException the interrupted exception | [
"Handle",
"close",
"by",
"closing",
"the",
"file",
"associated",
"with",
"the",
"channel",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/FileStorage.java#L383-L394 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/FileStorage.java | FileStorage.onStop | @Handler(priority = -1000)
public void onStop(Stop event) throws InterruptedException {
while (!inputWriters.isEmpty()) {
Writer handler = inputWriters.entrySet().iterator().next()
.getValue();
handler.close(event);
}
while (!outputWriters.isEmpty()) {
Writer handler = outputWriters.entrySet().iterator().next()
.getValue();
handler.close(event);
}
} | java | @Handler(priority = -1000)
public void onStop(Stop event) throws InterruptedException {
while (!inputWriters.isEmpty()) {
Writer handler = inputWriters.entrySet().iterator().next()
.getValue();
handler.close(event);
}
while (!outputWriters.isEmpty()) {
Writer handler = outputWriters.entrySet().iterator().next()
.getValue();
handler.close(event);
}
} | [
"@",
"Handler",
"(",
"priority",
"=",
"-",
"1000",
")",
"public",
"void",
"onStop",
"(",
"Stop",
"event",
")",
"throws",
"InterruptedException",
"{",
"while",
"(",
"!",
"inputWriters",
".",
"isEmpty",
"(",
")",
")",
"{",
"Writer",
"handler",
"=",
"inputWriters",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
".",
"getValue",
"(",
")",
";",
"handler",
".",
"close",
"(",
"event",
")",
";",
"}",
"while",
"(",
"!",
"outputWriters",
".",
"isEmpty",
"(",
")",
")",
"{",
"Writer",
"handler",
"=",
"outputWriters",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
".",
"getValue",
"(",
")",
";",
"handler",
".",
"close",
"(",
"event",
")",
";",
"}",
"}"
] | Handle stop by closing all files.
@param event the event
@throws InterruptedException the interrupted exception | [
"Handle",
"stop",
"by",
"closing",
"all",
"files",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/FileStorage.java#L402-L414 | train |
BBN-E/bue-common-open | gnuplot-util/src/main/java/com/bbn/bue/gnuplot/BoxPlot.java | BoxPlot.data | private String data() {
if (datasets.isEmpty()) {
return "";
} else {
final StringBuilder ret = new StringBuilder();
int biggestSize = 0;
for (final Dataset dataset : datasets) {
biggestSize = Math.max(biggestSize, dataset.numPoints());
}
for (int row = 0; row < biggestSize; ++row) {
ret.append(valueOrBlank(datasets.get(0), row));
// all dataset vlaues but first are prefixed with tab
for (final Dataset dataset : Iterables.skip(datasets, 1)) {
ret.append("\t");
ret.append(valueOrBlank(dataset, row));
}
ret.append("\n");
}
return ret.toString();
}
} | java | private String data() {
if (datasets.isEmpty()) {
return "";
} else {
final StringBuilder ret = new StringBuilder();
int biggestSize = 0;
for (final Dataset dataset : datasets) {
biggestSize = Math.max(biggestSize, dataset.numPoints());
}
for (int row = 0; row < biggestSize; ++row) {
ret.append(valueOrBlank(datasets.get(0), row));
// all dataset vlaues but first are prefixed with tab
for (final Dataset dataset : Iterables.skip(datasets, 1)) {
ret.append("\t");
ret.append(valueOrBlank(dataset, row));
}
ret.append("\n");
}
return ret.toString();
}
} | [
"private",
"String",
"data",
"(",
")",
"{",
"if",
"(",
"datasets",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"else",
"{",
"final",
"StringBuilder",
"ret",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"biggestSize",
"=",
"0",
";",
"for",
"(",
"final",
"Dataset",
"dataset",
":",
"datasets",
")",
"{",
"biggestSize",
"=",
"Math",
".",
"max",
"(",
"biggestSize",
",",
"dataset",
".",
"numPoints",
"(",
")",
")",
";",
"}",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"biggestSize",
";",
"++",
"row",
")",
"{",
"ret",
".",
"append",
"(",
"valueOrBlank",
"(",
"datasets",
".",
"get",
"(",
"0",
")",
",",
"row",
")",
")",
";",
"// all dataset vlaues but first are prefixed with tab",
"for",
"(",
"final",
"Dataset",
"dataset",
":",
"Iterables",
".",
"skip",
"(",
"datasets",
",",
"1",
")",
")",
"{",
"ret",
".",
"append",
"(",
"\"\\t\"",
")",
";",
"ret",
".",
"append",
"(",
"valueOrBlank",
"(",
"dataset",
",",
"row",
")",
")",
";",
"}",
"ret",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"return",
"ret",
".",
"toString",
"(",
")",
";",
"}",
"}"
] | gnuplot annoyingly requires data to be written in columns | [
"gnuplot",
"annoyingly",
"requires",
"data",
"to",
"be",
"written",
"in",
"columns"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/gnuplot-util/src/main/java/com/bbn/bue/gnuplot/BoxPlot.java#L144-L164 | train |
BBN-E/bue-common-open | gnuplot-util/src/main/java/com/bbn/bue/gnuplot/BoxPlot.java | BoxPlot.valueOrBlank | private String valueOrBlank(Dataset dataset, int idx) {
if (idx < dataset.numPoints()) {
return Double.toString(dataset.get(idx));
} else {
return "";
}
} | java | private String valueOrBlank(Dataset dataset, int idx) {
if (idx < dataset.numPoints()) {
return Double.toString(dataset.get(idx));
} else {
return "";
}
} | [
"private",
"String",
"valueOrBlank",
"(",
"Dataset",
"dataset",
",",
"int",
"idx",
")",
"{",
"if",
"(",
"idx",
"<",
"dataset",
".",
"numPoints",
"(",
")",
")",
"{",
"return",
"Double",
".",
"toString",
"(",
"dataset",
".",
"get",
"(",
"idx",
")",
")",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}"
] | used by writeData | [
"used",
"by",
"writeData"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/gnuplot-util/src/main/java/com/bbn/bue/gnuplot/BoxPlot.java#L167-L173 | train |
BBN-E/bue-common-open | gnuplot-util/src/main/java/com/bbn/bue/gnuplot/BoxPlot.java | BoxPlot.main | public static void main(String[] argv) throws IOException {
final File outputDir = new File(argv[0]);
final Random rand = new Random();
final double mean1 = 5.0;
final double mean2 = 7.0;
final double dev1 = 2.0;
final double dev2 = 4.0;
final double[] data1 = new double[100];
final double[] data2 = new double[100];
for (int i = 0; i < 100; ++i) {
data1[i] = rand.nextGaussian() * dev1 + mean1;
data2[i] = rand.nextGaussian() * dev2 + mean2;
}
BoxPlot.builder()
.addDataset(Dataset.createAdoptingData("A", data1))
.addDataset(Dataset.createAdoptingData("B", data2))
.setTitle("A vs B")
.setXAxis(Axis.xAxis().setLabel("FooCategory").build())
.setYAxis(Axis.yAxis().setLabel("FooValue").setRange(Range.closed(0.0, 15.0)).build())
.hideKey()
.build().renderToEmptyDirectory(outputDir);
} | java | public static void main(String[] argv) throws IOException {
final File outputDir = new File(argv[0]);
final Random rand = new Random();
final double mean1 = 5.0;
final double mean2 = 7.0;
final double dev1 = 2.0;
final double dev2 = 4.0;
final double[] data1 = new double[100];
final double[] data2 = new double[100];
for (int i = 0; i < 100; ++i) {
data1[i] = rand.nextGaussian() * dev1 + mean1;
data2[i] = rand.nextGaussian() * dev2 + mean2;
}
BoxPlot.builder()
.addDataset(Dataset.createAdoptingData("A", data1))
.addDataset(Dataset.createAdoptingData("B", data2))
.setTitle("A vs B")
.setXAxis(Axis.xAxis().setLabel("FooCategory").build())
.setYAxis(Axis.yAxis().setLabel("FooValue").setRange(Range.closed(0.0, 15.0)).build())
.hideKey()
.build().renderToEmptyDirectory(outputDir);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"argv",
")",
"throws",
"IOException",
"{",
"final",
"File",
"outputDir",
"=",
"new",
"File",
"(",
"argv",
"[",
"0",
"]",
")",
";",
"final",
"Random",
"rand",
"=",
"new",
"Random",
"(",
")",
";",
"final",
"double",
"mean1",
"=",
"5.0",
";",
"final",
"double",
"mean2",
"=",
"7.0",
";",
"final",
"double",
"dev1",
"=",
"2.0",
";",
"final",
"double",
"dev2",
"=",
"4.0",
";",
"final",
"double",
"[",
"]",
"data1",
"=",
"new",
"double",
"[",
"100",
"]",
";",
"final",
"double",
"[",
"]",
"data2",
"=",
"new",
"double",
"[",
"100",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"100",
";",
"++",
"i",
")",
"{",
"data1",
"[",
"i",
"]",
"=",
"rand",
".",
"nextGaussian",
"(",
")",
"*",
"dev1",
"+",
"mean1",
";",
"data2",
"[",
"i",
"]",
"=",
"rand",
".",
"nextGaussian",
"(",
")",
"*",
"dev2",
"+",
"mean2",
";",
"}",
"BoxPlot",
".",
"builder",
"(",
")",
".",
"addDataset",
"(",
"Dataset",
".",
"createAdoptingData",
"(",
"\"A\"",
",",
"data1",
")",
")",
".",
"addDataset",
"(",
"Dataset",
".",
"createAdoptingData",
"(",
"\"B\"",
",",
"data2",
")",
")",
".",
"setTitle",
"(",
"\"A vs B\"",
")",
".",
"setXAxis",
"(",
"Axis",
".",
"xAxis",
"(",
")",
".",
"setLabel",
"(",
"\"FooCategory\"",
")",
".",
"build",
"(",
")",
")",
".",
"setYAxis",
"(",
"Axis",
".",
"yAxis",
"(",
")",
".",
"setLabel",
"(",
"\"FooValue\"",
")",
".",
"setRange",
"(",
"Range",
".",
"closed",
"(",
"0.0",
",",
"15.0",
")",
")",
".",
"build",
"(",
")",
")",
".",
"hideKey",
"(",
")",
".",
"build",
"(",
")",
".",
"renderToEmptyDirectory",
"(",
"outputDir",
")",
";",
"}"
] | Little test program | [
"Little",
"test",
"program"
] | d618652674d647867306e2e4b987a21b7c29c015 | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/gnuplot-util/src/main/java/com/bbn/bue/gnuplot/BoxPlot.java#L341-L366 | train |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/OrientedBox3f.java | OrientedBox3f.setFirstAxis | @Override
public void setFirstAxis(double x, double y, double z, double extent, CoordinateSystem3D system) {
this.axis1.set(x, y, z);
assert(this.axis1.isUnitVector());
if (system.isLeftHanded()) {
this.axis3.set(this.axis1.crossLeftHand(this.axis2));
} else {
this.axis3.set(this.axis3.crossRightHand(this.axis2));
}
this.extent1 = extent;
} | java | @Override
public void setFirstAxis(double x, double y, double z, double extent, CoordinateSystem3D system) {
this.axis1.set(x, y, z);
assert(this.axis1.isUnitVector());
if (system.isLeftHanded()) {
this.axis3.set(this.axis1.crossLeftHand(this.axis2));
} else {
this.axis3.set(this.axis3.crossRightHand(this.axis2));
}
this.extent1 = extent;
} | [
"@",
"Override",
"public",
"void",
"setFirstAxis",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
",",
"double",
"extent",
",",
"CoordinateSystem3D",
"system",
")",
"{",
"this",
".",
"axis1",
".",
"set",
"(",
"x",
",",
"y",
",",
"z",
")",
";",
"assert",
"(",
"this",
".",
"axis1",
".",
"isUnitVector",
"(",
")",
")",
";",
"if",
"(",
"system",
".",
"isLeftHanded",
"(",
")",
")",
"{",
"this",
".",
"axis3",
".",
"set",
"(",
"this",
".",
"axis1",
".",
"crossLeftHand",
"(",
"this",
".",
"axis2",
")",
")",
";",
"}",
"else",
"{",
"this",
".",
"axis3",
".",
"set",
"(",
"this",
".",
"axis3",
".",
"crossRightHand",
"(",
"this",
".",
"axis2",
")",
")",
";",
"}",
"this",
".",
"extent1",
"=",
"extent",
";",
"}"
] | Set the first axis of the second .
The third axis is updated to be perpendicular to the two other axis.
@param x
@param y
@param z
@param extent
@param system | [
"Set",
"the",
"first",
"axis",
"of",
"the",
"second",
".",
"The",
"third",
"axis",
"is",
"updated",
"to",
"be",
"perpendicular",
"to",
"the",
"two",
"other",
"axis",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/OrientedBox3f.java#L453-L463 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java | Path2dfx.windingRuleProperty | public ObjectProperty<PathWindingRule> windingRuleProperty() {
if (this.windingRule == null) {
this.windingRule = new SimpleObjectProperty<>(this, MathFXAttributeNames.WINDING_RULE, DEFAULT_WINDING_RULE);
}
return this.windingRule;
} | java | public ObjectProperty<PathWindingRule> windingRuleProperty() {
if (this.windingRule == null) {
this.windingRule = new SimpleObjectProperty<>(this, MathFXAttributeNames.WINDING_RULE, DEFAULT_WINDING_RULE);
}
return this.windingRule;
} | [
"public",
"ObjectProperty",
"<",
"PathWindingRule",
">",
"windingRuleProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"windingRule",
"==",
"null",
")",
"{",
"this",
".",
"windingRule",
"=",
"new",
"SimpleObjectProperty",
"<>",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"WINDING_RULE",
",",
"DEFAULT_WINDING_RULE",
")",
";",
"}",
"return",
"this",
".",
"windingRule",
";",
"}"
] | Replies the windingRule property.
@return the windingRule property. | [
"Replies",
"the",
"windingRule",
"property",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java#L275-L280 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java | Path2dfx.isPolylineProperty | public BooleanProperty isPolylineProperty() {
if (this.isPolyline == null) {
this.isPolyline = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_POLYLINE, false);
this.isPolyline.bind(Bindings.createBooleanBinding(() -> {
boolean first = true;
boolean hasOneLine = false;
for (final PathElementType type : innerTypesProperty()) {
if (first) {
if (type != PathElementType.MOVE_TO) {
return false;
}
first = false;
} else if (type != PathElementType.LINE_TO) {
return false;
} else {
hasOneLine = true;
}
}
return hasOneLine;
},
innerTypesProperty()));
}
return this.isPolyline;
} | java | public BooleanProperty isPolylineProperty() {
if (this.isPolyline == null) {
this.isPolyline = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_POLYLINE, false);
this.isPolyline.bind(Bindings.createBooleanBinding(() -> {
boolean first = true;
boolean hasOneLine = false;
for (final PathElementType type : innerTypesProperty()) {
if (first) {
if (type != PathElementType.MOVE_TO) {
return false;
}
first = false;
} else if (type != PathElementType.LINE_TO) {
return false;
} else {
hasOneLine = true;
}
}
return hasOneLine;
},
innerTypesProperty()));
}
return this.isPolyline;
} | [
"public",
"BooleanProperty",
"isPolylineProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isPolyline",
"==",
"null",
")",
"{",
"this",
".",
"isPolyline",
"=",
"new",
"ReadOnlyBooleanWrapper",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"IS_POLYLINE",
",",
"false",
")",
";",
"this",
".",
"isPolyline",
".",
"bind",
"(",
"Bindings",
".",
"createBooleanBinding",
"(",
"(",
")",
"->",
"{",
"boolean",
"first",
"=",
"true",
";",
"boolean",
"hasOneLine",
"=",
"false",
";",
"for",
"(",
"final",
"PathElementType",
"type",
":",
"innerTypesProperty",
"(",
")",
")",
"{",
"if",
"(",
"first",
")",
"{",
"if",
"(",
"type",
"!=",
"PathElementType",
".",
"MOVE_TO",
")",
"{",
"return",
"false",
";",
"}",
"first",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"type",
"!=",
"PathElementType",
".",
"LINE_TO",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"hasOneLine",
"=",
"true",
";",
"}",
"}",
"return",
"hasOneLine",
";",
"}",
",",
"innerTypesProperty",
"(",
")",
")",
")",
";",
"}",
"return",
"this",
".",
"isPolyline",
";",
"}"
] | Replies the isPolyline property.
@return the isPolyline property. | [
"Replies",
"the",
"isPolyline",
"property",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java#L299-L322 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java | Path2dfx.isCurvedProperty | public BooleanProperty isCurvedProperty() {
if (this.isCurved == null) {
this.isCurved = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_CURVED, false);
this.isCurved.bind(Bindings.createBooleanBinding(() -> {
for (final PathElementType type : innerTypesProperty()) {
if (type == PathElementType.CURVE_TO || type == PathElementType.QUAD_TO) {
return true;
}
}
return false;
},
innerTypesProperty()));
}
return this.isCurved;
} | java | public BooleanProperty isCurvedProperty() {
if (this.isCurved == null) {
this.isCurved = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_CURVED, false);
this.isCurved.bind(Bindings.createBooleanBinding(() -> {
for (final PathElementType type : innerTypesProperty()) {
if (type == PathElementType.CURVE_TO || type == PathElementType.QUAD_TO) {
return true;
}
}
return false;
},
innerTypesProperty()));
}
return this.isCurved;
} | [
"public",
"BooleanProperty",
"isCurvedProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isCurved",
"==",
"null",
")",
"{",
"this",
".",
"isCurved",
"=",
"new",
"ReadOnlyBooleanWrapper",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"IS_CURVED",
",",
"false",
")",
";",
"this",
".",
"isCurved",
".",
"bind",
"(",
"Bindings",
".",
"createBooleanBinding",
"(",
"(",
")",
"->",
"{",
"for",
"(",
"final",
"PathElementType",
"type",
":",
"innerTypesProperty",
"(",
")",
")",
"{",
"if",
"(",
"type",
"==",
"PathElementType",
".",
"CURVE_TO",
"||",
"type",
"==",
"PathElementType",
".",
"QUAD_TO",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
",",
"innerTypesProperty",
"(",
")",
")",
")",
";",
"}",
"return",
"this",
".",
"isCurved",
";",
"}"
] | Replies the isCurved property.
@return the isCurved property. | [
"Replies",
"the",
"isCurved",
"property",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java#L333-L347 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java | Path2dfx.isPolygonProperty | public BooleanProperty isPolygonProperty() {
if (this.isPolygon == null) {
this.isPolygon = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_POLYGON, false);
this.isPolygon.bind(Bindings.createBooleanBinding(() -> {
boolean first = true;
boolean lastIsClose = false;
for (final PathElementType type : innerTypesProperty()) {
lastIsClose = false;
if (first) {
if (type != PathElementType.MOVE_TO) {
return false;
}
first = false;
} else if (type == PathElementType.MOVE_TO) {
return false;
} else if (type == PathElementType.CLOSE) {
lastIsClose = true;
}
}
return lastIsClose;
},
innerTypesProperty()));
}
return this.isPolygon;
} | java | public BooleanProperty isPolygonProperty() {
if (this.isPolygon == null) {
this.isPolygon = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_POLYGON, false);
this.isPolygon.bind(Bindings.createBooleanBinding(() -> {
boolean first = true;
boolean lastIsClose = false;
for (final PathElementType type : innerTypesProperty()) {
lastIsClose = false;
if (first) {
if (type != PathElementType.MOVE_TO) {
return false;
}
first = false;
} else if (type == PathElementType.MOVE_TO) {
return false;
} else if (type == PathElementType.CLOSE) {
lastIsClose = true;
}
}
return lastIsClose;
},
innerTypesProperty()));
}
return this.isPolygon;
} | [
"public",
"BooleanProperty",
"isPolygonProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isPolygon",
"==",
"null",
")",
"{",
"this",
".",
"isPolygon",
"=",
"new",
"ReadOnlyBooleanWrapper",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"IS_POLYGON",
",",
"false",
")",
";",
"this",
".",
"isPolygon",
".",
"bind",
"(",
"Bindings",
".",
"createBooleanBinding",
"(",
"(",
")",
"->",
"{",
"boolean",
"first",
"=",
"true",
";",
"boolean",
"lastIsClose",
"=",
"false",
";",
"for",
"(",
"final",
"PathElementType",
"type",
":",
"innerTypesProperty",
"(",
")",
")",
"{",
"lastIsClose",
"=",
"false",
";",
"if",
"(",
"first",
")",
"{",
"if",
"(",
"type",
"!=",
"PathElementType",
".",
"MOVE_TO",
")",
"{",
"return",
"false",
";",
"}",
"first",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"PathElementType",
".",
"MOVE_TO",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"PathElementType",
".",
"CLOSE",
")",
"{",
"lastIsClose",
"=",
"true",
";",
"}",
"}",
"return",
"lastIsClose",
";",
"}",
",",
"innerTypesProperty",
"(",
")",
")",
")",
";",
"}",
"return",
"this",
".",
"isPolygon",
";",
"}"
] | Replies the isPolygon property.
@return the isPolygon property. | [
"Replies",
"the",
"isPolygon",
"property",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java#L387-L411 | train |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java | Path2dfx.innerTypesProperty | protected ReadOnlyListWrapper<PathElementType> innerTypesProperty() {
if (this.types == null) {
this.types = new ReadOnlyListWrapper<>(this, MathFXAttributeNames.TYPES,
FXCollections.observableList(new ArrayList<>()));
}
return this.types;
} | java | protected ReadOnlyListWrapper<PathElementType> innerTypesProperty() {
if (this.types == null) {
this.types = new ReadOnlyListWrapper<>(this, MathFXAttributeNames.TYPES,
FXCollections.observableList(new ArrayList<>()));
}
return this.types;
} | [
"protected",
"ReadOnlyListWrapper",
"<",
"PathElementType",
">",
"innerTypesProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"types",
"==",
"null",
")",
"{",
"this",
".",
"types",
"=",
"new",
"ReadOnlyListWrapper",
"<>",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"TYPES",
",",
"FXCollections",
".",
"observableList",
"(",
"new",
"ArrayList",
"<>",
"(",
")",
")",
")",
";",
"}",
"return",
"this",
".",
"types",
";",
"}"
] | Replies the private types property.
@return the private types property. | [
"Replies",
"the",
"private",
"types",
"property",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d2/dfx/Path2dfx.java#L865-L871 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java | MultiMapLayer.setMapLayerAt | protected void setMapLayerAt(int index, L layer) {
this.subLayers.set(index, layer);
layer.setContainer(this);
resetBoundingBox();
} | java | protected void setMapLayerAt(int index, L layer) {
this.subLayers.set(index, layer);
layer.setContainer(this);
resetBoundingBox();
} | [
"protected",
"void",
"setMapLayerAt",
"(",
"int",
"index",
",",
"L",
"layer",
")",
"{",
"this",
".",
"subLayers",
".",
"set",
"(",
"index",
",",
"layer",
")",
";",
"layer",
".",
"setContainer",
"(",
"this",
")",
";",
"resetBoundingBox",
"(",
")",
";",
"}"
] | Put the given layer at the given index but
do not fire any event.
<p>This function does not test if the layer
is already present in the list of layers.
@param index index.
@param layer layer.
@throws IndexOutOfBoundsException if the index
is invalid. | [
"Put",
"the",
"given",
"layer",
"at",
"the",
"given",
"index",
"but",
"do",
"not",
"fire",
"any",
"event",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java#L286-L290 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java | MultiMapLayer.fireLayerAddedEvent | protected void fireLayerAddedEvent(MapLayer layer, int index) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer, Type.ADD_CHILD, index, layer.isTemporaryLayer()));
} | java | protected void fireLayerAddedEvent(MapLayer layer, int index) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer, Type.ADD_CHILD, index, layer.isTemporaryLayer()));
} | [
"protected",
"void",
"fireLayerAddedEvent",
"(",
"MapLayer",
"layer",
",",
"int",
"index",
")",
"{",
"fireLayerHierarchyChangedEvent",
"(",
"new",
"MapLayerHierarchyEvent",
"(",
"this",
",",
"layer",
",",
"Type",
".",
"ADD_CHILD",
",",
"index",
",",
"layer",
".",
"isTemporaryLayer",
"(",
")",
")",
")",
";",
"}"
] | Fire the event that indicates a layer was added.
@param layer is the added layer.
@param index is the insertion index. | [
"Fire",
"the",
"event",
"that",
"indicates",
"a",
"layer",
"was",
"added",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java#L443-L445 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java | MultiMapLayer.fireLayerRemovedEvent | protected void fireLayerRemovedEvent(MapLayer layer, int oldChildIndex) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(
this, layer, Type.REMOVE_CHILD, oldChildIndex, layer.isTemporaryLayer()));
} | java | protected void fireLayerRemovedEvent(MapLayer layer, int oldChildIndex) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(
this, layer, Type.REMOVE_CHILD, oldChildIndex, layer.isTemporaryLayer()));
} | [
"protected",
"void",
"fireLayerRemovedEvent",
"(",
"MapLayer",
"layer",
",",
"int",
"oldChildIndex",
")",
"{",
"fireLayerHierarchyChangedEvent",
"(",
"new",
"MapLayerHierarchyEvent",
"(",
"this",
",",
"layer",
",",
"Type",
".",
"REMOVE_CHILD",
",",
"oldChildIndex",
",",
"layer",
".",
"isTemporaryLayer",
"(",
")",
")",
")",
";",
"}"
] | Fire the event that indicates a layer was removed.
@param layer is the removed layer.
@param oldChildIndex the old child index. | [
"Fire",
"the",
"event",
"that",
"indicates",
"a",
"layer",
"was",
"removed",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java#L452-L455 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java | MultiMapLayer.fireLayerMovedUpEvent | protected void fireLayerMovedUpEvent(MapLayer layer, int newIndex) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer,
Type.MOVE_CHILD_UP, newIndex, layer.isTemporaryLayer()));
} | java | protected void fireLayerMovedUpEvent(MapLayer layer, int newIndex) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer,
Type.MOVE_CHILD_UP, newIndex, layer.isTemporaryLayer()));
} | [
"protected",
"void",
"fireLayerMovedUpEvent",
"(",
"MapLayer",
"layer",
",",
"int",
"newIndex",
")",
"{",
"fireLayerHierarchyChangedEvent",
"(",
"new",
"MapLayerHierarchyEvent",
"(",
"this",
",",
"layer",
",",
"Type",
".",
"MOVE_CHILD_UP",
",",
"newIndex",
",",
"layer",
".",
"isTemporaryLayer",
"(",
")",
")",
")",
";",
"}"
] | Fire the event that indicates a layer was moved up.
@param layer is the moved layer.
@param newIndex is the new index of the layer. | [
"Fire",
"the",
"event",
"that",
"indicates",
"a",
"layer",
"was",
"moved",
"up",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java#L462-L465 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java | MultiMapLayer.fireLayerMovedDownEvent | protected void fireLayerMovedDownEvent(MapLayer layer, int newIndex) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer,
Type.MOVE_CHILD_DOWN, newIndex, layer.isTemporaryLayer()));
} | java | protected void fireLayerMovedDownEvent(MapLayer layer, int newIndex) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer,
Type.MOVE_CHILD_DOWN, newIndex, layer.isTemporaryLayer()));
} | [
"protected",
"void",
"fireLayerMovedDownEvent",
"(",
"MapLayer",
"layer",
",",
"int",
"newIndex",
")",
"{",
"fireLayerHierarchyChangedEvent",
"(",
"new",
"MapLayerHierarchyEvent",
"(",
"this",
",",
"layer",
",",
"Type",
".",
"MOVE_CHILD_DOWN",
",",
"newIndex",
",",
"layer",
".",
"isTemporaryLayer",
"(",
")",
")",
")",
";",
"}"
] | Fire the event that indicates a layer was moved down.
@param layer is the moved layer.
@param newIndex is the new index of the layer. | [
"Fire",
"the",
"event",
"that",
"indicates",
"a",
"layer",
"was",
"moved",
"down",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java#L472-L475 | train |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java | MultiMapLayer.fireLayerRemoveAllEvent | protected void fireLayerRemoveAllEvent(List<? extends L> removedObjects) {
fireLayerHierarchyChangedEvent(
new MapLayerHierarchyEvent(
this,
removedObjects,
Type.REMOVE_ALL_CHILDREN,
-1,
isTemporaryLayer()));
} | java | protected void fireLayerRemoveAllEvent(List<? extends L> removedObjects) {
fireLayerHierarchyChangedEvent(
new MapLayerHierarchyEvent(
this,
removedObjects,
Type.REMOVE_ALL_CHILDREN,
-1,
isTemporaryLayer()));
} | [
"protected",
"void",
"fireLayerRemoveAllEvent",
"(",
"List",
"<",
"?",
"extends",
"L",
">",
"removedObjects",
")",
"{",
"fireLayerHierarchyChangedEvent",
"(",
"new",
"MapLayerHierarchyEvent",
"(",
"this",
",",
"removedObjects",
",",
"Type",
".",
"REMOVE_ALL_CHILDREN",
",",
"-",
"1",
",",
"isTemporaryLayer",
"(",
")",
")",
")",
";",
"}"
] | Fire the event that indicates all the layers were removed.
@param removedObjects are the removed objects. | [
"Fire",
"the",
"event",
"that",
"indicates",
"all",
"the",
"layers",
"were",
"removed",
"."
] | 0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/maplayer/MultiMapLayer.java#L480-L488 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.