id int32 0 165k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
36,400 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.isSaturday | public static boolean isSaturday(int column, int firstDayOfWeek) {
return (firstDayOfWeek == Time.SUNDAY && column == 6)
|| (firstDayOfWeek == Time.MONDAY && column == 5)
|| (firstDayOfWeek == Time.SATURDAY && column == 0);
} | java | public static boolean isSaturday(int column, int firstDayOfWeek) {
return (firstDayOfWeek == Time.SUNDAY && column == 6)
|| (firstDayOfWeek == Time.MONDAY && column == 5)
|| (firstDayOfWeek == Time.SATURDAY && column == 0);
} | [
"public",
"static",
"boolean",
"isSaturday",
"(",
"int",
"column",
",",
"int",
"firstDayOfWeek",
")",
"{",
"return",
"(",
"firstDayOfWeek",
"==",
"Time",
".",
"SUNDAY",
"&&",
"column",
"==",
"6",
")",
"||",
"(",
"firstDayOfWeek",
"==",
"Time",
".",
"MONDAY... | Determine whether the column position is Saturday or not.
@param column the column position
@param firstDayOfWeek the first day of week in android.text.format.Time
@return true if the column is Saturday position | [
"Determine",
"whether",
"the",
"column",
"position",
"is",
"Saturday",
"or",
"not",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L434-L438 |
36,401 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.isSunday | public static boolean isSunday(int column, int firstDayOfWeek) {
return (firstDayOfWeek == Time.SUNDAY && column == 0)
|| (firstDayOfWeek == Time.MONDAY && column == 6)
|| (firstDayOfWeek == Time.SATURDAY && column == 1);
} | java | public static boolean isSunday(int column, int firstDayOfWeek) {
return (firstDayOfWeek == Time.SUNDAY && column == 0)
|| (firstDayOfWeek == Time.MONDAY && column == 6)
|| (firstDayOfWeek == Time.SATURDAY && column == 1);
} | [
"public",
"static",
"boolean",
"isSunday",
"(",
"int",
"column",
",",
"int",
"firstDayOfWeek",
")",
"{",
"return",
"(",
"firstDayOfWeek",
"==",
"Time",
".",
"SUNDAY",
"&&",
"column",
"==",
"0",
")",
"||",
"(",
"firstDayOfWeek",
"==",
"Time",
".",
"MONDAY",... | Determine whether the column position is Sunday or not.
@param column the column position
@param firstDayOfWeek the first day of week in android.text.format.Time
@return true if the column is Sunday position | [
"Determine",
"whether",
"the",
"column",
"position",
"is",
"Sunday",
"or",
"not",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L447-L451 |
36,402 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.convertAlldayUtcToLocal | public static long convertAlldayUtcToLocal(Time recycle, long utcTime, String tz) {
if (recycle == null) {
recycle = new Time();
}
recycle.timezone = Time.TIMEZONE_UTC;
recycle.set(utcTime);
recycle.timezone = tz;
return recycle.normalize(true);
} | java | public static long convertAlldayUtcToLocal(Time recycle, long utcTime, String tz) {
if (recycle == null) {
recycle = new Time();
}
recycle.timezone = Time.TIMEZONE_UTC;
recycle.set(utcTime);
recycle.timezone = tz;
return recycle.normalize(true);
} | [
"public",
"static",
"long",
"convertAlldayUtcToLocal",
"(",
"Time",
"recycle",
",",
"long",
"utcTime",
",",
"String",
"tz",
")",
"{",
"if",
"(",
"recycle",
"==",
"null",
")",
"{",
"recycle",
"=",
"new",
"Time",
"(",
")",
";",
"}",
"recycle",
".",
"time... | Convert given UTC time into current local time. This assumes it is for an
allday event and will adjust the time to be on a midnight boundary.
@param recycle Time object to recycle, otherwise null.
@param utcTime Time to convert, in UTC.
@param tz The time zone to convert this time to. | [
"Convert",
"given",
"UTC",
"time",
"into",
"current",
"local",
"time",
".",
"This",
"assumes",
"it",
"is",
"for",
"an",
"allday",
"event",
"and",
"will",
"adjust",
"the",
"time",
"to",
"be",
"on",
"a",
"midnight",
"boundary",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L461-L469 |
36,403 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.getNextMidnight | public static long getNextMidnight(Time recycle, long theTime, String tz) {
if (recycle == null) {
recycle = new Time();
}
recycle.timezone = tz;
recycle.set(theTime);
recycle.monthDay++;
recycle.hour = 0;
recycle.minute = 0;
recycle.second = 0;
return recycle.normalize(true);
} | java | public static long getNextMidnight(Time recycle, long theTime, String tz) {
if (recycle == null) {
recycle = new Time();
}
recycle.timezone = tz;
recycle.set(theTime);
recycle.monthDay++;
recycle.hour = 0;
recycle.minute = 0;
recycle.second = 0;
return recycle.normalize(true);
} | [
"public",
"static",
"long",
"getNextMidnight",
"(",
"Time",
"recycle",
",",
"long",
"theTime",
",",
"String",
"tz",
")",
"{",
"if",
"(",
"recycle",
"==",
"null",
")",
"{",
"recycle",
"=",
"new",
"Time",
"(",
")",
";",
"}",
"recycle",
".",
"timezone",
... | Finds and returns the next midnight after "theTime" in milliseconds UTC
@param recycle - Time object to recycle, otherwise null.
@param theTime - Time used for calculations (in UTC)
@param tz The time zone to convert this time to. | [
"Finds",
"and",
"returns",
"the",
"next",
"midnight",
"after",
"theTime",
"in",
"milliseconds",
"UTC"
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L488-L499 |
36,404 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.checkForDuplicateNames | public static void checkForDuplicateNames(
Map<String, Boolean> isDuplicateName, Cursor cursor, int nameIndex) {
isDuplicateName.clear();
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
String displayName = cursor.getString(nameIndex);
// Set it to true if we've seen this name before, false otherwise
if (displayName != null) {
isDuplicateName.put(displayName, isDuplicateName.containsKey(displayName));
}
}
} | java | public static void checkForDuplicateNames(
Map<String, Boolean> isDuplicateName, Cursor cursor, int nameIndex) {
isDuplicateName.clear();
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
String displayName = cursor.getString(nameIndex);
// Set it to true if we've seen this name before, false otherwise
if (displayName != null) {
isDuplicateName.put(displayName, isDuplicateName.containsKey(displayName));
}
}
} | [
"public",
"static",
"void",
"checkForDuplicateNames",
"(",
"Map",
"<",
"String",
",",
"Boolean",
">",
"isDuplicateName",
",",
"Cursor",
"cursor",
",",
"int",
"nameIndex",
")",
"{",
"isDuplicateName",
".",
"clear",
"(",
")",
";",
"cursor",
".",
"moveToPosition"... | Scan through a cursor of calendars and check if names are duplicated.
This travels a cursor containing calendar display names and fills in the
provided map with whether or not each name is repeated.
@param isDuplicateName The map to put the duplicate check results in.
@param cursor The query of calendars to check
@param nameIndex The column of the query that contains the display name | [
"Scan",
"through",
"a",
"cursor",
"of",
"calendars",
"and",
"check",
"if",
"names",
"are",
"duplicated",
".",
"This",
"travels",
"a",
"cursor",
"containing",
"calendar",
"display",
"names",
"and",
"fills",
"in",
"the",
"provided",
"map",
"with",
"whether",
"... | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L510-L521 |
36,405 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.getDisplayColorFromColor | public static int getDisplayColorFromColor(int color) {
if (!isJellybeanOrLater()) {
return color;
}
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[1] = Math.min(hsv[1] * SATURATION_ADJUST, 1.0f);
hsv[2] = hsv[2] * INTENSITY_ADJUST;
return Color.HSVToColor(hsv);
} | java | public static int getDisplayColorFromColor(int color) {
if (!isJellybeanOrLater()) {
return color;
}
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[1] = Math.min(hsv[1] * SATURATION_ADJUST, 1.0f);
hsv[2] = hsv[2] * INTENSITY_ADJUST;
return Color.HSVToColor(hsv);
} | [
"public",
"static",
"int",
"getDisplayColorFromColor",
"(",
"int",
"color",
")",
"{",
"if",
"(",
"!",
"isJellybeanOrLater",
"(",
")",
")",
"{",
"return",
"color",
";",
"}",
"float",
"[",
"]",
"hsv",
"=",
"new",
"float",
"[",
"3",
"]",
";",
"Color",
"... | For devices with Jellybean or later, darkens the given color to ensure that white text is
clearly visible on top of it. For devices prior to Jellybean, does nothing, as the
sync adapter handles the color change.
@param color | [
"For",
"devices",
"with",
"Jellybean",
"or",
"later",
"darkens",
"the",
"given",
"color",
"to",
"ensure",
"that",
"white",
"text",
"is",
"clearly",
"visible",
"on",
"top",
"of",
"it",
".",
"For",
"devices",
"prior",
"to",
"Jellybean",
"does",
"nothing",
"a... | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L553-L563 |
36,406 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.getDeclinedColorFromColor | public static int getDeclinedColorFromColor(int color) {
int bg = 0xffffffff;
int a = DECLINED_EVENT_ALPHA;
int r = (((color & 0x00ff0000) * a) + ((bg & 0x00ff0000) * (0xff - a))) & 0xff000000;
int g = (((color & 0x0000ff00) * a) + ((bg & 0x0000ff00) * (0xff - a))) & 0x00ff0000;
int b = (((color & 0x000000ff) * a) + ((bg & 0x000000ff) * (0xff - a))) & 0x0000ff00;
return (0xff000000) | ((r | g | b) >> 8);
} | java | public static int getDeclinedColorFromColor(int color) {
int bg = 0xffffffff;
int a = DECLINED_EVENT_ALPHA;
int r = (((color & 0x00ff0000) * a) + ((bg & 0x00ff0000) * (0xff - a))) & 0xff000000;
int g = (((color & 0x0000ff00) * a) + ((bg & 0x0000ff00) * (0xff - a))) & 0x00ff0000;
int b = (((color & 0x000000ff) * a) + ((bg & 0x000000ff) * (0xff - a))) & 0x0000ff00;
return (0xff000000) | ((r | g | b) >> 8);
} | [
"public",
"static",
"int",
"getDeclinedColorFromColor",
"(",
"int",
"color",
")",
"{",
"int",
"bg",
"=",
"0xffffffff",
";",
"int",
"a",
"=",
"DECLINED_EVENT_ALPHA",
";",
"int",
"r",
"=",
"(",
"(",
"(",
"color",
"&",
"0x00ff0000",
")",
"*",
"a",
")",
"+... | white. The result is the color that should be used for declined events. | [
"white",
".",
"The",
"result",
"is",
"the",
"color",
"that",
"should",
"be",
"used",
"for",
"declined",
"events",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L567-L574 |
36,407 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.weaveDNAStrands | private static void weaveDNAStrands(LinkedList<DNASegment> segments, int firstJulianDay,
HashMap<Integer, DNAStrand> strands, int top, int bottom, int[] dayXs) {
// First, get rid of any colors that ended up with no segments
Iterator<DNAStrand> strandIterator = strands.values().iterator();
while (strandIterator.hasNext()) {
DNAStrand strand = strandIterator.next();
if (strand.count < 1 && strand.allDays == null) {
strandIterator.remove();
continue;
}
strand.points = new float[strand.count * 4];
strand.position = 0;
}
// Go through each segment and compute its points
for (DNASegment segment : segments) {
// Add the points to the strand of that color
DNAStrand strand = strands.get(segment.color);
int dayIndex = segment.day - firstJulianDay;
int dayStartMinute = segment.startMinute % DAY_IN_MINUTES;
int dayEndMinute = segment.endMinute % DAY_IN_MINUTES;
int height = bottom - top;
int workDayHeight = height * 3 / 4;
int remainderHeight = (height - workDayHeight) / 2;
int x = dayXs[dayIndex];
int y0 = 0;
int y1 = 0;
y0 = top + getPixelOffsetFromMinutes(dayStartMinute, workDayHeight, remainderHeight);
y1 = top + getPixelOffsetFromMinutes(dayEndMinute, workDayHeight, remainderHeight);
if (DEBUG) {
Log.d(TAG, "Adding " + Integer.toHexString(segment.color) + " at x,y0,y1: " + x
+ " " + y0 + " " + y1 + " for " + dayStartMinute + " " + dayEndMinute);
}
strand.points[strand.position++] = x;
strand.points[strand.position++] = y0;
strand.points[strand.position++] = x;
strand.points[strand.position++] = y1;
}
} | java | private static void weaveDNAStrands(LinkedList<DNASegment> segments, int firstJulianDay,
HashMap<Integer, DNAStrand> strands, int top, int bottom, int[] dayXs) {
// First, get rid of any colors that ended up with no segments
Iterator<DNAStrand> strandIterator = strands.values().iterator();
while (strandIterator.hasNext()) {
DNAStrand strand = strandIterator.next();
if (strand.count < 1 && strand.allDays == null) {
strandIterator.remove();
continue;
}
strand.points = new float[strand.count * 4];
strand.position = 0;
}
// Go through each segment and compute its points
for (DNASegment segment : segments) {
// Add the points to the strand of that color
DNAStrand strand = strands.get(segment.color);
int dayIndex = segment.day - firstJulianDay;
int dayStartMinute = segment.startMinute % DAY_IN_MINUTES;
int dayEndMinute = segment.endMinute % DAY_IN_MINUTES;
int height = bottom - top;
int workDayHeight = height * 3 / 4;
int remainderHeight = (height - workDayHeight) / 2;
int x = dayXs[dayIndex];
int y0 = 0;
int y1 = 0;
y0 = top + getPixelOffsetFromMinutes(dayStartMinute, workDayHeight, remainderHeight);
y1 = top + getPixelOffsetFromMinutes(dayEndMinute, workDayHeight, remainderHeight);
if (DEBUG) {
Log.d(TAG, "Adding " + Integer.toHexString(segment.color) + " at x,y0,y1: " + x
+ " " + y0 + " " + y1 + " for " + dayStartMinute + " " + dayEndMinute);
}
strand.points[strand.position++] = x;
strand.points[strand.position++] = y0;
strand.points[strand.position++] = x;
strand.points[strand.position++] = y1;
}
} | [
"private",
"static",
"void",
"weaveDNAStrands",
"(",
"LinkedList",
"<",
"DNASegment",
">",
"segments",
",",
"int",
"firstJulianDay",
",",
"HashMap",
"<",
"Integer",
",",
"DNAStrand",
">",
"strands",
",",
"int",
"top",
",",
"int",
"bottom",
",",
"int",
"[",
... | list of points to draw | [
"list",
"of",
"points",
"to",
"draw"
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L600-L639 |
36,408 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.getPixelOffsetFromMinutes | private static int getPixelOffsetFromMinutes(int minute, int workDayHeight,
int remainderHeight) {
int y;
if (minute < WORK_DAY_START_MINUTES) {
y = minute * remainderHeight / WORK_DAY_START_MINUTES;
} else if (minute < WORK_DAY_END_MINUTES) {
y = remainderHeight + (minute - WORK_DAY_START_MINUTES) * workDayHeight
/ WORK_DAY_MINUTES;
} else {
y = remainderHeight + workDayHeight + (minute - WORK_DAY_END_MINUTES) * remainderHeight
/ WORK_DAY_END_LENGTH;
}
return y;
} | java | private static int getPixelOffsetFromMinutes(int minute, int workDayHeight,
int remainderHeight) {
int y;
if (minute < WORK_DAY_START_MINUTES) {
y = minute * remainderHeight / WORK_DAY_START_MINUTES;
} else if (minute < WORK_DAY_END_MINUTES) {
y = remainderHeight + (minute - WORK_DAY_START_MINUTES) * workDayHeight
/ WORK_DAY_MINUTES;
} else {
y = remainderHeight + workDayHeight + (minute - WORK_DAY_END_MINUTES) * remainderHeight
/ WORK_DAY_END_LENGTH;
}
return y;
} | [
"private",
"static",
"int",
"getPixelOffsetFromMinutes",
"(",
"int",
"minute",
",",
"int",
"workDayHeight",
",",
"int",
"remainderHeight",
")",
"{",
"int",
"y",
";",
"if",
"(",
"minute",
"<",
"WORK_DAY_START_MINUTES",
")",
"{",
"y",
"=",
"minute",
"*",
"rema... | Compute a pixel offset from the top for a given minute from the work day
height and the height of the top area. | [
"Compute",
"a",
"pixel",
"offset",
"from",
"the",
"top",
"for",
"a",
"given",
"minute",
"from",
"the",
"work",
"day",
"height",
"and",
"the",
"height",
"of",
"the",
"top",
"area",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L645-L658 |
36,409 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.getOrCreateStrand | private static DNAStrand getOrCreateStrand(HashMap<Integer, DNAStrand> strands, int color) {
DNAStrand strand = strands.get(color);
if (strand == null) {
strand = new DNAStrand();
strand.color = color;
strand.count = 0;
strands.put(strand.color, strand);
}
return strand;
} | java | private static DNAStrand getOrCreateStrand(HashMap<Integer, DNAStrand> strands, int color) {
DNAStrand strand = strands.get(color);
if (strand == null) {
strand = new DNAStrand();
strand.color = color;
strand.count = 0;
strands.put(strand.color, strand);
}
return strand;
} | [
"private",
"static",
"DNAStrand",
"getOrCreateStrand",
"(",
"HashMap",
"<",
"Integer",
",",
"DNAStrand",
">",
"strands",
",",
"int",
"color",
")",
"{",
"DNAStrand",
"strand",
"=",
"strands",
".",
"get",
"(",
"color",
")",
";",
"if",
"(",
"strand",
"==",
... | Try to get a strand of the given color. Create it if it doesn't exist. | [
"Try",
"to",
"get",
"a",
"strand",
"of",
"the",
"given",
"color",
".",
"Create",
"it",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L663-L672 |
36,410 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.setUpSearchView | public static void setUpSearchView(SearchView view, Activity act) {
SearchManager searchManager = (SearchManager) act.getSystemService(Context.SEARCH_SERVICE);
view.setSearchableInfo(searchManager.getSearchableInfo(act.getComponentName()));
view.setQueryRefinementEnabled(true);
} | java | public static void setUpSearchView(SearchView view, Activity act) {
SearchManager searchManager = (SearchManager) act.getSystemService(Context.SEARCH_SERVICE);
view.setSearchableInfo(searchManager.getSearchableInfo(act.getComponentName()));
view.setQueryRefinementEnabled(true);
} | [
"public",
"static",
"void",
"setUpSearchView",
"(",
"SearchView",
"view",
",",
"Activity",
"act",
")",
"{",
"SearchManager",
"searchManager",
"=",
"(",
"SearchManager",
")",
"act",
".",
"getSystemService",
"(",
"Context",
".",
"SEARCH_SERVICE",
")",
";",
"view",... | This sets up a search view to use Calendar's search suggestions provider
and to allow refining the search.
@param view The {@link android.widget.SearchView} to set up
@param act The activity using the view | [
"This",
"sets",
"up",
"a",
"search",
"view",
"to",
"use",
"Calendar",
"s",
"search",
"suggestions",
"provider",
"and",
"to",
"allow",
"refining",
"the",
"search",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L682-L686 |
36,411 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.setMidnightUpdater | public static void setMidnightUpdater(Handler h, Runnable r, String timezone) {
if (h == null || r == null || timezone == null) {
return;
}
long now = System.currentTimeMillis();
Time time = new Time(timezone);
time.set(now);
long runInMillis = (24 * 3600 - time.hour * 3600 - time.minute * 60 -
time.second + 1) * 1000;
h.removeCallbacks(r);
h.postDelayed(r, runInMillis);
} | java | public static void setMidnightUpdater(Handler h, Runnable r, String timezone) {
if (h == null || r == null || timezone == null) {
return;
}
long now = System.currentTimeMillis();
Time time = new Time(timezone);
time.set(now);
long runInMillis = (24 * 3600 - time.hour * 3600 - time.minute * 60 -
time.second + 1) * 1000;
h.removeCallbacks(r);
h.postDelayed(r, runInMillis);
} | [
"public",
"static",
"void",
"setMidnightUpdater",
"(",
"Handler",
"h",
",",
"Runnable",
"r",
",",
"String",
"timezone",
")",
"{",
"if",
"(",
"h",
"==",
"null",
"||",
"r",
"==",
"null",
"||",
"timezone",
"==",
"null",
")",
"{",
"return",
";",
"}",
"lo... | do run the runnable | [
"do",
"run",
"the",
"runnable"
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L690-L701 |
36,412 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.resetMidnightUpdater | public static void resetMidnightUpdater(Handler h, Runnable r) {
if (h == null || r == null) {
return;
}
h.removeCallbacks(r);
} | java | public static void resetMidnightUpdater(Handler h, Runnable r) {
if (h == null || r == null) {
return;
}
h.removeCallbacks(r);
} | [
"public",
"static",
"void",
"resetMidnightUpdater",
"(",
"Handler",
"h",
",",
"Runnable",
"r",
")",
"{",
"if",
"(",
"h",
"==",
"null",
"||",
"r",
"==",
"null",
")",
"{",
"return",
";",
"}",
"h",
".",
"removeCallbacks",
"(",
"r",
")",
";",
"}"
] | Stop the midnight update thread | [
"Stop",
"the",
"midnight",
"update",
"thread"
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L704-L709 |
36,413 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.getDisplayedTimezone | public static String getDisplayedTimezone(long startMillis, String localTimezone,
String eventTimezone) {
String tzDisplay = null;
if (!TextUtils.equals(localTimezone, eventTimezone)) {
// Figure out if this is in DST
TimeZone tz = TimeZone.getTimeZone(localTimezone);
if (tz == null || tz.getID().equals("GMT")) {
tzDisplay = localTimezone;
} else {
Time startTime = new Time(localTimezone);
startTime.set(startMillis);
tzDisplay = tz.getDisplayName(startTime.isDst != 0, TimeZone.SHORT);
}
}
return tzDisplay;
} | java | public static String getDisplayedTimezone(long startMillis, String localTimezone,
String eventTimezone) {
String tzDisplay = null;
if (!TextUtils.equals(localTimezone, eventTimezone)) {
// Figure out if this is in DST
TimeZone tz = TimeZone.getTimeZone(localTimezone);
if (tz == null || tz.getID().equals("GMT")) {
tzDisplay = localTimezone;
} else {
Time startTime = new Time(localTimezone);
startTime.set(startMillis);
tzDisplay = tz.getDisplayName(startTime.isDst != 0, TimeZone.SHORT);
}
}
return tzDisplay;
} | [
"public",
"static",
"String",
"getDisplayedTimezone",
"(",
"long",
"startMillis",
",",
"String",
"localTimezone",
",",
"String",
"eventTimezone",
")",
"{",
"String",
"tzDisplay",
"=",
"null",
";",
"if",
"(",
"!",
"TextUtils",
".",
"equals",
"(",
"localTimezone",... | Returns the timezone to display in the event info, if the local timezone is different
from the event timezone. Otherwise returns null. | [
"Returns",
"the",
"timezone",
"to",
"display",
"in",
"the",
"event",
"info",
"if",
"the",
"local",
"timezone",
"is",
"different",
"from",
"the",
"event",
"timezone",
".",
"Otherwise",
"returns",
"null",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L715-L730 |
36,414 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.singleDayEvent | private static boolean singleDayEvent(long startMillis, long endMillis, long localGmtOffset) {
if (startMillis == endMillis) {
return true;
}
// An event ending at midnight should still be a single-day event, so check
// time end-1.
int startDay = Time.getJulianDay(startMillis, localGmtOffset);
int endDay = Time.getJulianDay(endMillis - 1, localGmtOffset);
return startDay == endDay;
} | java | private static boolean singleDayEvent(long startMillis, long endMillis, long localGmtOffset) {
if (startMillis == endMillis) {
return true;
}
// An event ending at midnight should still be a single-day event, so check
// time end-1.
int startDay = Time.getJulianDay(startMillis, localGmtOffset);
int endDay = Time.getJulianDay(endMillis - 1, localGmtOffset);
return startDay == endDay;
} | [
"private",
"static",
"boolean",
"singleDayEvent",
"(",
"long",
"startMillis",
",",
"long",
"endMillis",
",",
"long",
"localGmtOffset",
")",
"{",
"if",
"(",
"startMillis",
"==",
"endMillis",
")",
"{",
"return",
"true",
";",
"}",
"// An event ending at midnight shou... | Returns whether the specified time interval is in a single day. | [
"Returns",
"whether",
"the",
"specified",
"time",
"interval",
"is",
"in",
"a",
"single",
"day",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L735-L745 |
36,415 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.isTodayOrTomorrow | private static int isTodayOrTomorrow(Resources r, long dayMillis,
long currentMillis, long localGmtOffset) {
int startDay = Time.getJulianDay(dayMillis, localGmtOffset);
int currentDay = Time.getJulianDay(currentMillis, localGmtOffset);
int days = startDay - currentDay;
if (days == 1) {
return TOMORROW;
} else if (days == 0) {
return TODAY;
} else {
return NONE;
}
} | java | private static int isTodayOrTomorrow(Resources r, long dayMillis,
long currentMillis, long localGmtOffset) {
int startDay = Time.getJulianDay(dayMillis, localGmtOffset);
int currentDay = Time.getJulianDay(currentMillis, localGmtOffset);
int days = startDay - currentDay;
if (days == 1) {
return TOMORROW;
} else if (days == 0) {
return TODAY;
} else {
return NONE;
}
} | [
"private",
"static",
"int",
"isTodayOrTomorrow",
"(",
"Resources",
"r",
",",
"long",
"dayMillis",
",",
"long",
"currentMillis",
",",
"long",
"localGmtOffset",
")",
"{",
"int",
"startDay",
"=",
"Time",
".",
"getJulianDay",
"(",
"dayMillis",
",",
"localGmtOffset",... | Returns TODAY or TOMORROW if applicable. Otherwise returns NONE. | [
"Returns",
"TODAY",
"or",
"TOMORROW",
"if",
"applicable",
".",
"Otherwise",
"returns",
"NONE",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L755-L768 |
36,416 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.createEmailAttendeesIntent | public static Intent createEmailAttendeesIntent(Resources resources, String eventTitle,
String body, List<String> toEmails, List<String> ccEmails, String ownerAccount) {
List<String> toList = toEmails;
List<String> ccList = ccEmails;
if (toEmails.size() <= 0) {
if (ccEmails.size() <= 0) {
// TODO: Return a SEND intent if no one to email to, to at least populate
// a draft email with the subject (and no recipients).
throw new IllegalArgumentException("Both toEmails and ccEmails are empty.");
}
// Email app does not work with no "to" recipient. Move all 'cc' to 'to'
// in this case.
toList = ccEmails;
ccList = null;
}
// Use the event title as the email subject (prepended with 'Re: ').
String subject = null;
if (eventTitle != null) {
subject = resources.getString(R.string.email_subject_prefix) + eventTitle;
}
// Use the SENDTO intent with a 'mailto' URI, because using SEND will cause
// the picker to show apps like text messaging, which does not make sense
// for email addresses. We put all data in the URI instead of using the extra
// Intent fields (ie. EXTRA_CC, etc) because some email apps might not handle
// those (though gmail does).
Uri.Builder uriBuilder = new Uri.Builder();
uriBuilder.scheme("mailto");
// We will append the first email to the 'mailto' field later (because the
// current state of the Email app requires it). Add the remaining 'to' values
// here. When the email codebase is updated, we can simplify this.
if (toList.size() > 1) {
for (int i = 1; i < toList.size(); i++) {
// The Email app requires repeated parameter settings instead of
// a single comma-separated list.
uriBuilder.appendQueryParameter("to", toList.get(i));
}
}
// Add the subject parameter.
if (subject != null) {
uriBuilder.appendQueryParameter("subject", subject);
}
// Add the subject parameter.
if (body != null) {
uriBuilder.appendQueryParameter("body", body);
}
// Add the cc parameters.
if (ccList != null && ccList.size() > 0) {
for (String email : ccList) {
uriBuilder.appendQueryParameter("cc", email);
}
}
// Insert the first email after 'mailto:' in the URI manually since Uri.Builder
// doesn't seem to have a way to do this.
String uri = uriBuilder.toString();
if (uri.startsWith("mailto:")) {
StringBuilder builder = new StringBuilder(uri);
builder.insert(7, Uri.encode(toList.get(0)));
uri = builder.toString();
}
// Start the email intent. Email from the account of the calendar owner in case there
// are multiple email accounts.
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
emailIntent.putExtra("fromAccountString", ownerAccount);
// Workaround a Email bug that overwrites the body with this intent extra. If not
// set, it clears the body.
if (body != null) {
emailIntent.putExtra(Intent.EXTRA_TEXT, body);
}
return Intent.createChooser(emailIntent, resources.getString(R.string.email_picker_label));
} | java | public static Intent createEmailAttendeesIntent(Resources resources, String eventTitle,
String body, List<String> toEmails, List<String> ccEmails, String ownerAccount) {
List<String> toList = toEmails;
List<String> ccList = ccEmails;
if (toEmails.size() <= 0) {
if (ccEmails.size() <= 0) {
// TODO: Return a SEND intent if no one to email to, to at least populate
// a draft email with the subject (and no recipients).
throw new IllegalArgumentException("Both toEmails and ccEmails are empty.");
}
// Email app does not work with no "to" recipient. Move all 'cc' to 'to'
// in this case.
toList = ccEmails;
ccList = null;
}
// Use the event title as the email subject (prepended with 'Re: ').
String subject = null;
if (eventTitle != null) {
subject = resources.getString(R.string.email_subject_prefix) + eventTitle;
}
// Use the SENDTO intent with a 'mailto' URI, because using SEND will cause
// the picker to show apps like text messaging, which does not make sense
// for email addresses. We put all data in the URI instead of using the extra
// Intent fields (ie. EXTRA_CC, etc) because some email apps might not handle
// those (though gmail does).
Uri.Builder uriBuilder = new Uri.Builder();
uriBuilder.scheme("mailto");
// We will append the first email to the 'mailto' field later (because the
// current state of the Email app requires it). Add the remaining 'to' values
// here. When the email codebase is updated, we can simplify this.
if (toList.size() > 1) {
for (int i = 1; i < toList.size(); i++) {
// The Email app requires repeated parameter settings instead of
// a single comma-separated list.
uriBuilder.appendQueryParameter("to", toList.get(i));
}
}
// Add the subject parameter.
if (subject != null) {
uriBuilder.appendQueryParameter("subject", subject);
}
// Add the subject parameter.
if (body != null) {
uriBuilder.appendQueryParameter("body", body);
}
// Add the cc parameters.
if (ccList != null && ccList.size() > 0) {
for (String email : ccList) {
uriBuilder.appendQueryParameter("cc", email);
}
}
// Insert the first email after 'mailto:' in the URI manually since Uri.Builder
// doesn't seem to have a way to do this.
String uri = uriBuilder.toString();
if (uri.startsWith("mailto:")) {
StringBuilder builder = new StringBuilder(uri);
builder.insert(7, Uri.encode(toList.get(0)));
uri = builder.toString();
}
// Start the email intent. Email from the account of the calendar owner in case there
// are multiple email accounts.
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
emailIntent.putExtra("fromAccountString", ownerAccount);
// Workaround a Email bug that overwrites the body with this intent extra. If not
// set, it clears the body.
if (body != null) {
emailIntent.putExtra(Intent.EXTRA_TEXT, body);
}
return Intent.createChooser(emailIntent, resources.getString(R.string.email_picker_label));
} | [
"public",
"static",
"Intent",
"createEmailAttendeesIntent",
"(",
"Resources",
"resources",
",",
"String",
"eventTitle",
",",
"String",
"body",
",",
"List",
"<",
"String",
">",
"toEmails",
",",
"List",
"<",
"String",
">",
"ccEmails",
",",
"String",
"ownerAccount"... | Create an intent for emailing attendees of an event.
@param resources The resources for translating strings.
@param eventTitle The title of the event to use as the email subject.
@param body The default text for the email body.
@param toEmails The list of emails for the 'to' line.
@param ccEmails The list of emails for the 'cc' line.
@param ownerAccount The owner account to use as the email sender. | [
"Create",
"an",
"intent",
"for",
"emailing",
"attendees",
"of",
"an",
"event",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L780-L860 |
36,417 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.getVersionCode | public static String getVersionCode(Context context) {
if (sVersion == null) {
try {
sVersion = context.getPackageManager().getPackageInfo(
context.getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
// Can't find version; just leave it blank.
Log.e(TAG, "Error finding package " + context.getApplicationInfo().packageName);
}
}
return sVersion;
} | java | public static String getVersionCode(Context context) {
if (sVersion == null) {
try {
sVersion = context.getPackageManager().getPackageInfo(
context.getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
// Can't find version; just leave it blank.
Log.e(TAG, "Error finding package " + context.getApplicationInfo().packageName);
}
}
return sVersion;
} | [
"public",
"static",
"String",
"getVersionCode",
"(",
"Context",
"context",
")",
"{",
"if",
"(",
"sVersion",
"==",
"null",
")",
"{",
"try",
"{",
"sVersion",
"=",
"context",
".",
"getPackageManager",
"(",
")",
".",
"getPackageInfo",
"(",
"context",
".",
"get... | Return the app version code. | [
"Return",
"the",
"app",
"version",
"code",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L921-L932 |
36,418 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.findNanpMatchEnd | private static int findNanpMatchEnd(CharSequence text, int startPos) {
/*
* A few interesting cases:
* 94043 # too short, ignore
* 123456789012 # too long, ignore
* +1 (650) 555-1212 # 11 digits, spaces
* (650) 555 5555 # Second space, only when first is present.
* (650) 555-1212, (650) 555-1213 # two numbers, return first
* 1-650-555-1212 # 11 digits with leading '1'
* *#650.555.1212#*! # 10 digits, include #*, ignore trailing '!'
* 555.1212 # 7 digits
*
* For the most part we want to break on whitespace, but it's common to leave a space
* between the initial '1' and/or after the area code.
*/
// Check for "tel:" URI prefix.
if (text.length() > startPos + 4
&& text.subSequence(startPos, startPos + 4).toString().equalsIgnoreCase("tel:")) {
startPos += 4;
}
int endPos = text.length();
int curPos = startPos;
int foundDigits = 0;
char firstDigit = 'x';
boolean foundWhiteSpaceAfterAreaCode = false;
while (curPos <= endPos) {
char ch;
if (curPos < endPos) {
ch = text.charAt(curPos);
} else {
ch = 27; // fake invalid symbol at end to trigger loop break
}
if (Character.isDigit(ch)) {
if (foundDigits == 0) {
firstDigit = ch;
}
foundDigits++;
if (foundDigits > NANP_MAX_DIGITS) {
// too many digits, stop early
return -1;
}
} else if (Character.isWhitespace(ch)) {
if ((firstDigit == '1' && foundDigits == 4) ||
(foundDigits == 3)) {
foundWhiteSpaceAfterAreaCode = true;
} else if (firstDigit == '1' && foundDigits == 1) {
} else if (foundWhiteSpaceAfterAreaCode
&& ((firstDigit == '1' && (foundDigits == 7)) || (foundDigits == 6))) {
} else {
break;
}
} else if (NANP_ALLOWED_SYMBOLS.indexOf(ch) == -1) {
break;
}
// else it's an allowed symbol
curPos++;
}
if ((firstDigit != '1' && (foundDigits == 7 || foundDigits == 10)) ||
(firstDigit == '1' && foundDigits == 11)) {
// match
return curPos;
}
return -1;
} | java | private static int findNanpMatchEnd(CharSequence text, int startPos) {
/*
* A few interesting cases:
* 94043 # too short, ignore
* 123456789012 # too long, ignore
* +1 (650) 555-1212 # 11 digits, spaces
* (650) 555 5555 # Second space, only when first is present.
* (650) 555-1212, (650) 555-1213 # two numbers, return first
* 1-650-555-1212 # 11 digits with leading '1'
* *#650.555.1212#*! # 10 digits, include #*, ignore trailing '!'
* 555.1212 # 7 digits
*
* For the most part we want to break on whitespace, but it's common to leave a space
* between the initial '1' and/or after the area code.
*/
// Check for "tel:" URI prefix.
if (text.length() > startPos + 4
&& text.subSequence(startPos, startPos + 4).toString().equalsIgnoreCase("tel:")) {
startPos += 4;
}
int endPos = text.length();
int curPos = startPos;
int foundDigits = 0;
char firstDigit = 'x';
boolean foundWhiteSpaceAfterAreaCode = false;
while (curPos <= endPos) {
char ch;
if (curPos < endPos) {
ch = text.charAt(curPos);
} else {
ch = 27; // fake invalid symbol at end to trigger loop break
}
if (Character.isDigit(ch)) {
if (foundDigits == 0) {
firstDigit = ch;
}
foundDigits++;
if (foundDigits > NANP_MAX_DIGITS) {
// too many digits, stop early
return -1;
}
} else if (Character.isWhitespace(ch)) {
if ((firstDigit == '1' && foundDigits == 4) ||
(foundDigits == 3)) {
foundWhiteSpaceAfterAreaCode = true;
} else if (firstDigit == '1' && foundDigits == 1) {
} else if (foundWhiteSpaceAfterAreaCode
&& ((firstDigit == '1' && (foundDigits == 7)) || (foundDigits == 6))) {
} else {
break;
}
} else if (NANP_ALLOWED_SYMBOLS.indexOf(ch) == -1) {
break;
}
// else it's an allowed symbol
curPos++;
}
if ((firstDigit != '1' && (foundDigits == 7 || foundDigits == 10)) ||
(firstDigit == '1' && foundDigits == 11)) {
// match
return curPos;
}
return -1;
} | [
"private",
"static",
"int",
"findNanpMatchEnd",
"(",
"CharSequence",
"text",
",",
"int",
"startPos",
")",
"{",
"/*\n * A few interesting cases:\n * 94043 # too short, ignore\n * 123456789012 # too long, ignore\n ... | Checks to see if there is a valid phone number in the input, starting at the specified
offset. If so, the index of the last character + 1 is returned. The input is assumed
to begin with a non-whitespace character.
@return Exclusive end position, or -1 if not a match. | [
"Checks",
"to",
"see",
"if",
"there",
"is",
"a",
"valid",
"phone",
"number",
"in",
"the",
"input",
"starting",
"at",
"the",
"specified",
"offset",
".",
"If",
"so",
"the",
"index",
"of",
"the",
"last",
"character",
"+",
"1",
"is",
"returned",
".",
"The"... | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L1184-L1254 |
36,419 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java | Utils.spanWillOverlap | private static boolean spanWillOverlap(Spannable spanText, URLSpan[] spanList, int start,
int end) {
if (start == end) {
// empty span, ignore
return false;
}
for (URLSpan span : spanList) {
int existingStart = spanText.getSpanStart(span);
int existingEnd = spanText.getSpanEnd(span);
if ((start >= existingStart && start < existingEnd) ||
end > existingStart && end <= existingEnd) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
CharSequence seq = spanText.subSequence(start, end);
Log.v(TAG, "Not linkifying " + seq + " as phone number due to overlap");
}
return true;
}
}
return false;
} | java | private static boolean spanWillOverlap(Spannable spanText, URLSpan[] spanList, int start,
int end) {
if (start == end) {
// empty span, ignore
return false;
}
for (URLSpan span : spanList) {
int existingStart = spanText.getSpanStart(span);
int existingEnd = spanText.getSpanEnd(span);
if ((start >= existingStart && start < existingEnd) ||
end > existingStart && end <= existingEnd) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
CharSequence seq = spanText.subSequence(start, end);
Log.v(TAG, "Not linkifying " + seq + " as phone number due to overlap");
}
return true;
}
}
return false;
} | [
"private",
"static",
"boolean",
"spanWillOverlap",
"(",
"Spannable",
"spanText",
",",
"URLSpan",
"[",
"]",
"spanList",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"==",
"end",
")",
"{",
"// empty span, ignore",
"return",
"false",
... | Determines whether a new span at [start,end) will overlap with any existing span. | [
"Determines",
"whether",
"a",
"new",
"span",
"at",
"[",
"start",
"end",
")",
"will",
"overlap",
"with",
"any",
"existing",
"span",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/Utils.java#L1259-L1279 |
36,420 | Shusshu/Android-RecurrencePicker | library/src/main/java/be/billington/calendar/recurrencepicker/EventRecurrenceFormatter.java | EventRecurrenceFormatter.dayToUtilDay | private static int dayToUtilDay(int day) {
switch (day) {
case EventRecurrence.SU: return Calendar.SUNDAY;
case EventRecurrence.MO: return Calendar.MONDAY;
case EventRecurrence.TU: return Calendar.TUESDAY;
case EventRecurrence.WE: return Calendar.WEDNESDAY;
case EventRecurrence.TH: return Calendar.THURSDAY;
case EventRecurrence.FR: return Calendar.FRIDAY;
case EventRecurrence.SA: return Calendar.SATURDAY;
default: throw new IllegalArgumentException("bad day argument: " + day);
}
} | java | private static int dayToUtilDay(int day) {
switch (day) {
case EventRecurrence.SU: return Calendar.SUNDAY;
case EventRecurrence.MO: return Calendar.MONDAY;
case EventRecurrence.TU: return Calendar.TUESDAY;
case EventRecurrence.WE: return Calendar.WEDNESDAY;
case EventRecurrence.TH: return Calendar.THURSDAY;
case EventRecurrence.FR: return Calendar.FRIDAY;
case EventRecurrence.SA: return Calendar.SATURDAY;
default: throw new IllegalArgumentException("bad day argument: " + day);
}
} | [
"private",
"static",
"int",
"dayToUtilDay",
"(",
"int",
"day",
")",
"{",
"switch",
"(",
"day",
")",
"{",
"case",
"EventRecurrence",
".",
"SU",
":",
"return",
"Calendar",
".",
"SUNDAY",
";",
"case",
"EventRecurrence",
".",
"MO",
":",
"return",
"Calendar",
... | Converts EventRecurrence's day of week to DateUtil's day of week.
@param day of week as an EventRecurrence value
@return day of week as a DateUtil value. | [
"Converts",
"EventRecurrence",
"s",
"day",
"of",
"week",
"to",
"DateUtil",
"s",
"day",
"of",
"week",
"."
] | 4f0ae74482e4d46d57a8fb13b4b7980a8613f4af | https://github.com/Shusshu/Android-RecurrencePicker/blob/4f0ae74482e4d46d57a8fb13b4b7980a8613f4af/library/src/main/java/be/billington/calendar/recurrencepicker/EventRecurrenceFormatter.java#L160-L171 |
36,421 | EasyPost/easypost-java | src/main/java/com/easypost/model/Report.java | Report.reportURL | protected static String reportURL(String type) throws EasyPostException {
try {
String urlType = URLEncoder.encode(type, "UTF-8").toLowerCase();
return String.format("%s/reports/%s/", EasyPost.API_BASE, urlType);
} catch (java.io.UnsupportedEncodingException e) {
throw new EasyPostException("Undetermined Report Type");
}
} | java | protected static String reportURL(String type) throws EasyPostException {
try {
String urlType = URLEncoder.encode(type, "UTF-8").toLowerCase();
return String.format("%s/reports/%s/", EasyPost.API_BASE, urlType);
} catch (java.io.UnsupportedEncodingException e) {
throw new EasyPostException("Undetermined Report Type");
}
} | [
"protected",
"static",
"String",
"reportURL",
"(",
"String",
"type",
")",
"throws",
"EasyPostException",
"{",
"try",
"{",
"String",
"urlType",
"=",
"URLEncoder",
".",
"encode",
"(",
"type",
",",
"\"UTF-8\"",
")",
".",
"toLowerCase",
"(",
")",
";",
"return",
... | generate report URL pattern | [
"generate",
"report",
"URL",
"pattern"
] | 323b4cece5fa0f607e80a7e66cb1ce20c9d5b844 | https://github.com/EasyPost/easypost-java/blob/323b4cece5fa0f607e80a7e66cb1ce20c9d5b844/src/main/java/com/easypost/model/Report.java#L121-L128 |
36,422 | EasyPost/easypost-java | src/main/java/com/easypost/model/Item.java | Item.retrieveReference | public Item retrieveReference(String name, String value) throws EasyPostException {
return retrieveReference(name, value, null);
} | java | public Item retrieveReference(String name, String value) throws EasyPostException {
return retrieveReference(name, value, null);
} | [
"public",
"Item",
"retrieveReference",
"(",
"String",
"name",
",",
"String",
"value",
")",
"throws",
"EasyPostException",
"{",
"return",
"retrieveReference",
"(",
"name",
",",
"value",
",",
"null",
")",
";",
"}"
] | retrieve by custom reference | [
"retrieve",
"by",
"custom",
"reference"
] | 323b4cece5fa0f607e80a7e66cb1ce20c9d5b844 | https://github.com/EasyPost/easypost-java/blob/323b4cece5fa0f607e80a7e66cb1ce20c9d5b844/src/main/java/com/easypost/model/Item.java#L147-L149 |
36,423 | dbmdz/iiif-presentation-api | iiif-presentation-frontend-impl-springmvc/src/main/java/de/digitalcollections/iiif/presentation/frontend/impl/springmvc/controller/v2/IIIFPresentationApiController.java | IIIFPresentationApiController.getOriginalUri | private URI getOriginalUri(HttpServletRequest request) {
String requestUrl = request.getRequestURL().toString();
String incomingScheme = URI.create(requestUrl).getScheme();
String originalScheme = request.getHeader("X-Forwarded-Proto");
if (originalScheme != null && !incomingScheme.equals(originalScheme)) {
return URI.create(requestUrl.replaceFirst("^" + incomingScheme, originalScheme));
} else {
return URI.create(requestUrl);
}
} | java | private URI getOriginalUri(HttpServletRequest request) {
String requestUrl = request.getRequestURL().toString();
String incomingScheme = URI.create(requestUrl).getScheme();
String originalScheme = request.getHeader("X-Forwarded-Proto");
if (originalScheme != null && !incomingScheme.equals(originalScheme)) {
return URI.create(requestUrl.replaceFirst("^" + incomingScheme, originalScheme));
} else {
return URI.create(requestUrl);
}
} | [
"private",
"URI",
"getOriginalUri",
"(",
"HttpServletRequest",
"request",
")",
"{",
"String",
"requestUrl",
"=",
"request",
".",
"getRequestURL",
"(",
")",
".",
"toString",
"(",
")",
";",
"String",
"incomingScheme",
"=",
"URI",
".",
"create",
"(",
"requestUrl"... | Return the URL as it was originally received from a possible frontend proxy.
@param request Incoming request
@return URL as it was received at the frontend proxy | [
"Return",
"the",
"URL",
"as",
"it",
"was",
"originally",
"received",
"from",
"a",
"possible",
"frontend",
"proxy",
"."
] | 8b551d3717eed2620bc9e50b4c23f945b73b9cea | https://github.com/dbmdz/iiif-presentation-api/blob/8b551d3717eed2620bc9e50b4c23f945b73b9cea/iiif-presentation-frontend-impl-springmvc/src/main/java/de/digitalcollections/iiif/presentation/frontend/impl/springmvc/controller/v2/IIIFPresentationApiController.java#L163-L172 |
36,424 | Unicon/cas-addons | src/main/java/net/unicon/cas/addons/authentication/strong/oath/totp/TOTP.java | TOTP.hmacSha | private static byte[] hmacSha(String crypto, byte[] keyBytes, byte[] text) {
try {
Mac hmac;
hmac = Mac.getInstance(crypto);
SecretKeySpec macKey = new SecretKeySpec(keyBytes, "RAW");
hmac.init(macKey);
return hmac.doFinal(text);
} catch (GeneralSecurityException gse) {
throw new UndeclaredThrowableException(gse);
}
} | java | private static byte[] hmacSha(String crypto, byte[] keyBytes, byte[] text) {
try {
Mac hmac;
hmac = Mac.getInstance(crypto);
SecretKeySpec macKey = new SecretKeySpec(keyBytes, "RAW");
hmac.init(macKey);
return hmac.doFinal(text);
} catch (GeneralSecurityException gse) {
throw new UndeclaredThrowableException(gse);
}
} | [
"private",
"static",
"byte",
"[",
"]",
"hmacSha",
"(",
"String",
"crypto",
",",
"byte",
"[",
"]",
"keyBytes",
",",
"byte",
"[",
"]",
"text",
")",
"{",
"try",
"{",
"Mac",
"hmac",
";",
"hmac",
"=",
"Mac",
".",
"getInstance",
"(",
"crypto",
")",
";",
... | This method uses the JCE to provide the crypto algorithm. HMAC computes a
Hashed Message Authentication Code with the crypto hash algorithm as a
parameter.
@param crypto
: the crypto algorithm (HmacSHA1, HmacSHA256, HmacSHA512)
@param keyBytes
: the bytes to use for the HMAC key
@param text
: the message or text to be authenticated | [
"This",
"method",
"uses",
"the",
"JCE",
"to",
"provide",
"the",
"crypto",
"algorithm",
".",
"HMAC",
"computes",
"a",
"Hashed",
"Message",
"Authentication",
"Code",
"with",
"the",
"crypto",
"hash",
"algorithm",
"as",
"a",
"parameter",
"."
] | 9af2d4896e02d30622acec638539bfc41f45e480 | https://github.com/Unicon/cas-addons/blob/9af2d4896e02d30622acec638539bfc41f45e480/src/main/java/net/unicon/cas/addons/authentication/strong/oath/totp/TOTP.java#L35-L45 |
36,425 | Unicon/cas-addons | src/main/java/net/unicon/cas/addons/authentication/strong/oath/totp/TOTP.java | TOTP.generateTOTP | public static int generateTOTP(byte[] key, long time, int digits, String crypto) {
byte[] msg = ByteBuffer.allocate(8).putLong(time).array();
byte[] hash = hmacSha(crypto, key, msg);
// put selected bytes into result int
int offset = hash[hash.length - 1] & 0xf;
int binary = ((hash[offset] & 0x7f) << 24) | ((hash[offset + 1] & 0xff) << 16) | ((hash[offset + 2] & 0xff) << 8) | (hash[offset + 3] & 0xff);
int otp = binary % DIGITS_POWER[digits];
return otp;
} | java | public static int generateTOTP(byte[] key, long time, int digits, String crypto) {
byte[] msg = ByteBuffer.allocate(8).putLong(time).array();
byte[] hash = hmacSha(crypto, key, msg);
// put selected bytes into result int
int offset = hash[hash.length - 1] & 0xf;
int binary = ((hash[offset] & 0x7f) << 24) | ((hash[offset + 1] & 0xff) << 16) | ((hash[offset + 2] & 0xff) << 8) | (hash[offset + 3] & 0xff);
int otp = binary % DIGITS_POWER[digits];
return otp;
} | [
"public",
"static",
"int",
"generateTOTP",
"(",
"byte",
"[",
"]",
"key",
",",
"long",
"time",
",",
"int",
"digits",
",",
"String",
"crypto",
")",
"{",
"byte",
"[",
"]",
"msg",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"8",
")",
".",
"putLong",
"(",
... | This method generates a TOTP value for the given set of parameters.
@param key
: the shared secret
@param time
: a value that reflects a time
@param digits
: number of digits to return
@param crypto
: the crypto function to use
@return digits | [
"This",
"method",
"generates",
"a",
"TOTP",
"value",
"for",
"the",
"given",
"set",
"of",
"parameters",
"."
] | 9af2d4896e02d30622acec638539bfc41f45e480 | https://github.com/Unicon/cas-addons/blob/9af2d4896e02d30622acec638539bfc41f45e480/src/main/java/net/unicon/cas/addons/authentication/strong/oath/totp/TOTP.java#L62-L75 |
36,426 | Unicon/cas-addons | src/main/java/net/unicon/cas/addons/serviceregistry/JsonServiceRegistryDao.java | JsonServiceRegistryDao.loadServices | @SuppressWarnings("unchecked")
public final List<RegisteredService> loadServices() {
logger.info("Loading Registered Services from: [ {} ]...", this.servicesConfigFile);
final List<RegisteredService> resolvedServices = new ArrayList<RegisteredService>();
try {
final Map<String, List> m = unmarshalServicesRegistryResourceIntoMap();
if (m != null) {
final Iterator<Map> i = m.get(SERVICES_KEY).iterator();
while (i.hasNext()) {
final Map<?, ?> record = i.next();
final String svcId = ((String) record.get(SERVICES_ID_KEY));
final RegisteredService svc = getRegisteredServiceInstance(svcId);
if (svc != null) {
resolvedServices.add(this.objectMapper.convertValue(record, svc.getClass()));
logger.debug("Unmarshaled {}: {}", svc.getClass().getSimpleName(), record);
}
}
synchronized (this.mutexMonitor) {
this.delegateServiceRegistryDao.setRegisteredServices(resolvedServices);
}
}
} catch (final Throwable e) {
throw new RuntimeException(e);
}
return resolvedServices;
} | java | @SuppressWarnings("unchecked")
public final List<RegisteredService> loadServices() {
logger.info("Loading Registered Services from: [ {} ]...", this.servicesConfigFile);
final List<RegisteredService> resolvedServices = new ArrayList<RegisteredService>();
try {
final Map<String, List> m = unmarshalServicesRegistryResourceIntoMap();
if (m != null) {
final Iterator<Map> i = m.get(SERVICES_KEY).iterator();
while (i.hasNext()) {
final Map<?, ?> record = i.next();
final String svcId = ((String) record.get(SERVICES_ID_KEY));
final RegisteredService svc = getRegisteredServiceInstance(svcId);
if (svc != null) {
resolvedServices.add(this.objectMapper.convertValue(record, svc.getClass()));
logger.debug("Unmarshaled {}: {}", svc.getClass().getSimpleName(), record);
}
}
synchronized (this.mutexMonitor) {
this.delegateServiceRegistryDao.setRegisteredServices(resolvedServices);
}
}
} catch (final Throwable e) {
throw new RuntimeException(e);
}
return resolvedServices;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"List",
"<",
"RegisteredService",
">",
"loadServices",
"(",
")",
"{",
"logger",
".",
"info",
"(",
"\"Loading Registered Services from: [ {} ]...\"",
",",
"this",
".",
"servicesConfigFile",
")",
"... | This method is used as a Spring bean loadServices-method
as well as the reloading method when the change in the services definition resource is detected at runtime | [
"This",
"method",
"is",
"used",
"as",
"a",
"Spring",
"bean",
"loadServices",
"-",
"method",
"as",
"well",
"as",
"the",
"reloading",
"method",
"when",
"the",
"change",
"in",
"the",
"services",
"definition",
"resource",
"is",
"detected",
"at",
"runtime"
] | 9af2d4896e02d30622acec638539bfc41f45e480 | https://github.com/Unicon/cas-addons/blob/9af2d4896e02d30622acec638539bfc41f45e480/src/main/java/net/unicon/cas/addons/serviceregistry/JsonServiceRegistryDao.java#L112-L141 |
36,427 | Unicon/cas-addons | src/main/java/net/unicon/cas/addons/persondir/JsonBackedComplexStubPersonAttributeDao.java | JsonBackedComplexStubPersonAttributeDao.init | public void init() throws Exception {
try {
unmarshalAndSetBackingMap();
}
//If we get to this point, the JSON file is well-formed, but its structure does not map into PersonDir backingMap generic type - fail fast.
catch (final ClassCastException ex) {
throw new BeanCreationException(String.format("The semantic structure of the person attributes JSON config is not correct. Please fix it in this resource: [%s]",
this.personAttributesConfigFile.getURI()));
}
} | java | public void init() throws Exception {
try {
unmarshalAndSetBackingMap();
}
//If we get to this point, the JSON file is well-formed, but its structure does not map into PersonDir backingMap generic type - fail fast.
catch (final ClassCastException ex) {
throw new BeanCreationException(String.format("The semantic structure of the person attributes JSON config is not correct. Please fix it in this resource: [%s]",
this.personAttributesConfigFile.getURI()));
}
} | [
"public",
"void",
"init",
"(",
")",
"throws",
"Exception",
"{",
"try",
"{",
"unmarshalAndSetBackingMap",
"(",
")",
";",
"}",
"//If we get to this point, the JSON file is well-formed, but its structure does not map into PersonDir backingMap generic type - fail fast.",
"catch",
"(",
... | Init method un-marshals JSON representation of the person attributes. | [
"Init",
"method",
"un",
"-",
"marshals",
"JSON",
"representation",
"of",
"the",
"person",
"attributes",
"."
] | 9af2d4896e02d30622acec638539bfc41f45e480 | https://github.com/Unicon/cas-addons/blob/9af2d4896e02d30622acec638539bfc41f45e480/src/main/java/net/unicon/cas/addons/persondir/JsonBackedComplexStubPersonAttributeDao.java#L50-L59 |
36,428 | Unicon/cas-addons | src/main/java/net/unicon/cas/addons/persondir/JsonBackedComplexStubPersonAttributeDao.java | JsonBackedComplexStubPersonAttributeDao.onApplicationEvent | @Override
public void onApplicationEvent(final ResourceChangeDetectingEventNotifier.ResourceChangedEvent resourceChangedEvent) {
try {
if (!resourceChangedEvent.getResourceUri().equals(this.personAttributesConfigFile.getURI())) {
//Not our resource. Just get out of here.
return;
}
}
catch (final Throwable e) {
logger.error("An exception is caught while trying to access JSON resource: ", e);
return;
}
final Map<String, Map<String, List<Object>>> savedBackingMap;
synchronized (this.synchronizationMonitor) {
//Save the current state here in order to restore it, should the error occur.
savedBackingMap = super.getBackingMap();
}
try {
unmarshalAndSetBackingMap();
}
catch (final Throwable ex) {
logger.error("An exception is caught during reloading of the JSON configuration:", ex);
//Restore the old state. If the error occurs at this stage, well nothing we could do here. Just propagate the exception.
synchronized (this.synchronizationMonitor) {
super.setBackingMap(savedBackingMap);
}
}
} | java | @Override
public void onApplicationEvent(final ResourceChangeDetectingEventNotifier.ResourceChangedEvent resourceChangedEvent) {
try {
if (!resourceChangedEvent.getResourceUri().equals(this.personAttributesConfigFile.getURI())) {
//Not our resource. Just get out of here.
return;
}
}
catch (final Throwable e) {
logger.error("An exception is caught while trying to access JSON resource: ", e);
return;
}
final Map<String, Map<String, List<Object>>> savedBackingMap;
synchronized (this.synchronizationMonitor) {
//Save the current state here in order to restore it, should the error occur.
savedBackingMap = super.getBackingMap();
}
try {
unmarshalAndSetBackingMap();
}
catch (final Throwable ex) {
logger.error("An exception is caught during reloading of the JSON configuration:", ex);
//Restore the old state. If the error occurs at this stage, well nothing we could do here. Just propagate the exception.
synchronized (this.synchronizationMonitor) {
super.setBackingMap(savedBackingMap);
}
}
} | [
"@",
"Override",
"public",
"void",
"onApplicationEvent",
"(",
"final",
"ResourceChangeDetectingEventNotifier",
".",
"ResourceChangedEvent",
"resourceChangedEvent",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"resourceChangedEvent",
".",
"getResourceUri",
"(",
")",
".",
"equ... | Reload person attributes when JSON config is changed. In case of un-marshaling errors,
or any other errors, do not disturb running CAS server by propagating the exceptions,
but instead log the error and leave the previously cached person attributes state alone.
@param resourceChangedEvent event representing the resource change. Might not actually correspond
to this JSON config file, so the URI of it needs to be checked first. | [
"Reload",
"person",
"attributes",
"when",
"JSON",
"config",
"is",
"changed",
".",
"In",
"case",
"of",
"un",
"-",
"marshaling",
"errors",
"or",
"any",
"other",
"errors",
"do",
"not",
"disturb",
"running",
"CAS",
"server",
"by",
"propagating",
"the",
"exceptio... | 9af2d4896e02d30622acec638539bfc41f45e480 | https://github.com/Unicon/cas-addons/blob/9af2d4896e02d30622acec638539bfc41f45e480/src/main/java/net/unicon/cas/addons/persondir/JsonBackedComplexStubPersonAttributeDao.java#L69-L97 |
36,429 | Unicon/cas-addons | src/main/java/net/unicon/cas/addons/authentication/handler/ShiroHashServicePasswordEncoder.java | ShiroHashServicePasswordEncoder.init | void init() throws Throwable {
if (this.digestAlgorithmName != null) {
this.hashService.setHashAlgorithmName(this.digestAlgorithmName);
}
if (this.hashIterations > 0) {
this.hashService.setHashIterations(this.hashIterations);
}
} | java | void init() throws Throwable {
if (this.digestAlgorithmName != null) {
this.hashService.setHashAlgorithmName(this.digestAlgorithmName);
}
if (this.hashIterations > 0) {
this.hashService.setHashIterations(this.hashIterations);
}
} | [
"void",
"init",
"(",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"this",
".",
"digestAlgorithmName",
"!=",
"null",
")",
"{",
"this",
".",
"hashService",
".",
"setHashAlgorithmName",
"(",
"this",
".",
"digestAlgorithmName",
")",
";",
"}",
"if",
"(",
"this",... | This method is only intended to be called by the infrastructure code managing instances of this class
once during initialization of this instance | [
"This",
"method",
"is",
"only",
"intended",
"to",
"be",
"called",
"by",
"the",
"infrastructure",
"code",
"managing",
"instances",
"of",
"this",
"class",
"once",
"during",
"initialization",
"of",
"this",
"instance"
] | 9af2d4896e02d30622acec638539bfc41f45e480 | https://github.com/Unicon/cas-addons/blob/9af2d4896e02d30622acec638539bfc41f45e480/src/main/java/net/unicon/cas/addons/authentication/handler/ShiroHashServicePasswordEncoder.java#L68-L75 |
36,430 | bbottema/outlook-message-parser | src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java | OutlookMessageParser.parseMsg | public OutlookMessage parseMsg(@Nonnull final InputStream msgFileStream)
throws IOException {
// the .msg file, like a file system, contains directories and documents within this directories
// we now gain access to the root node and recursively go through the complete 'filesystem'.
final OutlookMessage msg = new OutlookMessage(rtf2htmlConverter);
try {
checkDirectoryEntry(new POIFSFileSystem(msgFileStream).getRoot(), msg);
} finally {
msgFileStream.close();
}
convertHeaders(msg);
return msg;
} | java | public OutlookMessage parseMsg(@Nonnull final InputStream msgFileStream)
throws IOException {
// the .msg file, like a file system, contains directories and documents within this directories
// we now gain access to the root node and recursively go through the complete 'filesystem'.
final OutlookMessage msg = new OutlookMessage(rtf2htmlConverter);
try {
checkDirectoryEntry(new POIFSFileSystem(msgFileStream).getRoot(), msg);
} finally {
msgFileStream.close();
}
convertHeaders(msg);
return msg;
} | [
"public",
"OutlookMessage",
"parseMsg",
"(",
"@",
"Nonnull",
"final",
"InputStream",
"msgFileStream",
")",
"throws",
"IOException",
"{",
"// the .msg file, like a file system, contains directories and documents within this directories",
"// we now gain access to the root node and recursi... | Parses a .msg file provided by an input stream.
@param msgFileStream The .msg file as a InputStream.
@return A {@link OutlookMessage} object representing the .msg file.
@throws IOException Thrown if the file could not be loaded or parsed. | [
"Parses",
"a",
".",
"msg",
"file",
"provided",
"by",
"an",
"input",
"stream",
"."
] | ea7d59da33c8a62dfc2e0aa64d2f8f7c903ccb0e | https://github.com/bbottema/outlook-message-parser/blob/ea7d59da33c8a62dfc2e0aa64d2f8f7c903ccb0e/src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java#L97-L109 |
36,431 | bbottema/outlook-message-parser | src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java | OutlookMessageParser.getBytesFromStream | private byte[] getBytesFromStream(final InputStream dstream)
throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final byte[] buffer = new byte[1024];
int read;
while ((read = dstream.read(buffer)) > 0) {
baos.write(buffer, 0, read);
}
return baos.toByteArray();
} | java | private byte[] getBytesFromStream(final InputStream dstream)
throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final byte[] buffer = new byte[1024];
int read;
while ((read = dstream.read(buffer)) > 0) {
baos.write(buffer, 0, read);
}
return baos.toByteArray();
} | [
"private",
"byte",
"[",
"]",
"getBytesFromStream",
"(",
"final",
"InputStream",
"dstream",
")",
"throws",
"IOException",
"{",
"final",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"final",
"byte",
"[",
"]",
"buffer",
"=",
... | Reads the bytes from the stream to a byte array.
@param dstream The stream to be read from.
@return An array of bytes.
@throws IOException If the stream cannot be read properly. | [
"Reads",
"the",
"bytes",
"from",
"the",
"stream",
"to",
"a",
"byte",
"array",
"."
] | ea7d59da33c8a62dfc2e0aa64d2f8f7c903ccb0e | https://github.com/bbottema/outlook-message-parser/blob/ea7d59da33c8a62dfc2e0aa64d2f8f7c903ccb0e/src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java#L491-L500 |
36,432 | bbottema/outlook-message-parser | src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookFileAttachment.java | OutlookFileAttachment.setProperty | public void setProperty(final OutlookMessageProperty msgProp) {
final String name = msgProp.getClazz();
final Object value = msgProp.getData();
if (name != null && value != null) {
switch (name) {
case "3701":
setSize(msgProp.getSize());
setData((byte[]) value);
break;
case "3704":
setFilename((String) value);
break;
case "3707":
setLongFilename((String) value);
break;
case "370e":
setMimeTag((String) value);
break;
case "3703":
setExtension((String) value);
break;
default:
// property to ignore, for full list see properties-list.txt
}
}
} | java | public void setProperty(final OutlookMessageProperty msgProp) {
final String name = msgProp.getClazz();
final Object value = msgProp.getData();
if (name != null && value != null) {
switch (name) {
case "3701":
setSize(msgProp.getSize());
setData((byte[]) value);
break;
case "3704":
setFilename((String) value);
break;
case "3707":
setLongFilename((String) value);
break;
case "370e":
setMimeTag((String) value);
break;
case "3703":
setExtension((String) value);
break;
default:
// property to ignore, for full list see properties-list.txt
}
}
} | [
"public",
"void",
"setProperty",
"(",
"final",
"OutlookMessageProperty",
"msgProp",
")",
"{",
"final",
"String",
"name",
"=",
"msgProp",
".",
"getClazz",
"(",
")",
";",
"final",
"Object",
"value",
"=",
"msgProp",
".",
"getData",
"(",
")",
";",
"if",
"(",
... | Sets the property specified by the name parameter. Unknown names are ignored. | [
"Sets",
"the",
"property",
"specified",
"by",
"the",
"name",
"parameter",
".",
"Unknown",
"names",
"are",
"ignored",
"."
] | ea7d59da33c8a62dfc2e0aa64d2f8f7c903ccb0e | https://github.com/bbottema/outlook-message-parser/blob/ea7d59da33c8a62dfc2e0aa64d2f8f7c903ccb0e/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookFileAttachment.java#L39-L65 |
36,433 | WASdev/tool.accelerate.core | liberty-starter-common/src/main/java/com/ibm/liberty/starter/service/common/api/v1/ProviderEndpoint.java | ProviderEndpoint.getStringResource | private String getStringResource(String path) {
InputStream in = getClass().getResourceAsStream(path);
StringBuilder index = new StringBuilder();
char[] buffer = new char[1024];
int read = 0;
try(InputStreamReader reader = new InputStreamReader(in)){
while((read = reader.read(buffer)) != -1) {
index.append(buffer, 0, read);
}
} catch (IOException e) {
//just return what we've got
return index.toString();
}
return index.toString();
} | java | private String getStringResource(String path) {
InputStream in = getClass().getResourceAsStream(path);
StringBuilder index = new StringBuilder();
char[] buffer = new char[1024];
int read = 0;
try(InputStreamReader reader = new InputStreamReader(in)){
while((read = reader.read(buffer)) != -1) {
index.append(buffer, 0, read);
}
} catch (IOException e) {
//just return what we've got
return index.toString();
}
return index.toString();
} | [
"private",
"String",
"getStringResource",
"(",
"String",
"path",
")",
"{",
"InputStream",
"in",
"=",
"getClass",
"(",
")",
".",
"getResourceAsStream",
"(",
"path",
")",
";",
"StringBuilder",
"index",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"char",
"[",
... | read the description contained in the index.html file | [
"read",
"the",
"description",
"contained",
"in",
"the",
"index",
".",
"html",
"file"
] | 6511da654a69a25a76573eb76eefff349d9c4d80 | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-common/src/main/java/com/ibm/liberty/starter/service/common/api/v1/ProviderEndpoint.java#L46-L61 |
36,434 | WASdev/tool.accelerate.core | liberty-starter-application/src/main/java/com/ibm/liberty/starter/ServiceConnector.java | ServiceConnector.getServiceObjectFromId | public Service getServiceObjectFromId(String id) {
log.fine("Return service object for " + id);
Service service = null;
for (Service s : services.getServices()) {
if (id.equals(s.getId())) {
return s;
}
}
return service;
} | java | public Service getServiceObjectFromId(String id) {
log.fine("Return service object for " + id);
Service service = null;
for (Service s : services.getServices()) {
if (id.equals(s.getId())) {
return s;
}
}
return service;
} | [
"public",
"Service",
"getServiceObjectFromId",
"(",
"String",
"id",
")",
"{",
"log",
".",
"fine",
"(",
"\"Return service object for \"",
"+",
"id",
")",
";",
"Service",
"service",
"=",
"null",
";",
"for",
"(",
"Service",
"s",
":",
"services",
".",
"getServic... | Returns the service object associated with the given id | [
"Returns",
"the",
"service",
"object",
"associated",
"with",
"the",
"given",
"id"
] | 6511da654a69a25a76573eb76eefff349d9c4d80 | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-application/src/main/java/com/ibm/liberty/starter/ServiceConnector.java#L72-L81 |
36,435 | WASdev/tool.accelerate.core | liberty-starter-application/src/main/java/com/ibm/liberty/starter/GitHubConnector.java | GitHubConnector.createGitRepository | public File createGitRepository(String repositoryName) throws IOException {
RepositoryService service = new RepositoryService();
service.getClient().setOAuth2Token(oAuthToken);
Repository repository = new Repository();
repository.setName(repositoryName);
repository = service.createRepository(repository);
repositoryLocation = repository.getHtmlUrl();
CloneCommand cloneCommand = Git.cloneRepository()
.setURI(repository.getCloneUrl())
.setDirectory(localGitDirectory);
addAuth(cloneCommand);
try {
localRepository = cloneCommand.call();
} catch (GitAPIException e) {
throw new IOException("Error cloning to local file system", e);
}
return localGitDirectory;
} | java | public File createGitRepository(String repositoryName) throws IOException {
RepositoryService service = new RepositoryService();
service.getClient().setOAuth2Token(oAuthToken);
Repository repository = new Repository();
repository.setName(repositoryName);
repository = service.createRepository(repository);
repositoryLocation = repository.getHtmlUrl();
CloneCommand cloneCommand = Git.cloneRepository()
.setURI(repository.getCloneUrl())
.setDirectory(localGitDirectory);
addAuth(cloneCommand);
try {
localRepository = cloneCommand.call();
} catch (GitAPIException e) {
throw new IOException("Error cloning to local file system", e);
}
return localGitDirectory;
} | [
"public",
"File",
"createGitRepository",
"(",
"String",
"repositoryName",
")",
"throws",
"IOException",
"{",
"RepositoryService",
"service",
"=",
"new",
"RepositoryService",
"(",
")",
";",
"service",
".",
"getClient",
"(",
")",
".",
"setOAuth2Token",
"(",
"oAuthTo... | Creates a repository on GitHub and in a local temporary directory. This is a one time operation as
once it is created on GitHub and locally it cannot be recreated. | [
"Creates",
"a",
"repository",
"on",
"GitHub",
"and",
"in",
"a",
"local",
"temporary",
"directory",
".",
"This",
"is",
"a",
"one",
"time",
"operation",
"as",
"once",
"it",
"is",
"created",
"on",
"GitHub",
"and",
"locally",
"it",
"cannot",
"be",
"recreated",... | 6511da654a69a25a76573eb76eefff349d9c4d80 | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-application/src/main/java/com/ibm/liberty/starter/GitHubConnector.java#L52-L70 |
36,436 | WASdev/tool.accelerate.core | liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java | DomUtil.hasChildNode | public static boolean hasChildNode(Node parentNode, String nodeName){
return getChildNode(parentNode, nodeName, null) != null ? true : false;
} | java | public static boolean hasChildNode(Node parentNode, String nodeName){
return getChildNode(parentNode, nodeName, null) != null ? true : false;
} | [
"public",
"static",
"boolean",
"hasChildNode",
"(",
"Node",
"parentNode",
",",
"String",
"nodeName",
")",
"{",
"return",
"getChildNode",
"(",
"parentNode",
",",
"nodeName",
",",
"null",
")",
"!=",
"null",
"?",
"true",
":",
"false",
";",
"}"
] | Determine if the parent node contains a child node with matching name
@param parentNode - the parent node
@param nodeName - name of child node to match
@return boolean value to indicate whether the parent node contains matching child node | [
"Determine",
"if",
"the",
"parent",
"node",
"contains",
"a",
"child",
"node",
"with",
"matching",
"name"
] | 6511da654a69a25a76573eb76eefff349d9c4d80 | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java#L39-L41 |
36,437 | WASdev/tool.accelerate.core | liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java | DomUtil.getChildNode | public static Node getChildNode(Node parentNode, String name, String value){
List<Node> matchingChildren = getChildren(parentNode, name, value);
return (matchingChildren.size() > 0) ? matchingChildren.get(0) : null;
} | java | public static Node getChildNode(Node parentNode, String name, String value){
List<Node> matchingChildren = getChildren(parentNode, name, value);
return (matchingChildren.size() > 0) ? matchingChildren.get(0) : null;
} | [
"public",
"static",
"Node",
"getChildNode",
"(",
"Node",
"parentNode",
",",
"String",
"name",
",",
"String",
"value",
")",
"{",
"List",
"<",
"Node",
">",
"matchingChildren",
"=",
"getChildren",
"(",
"parentNode",
",",
"name",
",",
"value",
")",
";",
"retur... | Get the matching child node
@param parentNode - the parent node
@param name - name of child node to match
@param value - value of child node to match, specify null to not match value
@return the child node if a match was found, null otherwise | [
"Get",
"the",
"matching",
"child",
"node"
] | 6511da654a69a25a76573eb76eefff349d9c4d80 | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java#L50-L53 |
36,438 | WASdev/tool.accelerate.core | liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java | DomUtil.getGrandchildNode | public static Node getGrandchildNode(Node parentNode, String childNodeName, String grandChildNodeName, String grandChildNodeValue){
List<Node> matchingChildren = getChildren(parentNode, childNodeName, null);
for(Node child : matchingChildren){
Node matchingGrandChild = getChildNode(child, grandChildNodeName, grandChildNodeValue);
if(matchingGrandChild != null){
return matchingGrandChild;
}
}
return null;
} | java | public static Node getGrandchildNode(Node parentNode, String childNodeName, String grandChildNodeName, String grandChildNodeValue){
List<Node> matchingChildren = getChildren(parentNode, childNodeName, null);
for(Node child : matchingChildren){
Node matchingGrandChild = getChildNode(child, grandChildNodeName, grandChildNodeValue);
if(matchingGrandChild != null){
return matchingGrandChild;
}
}
return null;
} | [
"public",
"static",
"Node",
"getGrandchildNode",
"(",
"Node",
"parentNode",
",",
"String",
"childNodeName",
",",
"String",
"grandChildNodeName",
",",
"String",
"grandChildNodeValue",
")",
"{",
"List",
"<",
"Node",
">",
"matchingChildren",
"=",
"getChildren",
"(",
... | Get the matching grand child node
@param parentNode - the parent node
@param childNodeName - name of child node to match
@param grandChildNodeName - name of grand child node to match
@param grandChildNodeValue - value of grand child node to match
@return the grand child node if a match was found, null otherwise | [
"Get",
"the",
"matching",
"grand",
"child",
"node"
] | 6511da654a69a25a76573eb76eefff349d9c4d80 | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java#L63-L72 |
36,439 | WASdev/tool.accelerate.core | liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java | DomUtil.getChildren | private static List<Node> getChildren(Node parentNode, String name, String value){
List<Node> childNodes = new ArrayList<Node>();
if(parentNode == null || name == null){
return childNodes;
}
if (parentNode.getNodeType() == Node.ELEMENT_NODE && parentNode.hasChildNodes()) {
NodeList children = parentNode.getChildNodes();
for(int i=0; i < children.getLength(); i++){
Node child = children.item(i);
if(child != null && name.equals(child.getNodeName()) && (value == null || value.equals(child.getTextContent()))){
childNodes.add(child);
}
}
}
return childNodes;
} | java | private static List<Node> getChildren(Node parentNode, String name, String value){
List<Node> childNodes = new ArrayList<Node>();
if(parentNode == null || name == null){
return childNodes;
}
if (parentNode.getNodeType() == Node.ELEMENT_NODE && parentNode.hasChildNodes()) {
NodeList children = parentNode.getChildNodes();
for(int i=0; i < children.getLength(); i++){
Node child = children.item(i);
if(child != null && name.equals(child.getNodeName()) && (value == null || value.equals(child.getTextContent()))){
childNodes.add(child);
}
}
}
return childNodes;
} | [
"private",
"static",
"List",
"<",
"Node",
">",
"getChildren",
"(",
"Node",
"parentNode",
",",
"String",
"name",
",",
"String",
"value",
")",
"{",
"List",
"<",
"Node",
">",
"childNodes",
"=",
"new",
"ArrayList",
"<",
"Node",
">",
"(",
")",
";",
"if",
... | Get all matching child nodes
@param parentNode - the parent node
@param name - name of child node to match
@param value - value of child node to match, specify null to not match value
@return matching child nodes | [
"Get",
"all",
"matching",
"child",
"nodes"
] | 6511da654a69a25a76573eb76eefff349d9c4d80 | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java#L81-L98 |
36,440 | WASdev/tool.accelerate.core | liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java | DomUtil.addChildNode | public static Node addChildNode(Document doc, Node parentNode, String childName, String childValue){
if(doc == null || parentNode == null || childName == null){
return null;
}
Node childNode = doc.createElement(childName);
if(childValue != null){
childNode.setTextContent(childValue);
}
parentNode.appendChild(childNode);
return childNode;
} | java | public static Node addChildNode(Document doc, Node parentNode, String childName, String childValue){
if(doc == null || parentNode == null || childName == null){
return null;
}
Node childNode = doc.createElement(childName);
if(childValue != null){
childNode.setTextContent(childValue);
}
parentNode.appendChild(childNode);
return childNode;
} | [
"public",
"static",
"Node",
"addChildNode",
"(",
"Document",
"doc",
",",
"Node",
"parentNode",
",",
"String",
"childName",
",",
"String",
"childValue",
")",
"{",
"if",
"(",
"doc",
"==",
"null",
"||",
"parentNode",
"==",
"null",
"||",
"childName",
"==",
"nu... | Add a child node
@param parentNode - the parent node
@param childName - name of child node to create
@param childValue - value of child node
@return the child node | [
"Add",
"a",
"child",
"node"
] | 6511da654a69a25a76573eb76eefff349d9c4d80 | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java#L107-L117 |
36,441 | WASdev/tool.accelerate.core | liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java | DomUtil.findOrAddChildNode | public static Node findOrAddChildNode(Document doc, Node parentNode, String childName, String childValue){
Node matchingChild = getChildNode(parentNode, childName, childValue);
return matchingChild != null ? matchingChild : addChildNode(doc, parentNode, childName, childValue);
} | java | public static Node findOrAddChildNode(Document doc, Node parentNode, String childName, String childValue){
Node matchingChild = getChildNode(parentNode, childName, childValue);
return matchingChild != null ? matchingChild : addChildNode(doc, parentNode, childName, childValue);
} | [
"public",
"static",
"Node",
"findOrAddChildNode",
"(",
"Document",
"doc",
",",
"Node",
"parentNode",
",",
"String",
"childName",
",",
"String",
"childValue",
")",
"{",
"Node",
"matchingChild",
"=",
"getChildNode",
"(",
"parentNode",
",",
"childName",
",",
"child... | Get the matching child node. Create a node if it doens't already exist
@param parentNode - the parent node
@param childName - name of child node to match
@param childValue - value of child node to match, specify null to not match value
@return the child node | [
"Get",
"the",
"matching",
"child",
"node",
".",
"Create",
"a",
"node",
"if",
"it",
"doens",
"t",
"already",
"exist"
] | 6511da654a69a25a76573eb76eefff349d9c4d80 | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-application/src/main/java/com/ibm/liberty/starter/build/maven/DomUtil.java#L126-L129 |
36,442 | conductor-framework/conductor | src/main/java/io/ddavison/conductor/Locomotive.java | Locomotive.waitForElement | public WebElement waitForElement(By by) {
int attempts = 0;
int size = driver.findElements(by).size();
while (size == 0) {
size = driver.findElements(by).size();
if (attempts == MAX_ATTEMPTS) fail(String.format("Could not find %s after %d seconds",
by.toString(),
MAX_ATTEMPTS));
attempts++;
try {
Thread.sleep(1000); // sleep for 1 second.
} catch (Exception x) {
fail("Failed due to an exception during Thread.sleep!");
x.printStackTrace();
}
}
if (size > 1) System.err.println("WARN: There are more than 1 " + by.toString() + " 's!");
return driver.findElement(by);
} | java | public WebElement waitForElement(By by) {
int attempts = 0;
int size = driver.findElements(by).size();
while (size == 0) {
size = driver.findElements(by).size();
if (attempts == MAX_ATTEMPTS) fail(String.format("Could not find %s after %d seconds",
by.toString(),
MAX_ATTEMPTS));
attempts++;
try {
Thread.sleep(1000); // sleep for 1 second.
} catch (Exception x) {
fail("Failed due to an exception during Thread.sleep!");
x.printStackTrace();
}
}
if (size > 1) System.err.println("WARN: There are more than 1 " + by.toString() + " 's!");
return driver.findElement(by);
} | [
"public",
"WebElement",
"waitForElement",
"(",
"By",
"by",
")",
"{",
"int",
"attempts",
"=",
"0",
";",
"int",
"size",
"=",
"driver",
".",
"findElements",
"(",
"by",
")",
".",
"size",
"(",
")",
";",
"while",
"(",
"size",
"==",
"0",
")",
"{",
"size",... | Method that acts as an arbiter of implicit timeouts of sorts.. sort of like a Wait For Ajax method. | [
"Method",
"that",
"acts",
"as",
"an",
"arbiter",
"of",
"implicit",
"timeouts",
"of",
"sorts",
"..",
"sort",
"of",
"like",
"a",
"Wait",
"For",
"Ajax",
"method",
"."
] | fc9843cfd633c358ce4f0708672c0081e6ef3e22 | https://github.com/conductor-framework/conductor/blob/fc9843cfd633c358ce4f0708672c0081e6ef3e22/src/main/java/io/ddavison/conductor/Locomotive.java#L269-L290 |
36,443 | conductor-framework/conductor | src/main/java/io/ddavison/conductor/LocomotiveConfig.java | LocomotiveConfig.url | @Override
public String url() {
String url = "";
if (!StringUtils.isEmpty(baseUrl())) {
url = baseUrl() + path();
} else {
if (!StringUtils.isEmpty(properties.getProperty(Constants.DEFAULT_PROPERTY_URL))) {
url = properties.getProperty(Constants.DEFAULT_PROPERTY_URL);
}
if (testConfig != null && (!StringUtils.isEmpty(testConfig.url()))) {
url = testConfig.url();
}
if (!StringUtils.isEmpty(JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_URL))) {
url = JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_URL);
}
}
return url;
} | java | @Override
public String url() {
String url = "";
if (!StringUtils.isEmpty(baseUrl())) {
url = baseUrl() + path();
} else {
if (!StringUtils.isEmpty(properties.getProperty(Constants.DEFAULT_PROPERTY_URL))) {
url = properties.getProperty(Constants.DEFAULT_PROPERTY_URL);
}
if (testConfig != null && (!StringUtils.isEmpty(testConfig.url()))) {
url = testConfig.url();
}
if (!StringUtils.isEmpty(JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_URL))) {
url = JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_URL);
}
}
return url;
} | [
"@",
"Override",
"public",
"String",
"url",
"(",
")",
"{",
"String",
"url",
"=",
"\"\"",
";",
"if",
"(",
"!",
"StringUtils",
".",
"isEmpty",
"(",
"baseUrl",
"(",
")",
")",
")",
"{",
"url",
"=",
"baseUrl",
"(",
")",
"+",
"path",
"(",
")",
";",
"... | Url that automated tests will be testing.
@return If a base url is provided it'll return the base url + path, otherwise it'll fallback to the normal url params. | [
"Url",
"that",
"automated",
"tests",
"will",
"be",
"testing",
"."
] | fc9843cfd633c358ce4f0708672c0081e6ef3e22 | https://github.com/conductor-framework/conductor/blob/fc9843cfd633c358ce4f0708672c0081e6ef3e22/src/main/java/io/ddavison/conductor/LocomotiveConfig.java#L34-L51 |
36,444 | LinkedDataFragments/Server.Java | src/main/java/org/linkeddatafragments/datasource/DataSourceFactory.java | DataSourceFactory.create | public static IDataSource create(JsonObject config) throws DataSourceCreationException {
String title = config.getAsJsonPrimitive("title").getAsString();
String description = config.getAsJsonPrimitive("description").getAsString();
String typeName = config.getAsJsonPrimitive("type").getAsString();
JsonObject settings = config.getAsJsonObject("settings");
final IDataSourceType type = DataSourceTypesRegistry.getType(typeName);
if ( type == null )
throw new UnknownDataSourceTypeException(typeName);
return type.createDataSource( title, description, settings );
} | java | public static IDataSource create(JsonObject config) throws DataSourceCreationException {
String title = config.getAsJsonPrimitive("title").getAsString();
String description = config.getAsJsonPrimitive("description").getAsString();
String typeName = config.getAsJsonPrimitive("type").getAsString();
JsonObject settings = config.getAsJsonObject("settings");
final IDataSourceType type = DataSourceTypesRegistry.getType(typeName);
if ( type == null )
throw new UnknownDataSourceTypeException(typeName);
return type.createDataSource( title, description, settings );
} | [
"public",
"static",
"IDataSource",
"create",
"(",
"JsonObject",
"config",
")",
"throws",
"DataSourceCreationException",
"{",
"String",
"title",
"=",
"config",
".",
"getAsJsonPrimitive",
"(",
"\"title\"",
")",
".",
"getAsString",
"(",
")",
";",
"String",
"descripti... | Create a datasource using a JSON config
@param config
@return datasource interface
@throws DataSourceCreationException | [
"Create",
"a",
"datasource",
"using",
"a",
"JSON",
"config"
] | 15f72a0675cb761a986f0d0d40b36a83dd482b1e | https://github.com/LinkedDataFragments/Server.Java/blob/15f72a0675cb761a986f0d0d40b36a83dd482b1e/src/main/java/org/linkeddatafragments/datasource/DataSourceFactory.java#L21-L33 |
36,445 | LinkedDataFragments/Server.Java | src/main/java/org/linkeddatafragments/servlet/LinkedDataFragmentServlet.java | LinkedDataFragmentServlet.getDataSource | private IDataSource getDataSource(HttpServletRequest request) throws DataSourceNotFoundException {
String contextPath = request.getContextPath();
String requestURI = request.getRequestURI();
String path = contextPath == null
? requestURI
: requestURI.substring(contextPath.length());
if (path.equals("/") || path.isEmpty()) {
final String baseURL = FragmentRequestParserBase.extractBaseURL(request, config);
return new IndexDataSource(baseURL, dataSources);
}
String dataSourceName = path.substring(1);
IDataSource dataSource = dataSources.get(dataSourceName);
if (dataSource == null) {
throw new DataSourceNotFoundException(dataSourceName);
}
return dataSource;
} | java | private IDataSource getDataSource(HttpServletRequest request) throws DataSourceNotFoundException {
String contextPath = request.getContextPath();
String requestURI = request.getRequestURI();
String path = contextPath == null
? requestURI
: requestURI.substring(contextPath.length());
if (path.equals("/") || path.isEmpty()) {
final String baseURL = FragmentRequestParserBase.extractBaseURL(request, config);
return new IndexDataSource(baseURL, dataSources);
}
String dataSourceName = path.substring(1);
IDataSource dataSource = dataSources.get(dataSourceName);
if (dataSource == null) {
throw new DataSourceNotFoundException(dataSourceName);
}
return dataSource;
} | [
"private",
"IDataSource",
"getDataSource",
"(",
"HttpServletRequest",
"request",
")",
"throws",
"DataSourceNotFoundException",
"{",
"String",
"contextPath",
"=",
"request",
".",
"getContextPath",
"(",
")",
";",
"String",
"requestURI",
"=",
"request",
".",
"getRequestU... | Get the datasource
@param request
@return
@throws IOException | [
"Get",
"the",
"datasource"
] | 15f72a0675cb761a986f0d0d40b36a83dd482b1e | https://github.com/LinkedDataFragments/Server.Java/blob/15f72a0675cb761a986f0d0d40b36a83dd482b1e/src/main/java/org/linkeddatafragments/servlet/LinkedDataFragmentServlet.java#L132-L151 |
36,446 | LinkedDataFragments/Server.Java | src/main/java/org/linkeddatafragments/fragments/LinkedDataFragmentBase.java | LinkedDataFragmentBase.addMetadata | public void addMetadata( final Model model )
{
final Resource datasetId = model.createResource( getDatasetURI() );
final Resource fragmentId = model.createResource( fragmentURL );
datasetId.addProperty( CommonResources.RDF_TYPE, CommonResources.VOID_DATASET );
datasetId.addProperty( CommonResources.RDF_TYPE, CommonResources.HYDRA_COLLECTION );
datasetId.addProperty( CommonResources.VOID_SUBSET, fragmentId );
Literal itemsPerPage = model.createTypedLiteral(this.getMaxPageSize());
datasetId.addProperty( CommonResources.HYDRA_ITEMSPERPAGE, itemsPerPage);
fragmentId.addProperty( CommonResources.RDF_TYPE, CommonResources.HYDRA_COLLECTION );
fragmentId.addProperty( CommonResources.RDF_TYPE, CommonResources.HYDRA_PAGEDCOLLECTION );
} | java | public void addMetadata( final Model model )
{
final Resource datasetId = model.createResource( getDatasetURI() );
final Resource fragmentId = model.createResource( fragmentURL );
datasetId.addProperty( CommonResources.RDF_TYPE, CommonResources.VOID_DATASET );
datasetId.addProperty( CommonResources.RDF_TYPE, CommonResources.HYDRA_COLLECTION );
datasetId.addProperty( CommonResources.VOID_SUBSET, fragmentId );
Literal itemsPerPage = model.createTypedLiteral(this.getMaxPageSize());
datasetId.addProperty( CommonResources.HYDRA_ITEMSPERPAGE, itemsPerPage);
fragmentId.addProperty( CommonResources.RDF_TYPE, CommonResources.HYDRA_COLLECTION );
fragmentId.addProperty( CommonResources.RDF_TYPE, CommonResources.HYDRA_PAGEDCOLLECTION );
} | [
"public",
"void",
"addMetadata",
"(",
"final",
"Model",
"model",
")",
"{",
"final",
"Resource",
"datasetId",
"=",
"model",
".",
"createResource",
"(",
"getDatasetURI",
"(",
")",
")",
";",
"final",
"Resource",
"fragmentId",
"=",
"model",
".",
"createResource",
... | Adds some basic metadata to the given RDF model.
This method may be overridden in subclasses.
@param model | [
"Adds",
"some",
"basic",
"metadata",
"to",
"the",
"given",
"RDF",
"model",
".",
"This",
"method",
"may",
"be",
"overridden",
"in",
"subclasses",
"."
] | 15f72a0675cb761a986f0d0d40b36a83dd482b1e | https://github.com/LinkedDataFragments/Server.Java/blob/15f72a0675cb761a986f0d0d40b36a83dd482b1e/src/main/java/org/linkeddatafragments/fragments/LinkedDataFragmentBase.java#L121-L135 |
36,447 | LinkedDataFragments/Server.Java | src/main/java/org/linkeddatafragments/fragments/LinkedDataFragmentBase.java | LinkedDataFragmentBase.addControls | public void addControls( final Model model )
{
final URIBuilder pagedURL;
try {
pagedURL = new URIBuilder( fragmentURL );
}
catch ( URISyntaxException e ) {
throw new IllegalArgumentException( e );
}
final Resource fragmentId = model.createResource( fragmentURL );
final Resource firstPageId =
model.createResource(
pagedURL.setParameter(ILinkedDataFragmentRequest.PARAMETERNAME_PAGE,
"1").toString() );
fragmentId.addProperty( CommonResources.HYDRA_FIRSTPAGE, firstPageId );
if ( pageNumber > 1) {
final String prevPageNumber = Long.toString( pageNumber - 1 );
final Resource prevPageId =
model.createResource(
pagedURL.setParameter(ILinkedDataFragmentRequest.PARAMETERNAME_PAGE,
prevPageNumber).toString() );
fragmentId.addProperty( CommonResources.HYDRA_PREVIOUSPAGE, prevPageId );
}
if ( ! isLastPage ) {
final String nextPageNumber = Long.toString( pageNumber + 1 );
final Resource nextPageId =
model.createResource(
pagedURL.setParameter(ILinkedDataFragmentRequest.PARAMETERNAME_PAGE,
nextPageNumber).toString() );
fragmentId.addProperty( CommonResources.HYDRA_NEXTPAGE, nextPageId );
}
} | java | public void addControls( final Model model )
{
final URIBuilder pagedURL;
try {
pagedURL = new URIBuilder( fragmentURL );
}
catch ( URISyntaxException e ) {
throw new IllegalArgumentException( e );
}
final Resource fragmentId = model.createResource( fragmentURL );
final Resource firstPageId =
model.createResource(
pagedURL.setParameter(ILinkedDataFragmentRequest.PARAMETERNAME_PAGE,
"1").toString() );
fragmentId.addProperty( CommonResources.HYDRA_FIRSTPAGE, firstPageId );
if ( pageNumber > 1) {
final String prevPageNumber = Long.toString( pageNumber - 1 );
final Resource prevPageId =
model.createResource(
pagedURL.setParameter(ILinkedDataFragmentRequest.PARAMETERNAME_PAGE,
prevPageNumber).toString() );
fragmentId.addProperty( CommonResources.HYDRA_PREVIOUSPAGE, prevPageId );
}
if ( ! isLastPage ) {
final String nextPageNumber = Long.toString( pageNumber + 1 );
final Resource nextPageId =
model.createResource(
pagedURL.setParameter(ILinkedDataFragmentRequest.PARAMETERNAME_PAGE,
nextPageNumber).toString() );
fragmentId.addProperty( CommonResources.HYDRA_NEXTPAGE, nextPageId );
}
} | [
"public",
"void",
"addControls",
"(",
"final",
"Model",
"model",
")",
"{",
"final",
"URIBuilder",
"pagedURL",
";",
"try",
"{",
"pagedURL",
"=",
"new",
"URIBuilder",
"(",
"fragmentURL",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"thro... | Adds an RDF description of page links to the given RDF model.
This method may be overridden in subclasses.
@param model | [
"Adds",
"an",
"RDF",
"description",
"of",
"page",
"links",
"to",
"the",
"given",
"RDF",
"model",
".",
"This",
"method",
"may",
"be",
"overridden",
"in",
"subclasses",
"."
] | 15f72a0675cb761a986f0d0d40b36a83dd482b1e | https://github.com/LinkedDataFragments/Server.Java/blob/15f72a0675cb761a986f0d0d40b36a83dd482b1e/src/main/java/org/linkeddatafragments/fragments/LinkedDataFragmentBase.java#L142-L180 |
36,448 | LinkedDataFragments/Server.Java | src/main/java/org/linkeddatafragments/datasource/hdt/HdtBasedRequestProcessorForTPFs.java | HdtBasedRequestProcessorForTPFs.toTriple | private Triple toTriple(TripleID tripleId) {
return new Triple(
dictionary.getNode(tripleId.getSubject(), TripleComponentRole.SUBJECT),
dictionary.getNode(tripleId.getPredicate(), TripleComponentRole.PREDICATE),
dictionary.getNode(tripleId.getObject(), TripleComponentRole.OBJECT)
);
} | java | private Triple toTriple(TripleID tripleId) {
return new Triple(
dictionary.getNode(tripleId.getSubject(), TripleComponentRole.SUBJECT),
dictionary.getNode(tripleId.getPredicate(), TripleComponentRole.PREDICATE),
dictionary.getNode(tripleId.getObject(), TripleComponentRole.OBJECT)
);
} | [
"private",
"Triple",
"toTriple",
"(",
"TripleID",
"tripleId",
")",
"{",
"return",
"new",
"Triple",
"(",
"dictionary",
".",
"getNode",
"(",
"tripleId",
".",
"getSubject",
"(",
")",
",",
"TripleComponentRole",
".",
"SUBJECT",
")",
",",
"dictionary",
".",
"getN... | Converts the HDT triple to a Jena Triple.
@param tripleId the HDT triple
@return the Jena triple | [
"Converts",
"the",
"HDT",
"triple",
"to",
"a",
"Jena",
"Triple",
"."
] | 15f72a0675cb761a986f0d0d40b36a83dd482b1e | https://github.com/LinkedDataFragments/Server.Java/blob/15f72a0675cb761a986f0d0d40b36a83dd482b1e/src/main/java/org/linkeddatafragments/datasource/hdt/HdtBasedRequestProcessorForTPFs.java#L172-L178 |
36,449 | dadoonet/testcontainers-java-module-elasticsearch | src/main/java/fr/pilato/elasticsearch/containers/ElasticsearchContainer.java | ElasticsearchContainer.withSecureSetting | public ElasticsearchContainer withSecureSetting(String key, String value) {
securedKeys.put(key, value);
return this;
} | java | public ElasticsearchContainer withSecureSetting(String key, String value) {
securedKeys.put(key, value);
return this;
} | [
"public",
"ElasticsearchContainer",
"withSecureSetting",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"securedKeys",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Define the elasticsearch docker registry base url
@param key Key
@param value Value
@return this | [
"Define",
"the",
"elasticsearch",
"docker",
"registry",
"base",
"url"
] | 780eec66c2999a1e4814f039b2a4559d6a5da408 | https://github.com/dadoonet/testcontainers-java-module-elasticsearch/blob/780eec66c2999a1e4814f039b2a4559d6a5da408/src/main/java/fr/pilato/elasticsearch/containers/ElasticsearchContainer.java#L93-L96 |
36,450 | dadoonet/testcontainers-java-module-elasticsearch | src/main/java/fr/pilato/elasticsearch/containers/ElasticsearchContainer.java | ElasticsearchContainer.withPluginDir | public ElasticsearchContainer withPluginDir(Path pluginDir) {
if (pluginDir == null) {
return this;
}
// When we have a plugin dir, we need to mount it in the docker instance
this.pluginDir = createVolumeDirectory(true);
// We create the volume that will be needed for plugins
addFileSystemBind(this.pluginDir.toString(), "/plugins", BindMode.READ_ONLY);
logger().debug("Installing plugins from [{}]", pluginDir);
try {
Files.list(pluginDir).forEach(path -> {
logger().trace("File found in [{}]: [{}]", pluginDir, path);
if (path.toString().endsWith(".zip")) {
logger().debug("Copying [{}] to [{}]", path.getFileName(), this.pluginDir.toAbsolutePath().toString());
try {
Files.copy(path, this.pluginDir.resolve(path.getFileName()));
withPlugin("file:///tmp/plugins/" + path.getFileName());
} catch (IOException e) {
logger().error("Error while copying", e);
}
}
});
} catch (IOException e) {
logger().error("Error listing plugins", e);
}
return this;
} | java | public ElasticsearchContainer withPluginDir(Path pluginDir) {
if (pluginDir == null) {
return this;
}
// When we have a plugin dir, we need to mount it in the docker instance
this.pluginDir = createVolumeDirectory(true);
// We create the volume that will be needed for plugins
addFileSystemBind(this.pluginDir.toString(), "/plugins", BindMode.READ_ONLY);
logger().debug("Installing plugins from [{}]", pluginDir);
try {
Files.list(pluginDir).forEach(path -> {
logger().trace("File found in [{}]: [{}]", pluginDir, path);
if (path.toString().endsWith(".zip")) {
logger().debug("Copying [{}] to [{}]", path.getFileName(), this.pluginDir.toAbsolutePath().toString());
try {
Files.copy(path, this.pluginDir.resolve(path.getFileName()));
withPlugin("file:///tmp/plugins/" + path.getFileName());
} catch (IOException e) {
logger().error("Error while copying", e);
}
}
});
} catch (IOException e) {
logger().error("Error listing plugins", e);
}
return this;
} | [
"public",
"ElasticsearchContainer",
"withPluginDir",
"(",
"Path",
"pluginDir",
")",
"{",
"if",
"(",
"pluginDir",
"==",
"null",
")",
"{",
"return",
"this",
";",
"}",
"// When we have a plugin dir, we need to mount it in the docker instance",
"this",
".",
"pluginDir",
"="... | Path to plugin dir which contains plugins that needs to be installed
@param pluginDir plugins dir
@return this | [
"Path",
"to",
"plugin",
"dir",
"which",
"contains",
"plugins",
"that",
"needs",
"to",
"be",
"installed"
] | 780eec66c2999a1e4814f039b2a4559d6a5da408 | https://github.com/dadoonet/testcontainers-java-module-elasticsearch/blob/780eec66c2999a1e4814f039b2a4559d6a5da408/src/main/java/fr/pilato/elasticsearch/containers/ElasticsearchContainer.java#L113-L142 |
36,451 | rtyley/android-screenshot-lib | paparazzo/src/main/java/com/github/rtyley/android/screenshot/paparazzo/OnDemandScreenshotService.java | OnDemandScreenshotService.start | public void start() {
Thread thread = new Thread(new LogCatCommandExecutor());
thread.setName(getClass().getSimpleName() + " logcat for " + device.getSerialNumber());
thread.start();
try {
sleep(500); // ignore old output that logcat feeds us
} catch (InterruptedException e) {
}
logListenerCommandShell.activate();
} | java | public void start() {
Thread thread = new Thread(new LogCatCommandExecutor());
thread.setName(getClass().getSimpleName() + " logcat for " + device.getSerialNumber());
thread.start();
try {
sleep(500); // ignore old output that logcat feeds us
} catch (InterruptedException e) {
}
logListenerCommandShell.activate();
} | [
"public",
"void",
"start",
"(",
")",
"{",
"Thread",
"thread",
"=",
"new",
"Thread",
"(",
"new",
"LogCatCommandExecutor",
"(",
")",
")",
";",
"thread",
".",
"setName",
"(",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\" logcat for \"",
"+"... | Start receiving and acting on paparazzo requests from the device. | [
"Start",
"receiving",
"and",
"acting",
"on",
"paparazzo",
"requests",
"from",
"the",
"device",
"."
] | 8714d37ca3e62716953032cf8e55657bc2ed211b | https://github.com/rtyley/android-screenshot-lib/blob/8714d37ca3e62716953032cf8e55657bc2ed211b/paparazzo/src/main/java/com/github/rtyley/android/screenshot/paparazzo/OnDemandScreenshotService.java#L33-L44 |
36,452 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/css/RGBColor.java | RGBColor.rgb | public static RGBColor rgb(int r, int g, int b) {
return new RGBColor(makeRgb(r, g, b));
} | java | public static RGBColor rgb(int r, int g, int b) {
return new RGBColor(makeRgb(r, g, b));
} | [
"public",
"static",
"RGBColor",
"rgb",
"(",
"int",
"r",
",",
"int",
"g",
",",
"int",
"b",
")",
"{",
"return",
"new",
"RGBColor",
"(",
"makeRgb",
"(",
"r",
",",
"g",
",",
"b",
")",
")",
";",
"}"
] | RGB color as r,g,b triple. | [
"RGB",
"color",
"as",
"r",
"g",
"b",
"triple",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/css/RGBColor.java#L70-L72 |
36,453 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java | DocumentStyleImpl.cur | public double cur(Element elem, String prop, boolean force) {
if (JsUtils.isWindow(elem)) {
if ("width".equals(prop)) {
return getContentDocument(elem).getClientWidth();
}
if ("height".equals(prop)) {
return getContentDocument(elem).getClientHeight();
}
elem = GQuery.body;
}
if (force && sizeRegex.test(prop)) {
// make curCSS below resolve width and height (issue #145) when force is true
} else if (elem.getPropertyString(prop) != null
&& (elem.getStyle() == null || elem.getStyle().getProperty(prop) == null)) {
// cases where elem.prop exists instead of elem.style.prop
return elem.getPropertyDouble(prop);
}
String val = curCSS(elem, prop, force);
if ("thick".equalsIgnoreCase(val)) {
return 5;
} else if ("medium".equalsIgnoreCase(val)) {
return 3;
} else if ("thin".equalsIgnoreCase(val)) {
return 1;
}
if (!val.matches("^[\\d\\.]+.*$")) {
val = curCSS(elem, prop, false);
}
val = val.trim().replaceAll("[^\\d\\.\\-]+.*$", "");
return val.isEmpty() ? 0 : Double.parseDouble(val);
} | java | public double cur(Element elem, String prop, boolean force) {
if (JsUtils.isWindow(elem)) {
if ("width".equals(prop)) {
return getContentDocument(elem).getClientWidth();
}
if ("height".equals(prop)) {
return getContentDocument(elem).getClientHeight();
}
elem = GQuery.body;
}
if (force && sizeRegex.test(prop)) {
// make curCSS below resolve width and height (issue #145) when force is true
} else if (elem.getPropertyString(prop) != null
&& (elem.getStyle() == null || elem.getStyle().getProperty(prop) == null)) {
// cases where elem.prop exists instead of elem.style.prop
return elem.getPropertyDouble(prop);
}
String val = curCSS(elem, prop, force);
if ("thick".equalsIgnoreCase(val)) {
return 5;
} else if ("medium".equalsIgnoreCase(val)) {
return 3;
} else if ("thin".equalsIgnoreCase(val)) {
return 1;
}
if (!val.matches("^[\\d\\.]+.*$")) {
val = curCSS(elem, prop, false);
}
val = val.trim().replaceAll("[^\\d\\.\\-]+.*$", "");
return val.isEmpty() ? 0 : Double.parseDouble(val);
} | [
"public",
"double",
"cur",
"(",
"Element",
"elem",
",",
"String",
"prop",
",",
"boolean",
"force",
")",
"{",
"if",
"(",
"JsUtils",
".",
"isWindow",
"(",
"elem",
")",
")",
"{",
"if",
"(",
"\"width\"",
".",
"equals",
"(",
"prop",
")",
")",
"{",
"retu... | Returns the numeric value of a css property.
The parameter force has a special meaning:
- When force is false, returns the value of the css property defined
in the set of style attributes.
- Otherwise it returns the real computed value. | [
"Returns",
"the",
"numeric",
"value",
"of",
"a",
"css",
"property",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java#L46-L77 |
36,454 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java | DocumentStyleImpl.curCSS | public String curCSS(Element elem, String name, boolean force) {
if (elem == null) {
return "";
}
name = fixPropertyName(name);
// value defined in the element style
String ret = elem.getStyle().getProperty(name);
if (force) {
Element toDetach = null;
if (JsUtils.isDetached(elem)) {
// If the element is detached to the DOM we attach temporary to it
toDetach = attachTemporary(elem);
}
if (sizeRegex.test(name)) {
ret = getVisibleSize(elem, name) + "px";
} else if ("opacity".equalsIgnoreCase(name)) {
ret = String.valueOf(getOpacity(elem));
} else {
ret = getComputedStyle(elem, JsUtils.hyphenize(name), name, null);
}
// If the element was previously attached, detached it.
if (toDetach != null) {
toDetach.removeFromParent();
}
}
return ret == null ? "" : ret;
} | java | public String curCSS(Element elem, String name, boolean force) {
if (elem == null) {
return "";
}
name = fixPropertyName(name);
// value defined in the element style
String ret = elem.getStyle().getProperty(name);
if (force) {
Element toDetach = null;
if (JsUtils.isDetached(elem)) {
// If the element is detached to the DOM we attach temporary to it
toDetach = attachTemporary(elem);
}
if (sizeRegex.test(name)) {
ret = getVisibleSize(elem, name) + "px";
} else if ("opacity".equalsIgnoreCase(name)) {
ret = String.valueOf(getOpacity(elem));
} else {
ret = getComputedStyle(elem, JsUtils.hyphenize(name), name, null);
}
// If the element was previously attached, detached it.
if (toDetach != null) {
toDetach.removeFromParent();
}
}
return ret == null ? "" : ret;
} | [
"public",
"String",
"curCSS",
"(",
"Element",
"elem",
",",
"String",
"name",
",",
"boolean",
"force",
")",
"{",
"if",
"(",
"elem",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"name",
"=",
"fixPropertyName",
"(",
"name",
")",
";",
"// value defi... | Return the string value of a css property of an element.
The parameter force has a special meaning:
- When force is false, returns the value of the css property defined
in the set of style attributes.
- Otherwise it returns the real computed value.
For instance if you do not define 'display=none' in the element style but in
the css stylesheet, it will return an empty string unless you pass the
parameter force=true. | [
"Return",
"the",
"string",
"value",
"of",
"a",
"css",
"property",
"of",
"an",
"element",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java#L91-L122 |
36,455 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java | DocumentStyleImpl.fixInlineElement | private void fixInlineElement(Element e) {
if (e.getClientHeight() == 0 && e.getClientWidth() == 0
&& "inline".equals(curCSS(e, "display", true))) {
setStyleProperty(e, "display", "inline-block");
setStyleProperty(e, "width", "auto");
setStyleProperty(e, "height", "auto");
}
} | java | private void fixInlineElement(Element e) {
if (e.getClientHeight() == 0 && e.getClientWidth() == 0
&& "inline".equals(curCSS(e, "display", true))) {
setStyleProperty(e, "display", "inline-block");
setStyleProperty(e, "width", "auto");
setStyleProperty(e, "height", "auto");
}
} | [
"private",
"void",
"fixInlineElement",
"(",
"Element",
"e",
")",
"{",
"if",
"(",
"e",
".",
"getClientHeight",
"(",
")",
"==",
"0",
"&&",
"e",
".",
"getClientWidth",
"(",
")",
"==",
"0",
"&&",
"\"inline\"",
".",
"equals",
"(",
"curCSS",
"(",
"e",
",",... | inline elements do not have width nor height unless we set it to inline-block | [
"inline",
"elements",
"do",
"not",
"have",
"width",
"nor",
"height",
"unless",
"we",
"set",
"it",
"to",
"inline",
"-",
"block"
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java#L170-L177 |
36,456 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java | DocumentStyleImpl.setStyleProperty | public void setStyleProperty(Element e, String prop, String val) {
if (e == null || prop == null) {
return;
}
prop = fixPropertyName(prop);
// put it in lower-case only when all letters are upper-case, to avoid
// modifying already camelized properties
if (prop.matches("^[A-Z]+$")) {
prop = prop.toLowerCase();
}
prop = JsUtils.camelize(prop);
if (val == null || val.trim().length() == 0) {
removeStyleProperty(e, prop);
} else {
if (val.matches("-?[\\d\\.]+") && !cssNumberRegex.test(prop)) {
val += "px";
}
e.getStyle().setProperty(prop, val);
}
} | java | public void setStyleProperty(Element e, String prop, String val) {
if (e == null || prop == null) {
return;
}
prop = fixPropertyName(prop);
// put it in lower-case only when all letters are upper-case, to avoid
// modifying already camelized properties
if (prop.matches("^[A-Z]+$")) {
prop = prop.toLowerCase();
}
prop = JsUtils.camelize(prop);
if (val == null || val.trim().length() == 0) {
removeStyleProperty(e, prop);
} else {
if (val.matches("-?[\\d\\.]+") && !cssNumberRegex.test(prop)) {
val += "px";
}
e.getStyle().setProperty(prop, val);
}
} | [
"public",
"void",
"setStyleProperty",
"(",
"Element",
"e",
",",
"String",
"prop",
",",
"String",
"val",
")",
"{",
"if",
"(",
"e",
"==",
"null",
"||",
"prop",
"==",
"null",
")",
"{",
"return",
";",
"}",
"prop",
"=",
"fixPropertyName",
"(",
"prop",
")"... | Set the value of a style property of an element. | [
"Set",
"the",
"value",
"of",
"a",
"style",
"property",
"of",
"an",
"element",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java#L236-L255 |
36,457 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java | DocumentStyleImpl.defaultDisplay | public String defaultDisplay(String tagName) {
String ret = elemdisplay.get(tagName);
if (ret == null) {
Element e = DOM.createElement(tagName);
Document.get().getBody().appendChild(e);
ret = curCSS(e, "display", false);
e.removeFromParent();
if (ret == null || ret.matches("(|none)")) {
ret = "block";
}
elemdisplay.put(tagName, ret);
}
return ret;
} | java | public String defaultDisplay(String tagName) {
String ret = elemdisplay.get(tagName);
if (ret == null) {
Element e = DOM.createElement(tagName);
Document.get().getBody().appendChild(e);
ret = curCSS(e, "display", false);
e.removeFromParent();
if (ret == null || ret.matches("(|none)")) {
ret = "block";
}
elemdisplay.put(tagName, ret);
}
return ret;
} | [
"public",
"String",
"defaultDisplay",
"(",
"String",
"tagName",
")",
"{",
"String",
"ret",
"=",
"elemdisplay",
".",
"get",
"(",
"tagName",
")",
";",
"if",
"(",
"ret",
"==",
"null",
")",
"{",
"Element",
"e",
"=",
"DOM",
".",
"createElement",
"(",
"tagNa... | Returns the default display value for each html tag. | [
"Returns",
"the",
"default",
"display",
"value",
"for",
"each",
"html",
"tag",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java#L270-L283 |
36,458 | mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/model/BatchResponse.java | BatchResponse.setItems | public void setItems(java.util.Collection<java.util.Map<String,AttributeValue>> items) {
if (items == null) {
this.items = null;
return;
}
java.util.List<java.util.Map<String,AttributeValue>> itemsCopy = new java.util.ArrayList<java.util.Map<String,AttributeValue>>(items.size());
itemsCopy.addAll(items);
this.items = itemsCopy;
} | java | public void setItems(java.util.Collection<java.util.Map<String,AttributeValue>> items) {
if (items == null) {
this.items = null;
return;
}
java.util.List<java.util.Map<String,AttributeValue>> itemsCopy = new java.util.ArrayList<java.util.Map<String,AttributeValue>>(items.size());
itemsCopy.addAll(items);
this.items = itemsCopy;
} | [
"public",
"void",
"setItems",
"(",
"java",
".",
"util",
".",
"Collection",
"<",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"AttributeValue",
">",
">",
"items",
")",
"{",
"if",
"(",
"items",
"==",
"null",
")",
"{",
"this",
".",
"items",
"=... | Sets the value of the Items property for this object.
@param items The new value for the Items property for this object. | [
"Sets",
"the",
"value",
"of",
"the",
"Items",
"property",
"for",
"this",
"object",
"."
] | 4b230ac843494cb10e46ddc2848f5b5d377d7b72 | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/model/BatchResponse.java#L55-L64 |
36,459 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java | Effects.queueAnimation | public void queueAnimation(final GQAnimation anim, final int duration) {
if (isOff()) {
anim.onStart();
anim.onComplete();
} else {
queue(anim.e, DEFAULT_NAME, new Function() {
public void cancel(Element e) {
Animation anim = (Animation) data(e, GQAnimation.ACTUAL_ANIMATION, null);
if (anim != null) {
anim.cancel();
}
}
public void f(Element e) {
anim.run(duration);
}
});
}
} | java | public void queueAnimation(final GQAnimation anim, final int duration) {
if (isOff()) {
anim.onStart();
anim.onComplete();
} else {
queue(anim.e, DEFAULT_NAME, new Function() {
public void cancel(Element e) {
Animation anim = (Animation) data(e, GQAnimation.ACTUAL_ANIMATION, null);
if (anim != null) {
anim.cancel();
}
}
public void f(Element e) {
anim.run(duration);
}
});
}
} | [
"public",
"void",
"queueAnimation",
"(",
"final",
"GQAnimation",
"anim",
",",
"final",
"int",
"duration",
")",
"{",
"if",
"(",
"isOff",
"(",
")",
")",
"{",
"anim",
".",
"onStart",
"(",
")",
";",
"anim",
".",
"onComplete",
"(",
")",
";",
"}",
"else",
... | Queue an animation for an element.
The goal of this method is to reuse animations.
@param e
@param anim
@param duration | [
"Queue",
"an",
"animation",
"for",
"an",
"element",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java#L122-L140 |
36,460 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java | Effects.vendorProperty | public static String vendorProperty(String prop) {
return vendorPropNames.get(prop) != null ? vendorPropNames.get(prop) : prop;
} | java | public static String vendorProperty(String prop) {
return vendorPropNames.get(prop) != null ? vendorPropNames.get(prop) : prop;
} | [
"public",
"static",
"String",
"vendorProperty",
"(",
"String",
"prop",
")",
"{",
"return",
"vendorPropNames",
".",
"get",
"(",
"prop",
")",
"!=",
"null",
"?",
"vendorPropNames",
".",
"get",
"(",
"prop",
")",
":",
"prop",
";",
"}"
] | Get the cached vendor property name. | [
"Get",
"the",
"cached",
"vendor",
"property",
"name",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java#L166-L168 |
36,461 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java | Effects.slideToggle | public Effects slideToggle(Function... f) {
return as(Effects).slideToggle(Speed.DEFAULT, f);
} | java | public Effects slideToggle(Function... f) {
return as(Effects).slideToggle(Speed.DEFAULT, f);
} | [
"public",
"Effects",
"slideToggle",
"(",
"Function",
"...",
"f",
")",
"{",
"return",
"as",
"(",
"Effects",
")",
".",
"slideToggle",
"(",
"Speed",
".",
"DEFAULT",
",",
"f",
")",
";",
"}"
] | Toggle the visibility of all matched elements by adjusting their height and firing an optional
callback after completion. Only the height is adjusted for this animation, causing all matched
elements to be hidden or shown in a "sliding" manner | [
"Toggle",
"the",
"visibility",
"of",
"all",
"matched",
"elements",
"by",
"adjusting",
"their",
"height",
"and",
"firing",
"an",
"optional",
"callback",
"after",
"completion",
".",
"Only",
"the",
"height",
"is",
"adjusted",
"for",
"this",
"animation",
"causing",
... | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java#L582-L584 |
36,462 | ArcBees/gwtquery | samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java | GwtQueryBenchModule.initResultsTable | private void initResultsTable(DeferredSelector[] dg, Benchmark... benchs) {
int numRows = dg.length;
grid = new FlexTable();
grid.addStyleName("resultstable");
RootPanel.get("results").clear();
RootPanel.get("results").add(grid);
grid.setText(0, 0, "Selector");
for (int i=0; i < benchs.length; i++) {
grid.setText(0, i+1, benchs[i].getId());
}
for (int i = 0; i < numRows; i++) {
grid.setText(i+1, 0, dg[i].getSelector());
for (int j = 0; j < benchs.length; j++) {
grid.setText(i+1, j+1, "-");
}
}
} | java | private void initResultsTable(DeferredSelector[] dg, Benchmark... benchs) {
int numRows = dg.length;
grid = new FlexTable();
grid.addStyleName("resultstable");
RootPanel.get("results").clear();
RootPanel.get("results").add(grid);
grid.setText(0, 0, "Selector");
for (int i=0; i < benchs.length; i++) {
grid.setText(0, i+1, benchs[i].getId());
}
for (int i = 0; i < numRows; i++) {
grid.setText(i+1, 0, dg[i].getSelector());
for (int j = 0; j < benchs.length; j++) {
grid.setText(i+1, j+1, "-");
}
}
} | [
"private",
"void",
"initResultsTable",
"(",
"DeferredSelector",
"[",
"]",
"dg",
",",
"Benchmark",
"...",
"benchs",
")",
"{",
"int",
"numRows",
"=",
"dg",
".",
"length",
";",
"grid",
"=",
"new",
"FlexTable",
"(",
")",
";",
"grid",
".",
"addStyleName",
"("... | Reset the result table | [
"Reset",
"the",
"result",
"table"
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java#L413-L431 |
36,463 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Callbacks.java | Callbacks.add | public Callbacks add(com.google.gwt.core.client.Callback<?, ?>... c) {
addAll((Object[]) c);
return this;
} | java | public Callbacks add(com.google.gwt.core.client.Callback<?, ?>... c) {
addAll((Object[]) c);
return this;
} | [
"public",
"Callbacks",
"add",
"(",
"com",
".",
"google",
".",
"gwt",
".",
"core",
".",
"client",
".",
"Callback",
"<",
"?",
",",
"?",
">",
"...",
"c",
")",
"{",
"addAll",
"(",
"(",
"Object",
"[",
"]",
")",
"c",
")",
";",
"return",
"this",
";",
... | Add a Callback or a collection of callbacks to a callback list. | [
"Add",
"a",
"Callback",
"or",
"a",
"collection",
"of",
"callbacks",
"to",
"a",
"callback",
"list",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Callbacks.java#L76-L79 |
36,464 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Callbacks.java | Callbacks.fire | public Callbacks fire(Object... o) {
if (!done) {
done = isOnce;
if (isMemory) {
memory = new ArrayList<>(Arrays.asList(o));
}
if (stack != null)
for (Object c : stack) {
if (!run(c, o) && stopOnFalse) {
break;
}
}
}
return this;
} | java | public Callbacks fire(Object... o) {
if (!done) {
done = isOnce;
if (isMemory) {
memory = new ArrayList<>(Arrays.asList(o));
}
if (stack != null)
for (Object c : stack) {
if (!run(c, o) && stopOnFalse) {
break;
}
}
}
return this;
} | [
"public",
"Callbacks",
"fire",
"(",
"Object",
"...",
"o",
")",
"{",
"if",
"(",
"!",
"done",
")",
"{",
"done",
"=",
"isOnce",
";",
"if",
"(",
"isMemory",
")",
"{",
"memory",
"=",
"new",
"ArrayList",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"o",
")... | Call all of the callbacks with the given arguments. | [
"Call",
"all",
"of",
"the",
"callbacks",
"with",
"the",
"given",
"arguments",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Callbacks.java#L112-L126 |
36,465 | mboudreau/Alternator | src/main/java/com/michelboudreau/alternator/AlternatorDBHandler.java | AlternatorDBHandler.save | public synchronized void save(String persistence) {
try {
createObjectMapper().writeValue(new File(persistence), tableList);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
} | java | public synchronized void save(String persistence) {
try {
createObjectMapper().writeValue(new File(persistence), tableList);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
} | [
"public",
"synchronized",
"void",
"save",
"(",
"String",
"persistence",
")",
"{",
"try",
"{",
"createObjectMapper",
"(",
")",
".",
"writeValue",
"(",
"new",
"File",
"(",
"persistence",
")",
",",
"tableList",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",... | Maybe save automatically on destroy? | [
"Maybe",
"save",
"automatically",
"on",
"destroy?"
] | 4b230ac843494cb10e46ddc2848f5b5d377d7b72 | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/michelboudreau/alternator/AlternatorDBHandler.java#L129-L135 |
36,466 | mboudreau/Alternator | src/main/java/com/michelboudreau/alternator/AlternatorDBHandler.java | AlternatorDBHandler.createObjectMapper | public ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY)
.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.NONE)
.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE)
.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
return mapper;
} | java | public ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY)
.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.NONE)
.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE)
.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
return mapper;
} | [
"public",
"ObjectMapper",
"createObjectMapper",
"(",
")",
"{",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"mapper",
".",
"setVisibility",
"(",
"PropertyAccessor",
".",
"FIELD",
",",
"JsonAutoDetect",
".",
"Visibility",
".",
"ANY",
")",
... | Not sure about this. If correct and only need one, only create one instance | [
"Not",
"sure",
"about",
"this",
".",
"If",
"correct",
"and",
"only",
"need",
"one",
"only",
"create",
"one",
"instance"
] | 4b230ac843494cb10e46ddc2848f5b5d377d7b72 | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/michelboudreau/alternator/AlternatorDBHandler.java#L156-L167 |
36,467 | mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/model/AttributeValue.java | AttributeValue.setSS | public void setSS(java.util.Collection<String> sS) {
if (sS == null) {
this.sS = null;
return;
}
java.util.List<String> sSCopy = new java.util.ArrayList<String>(sS.size());
sSCopy.addAll(sS);
this.sS = sSCopy;
} | java | public void setSS(java.util.Collection<String> sS) {
if (sS == null) {
this.sS = null;
return;
}
java.util.List<String> sSCopy = new java.util.ArrayList<String>(sS.size());
sSCopy.addAll(sS);
this.sS = sSCopy;
} | [
"public",
"void",
"setSS",
"(",
"java",
".",
"util",
".",
"Collection",
"<",
"String",
">",
"sS",
")",
"{",
"if",
"(",
"sS",
"==",
"null",
")",
"{",
"this",
".",
"sS",
"=",
"null",
";",
"return",
";",
"}",
"java",
".",
"util",
".",
"List",
"<",... | A set of strings.
@param sS A set of strings. | [
"A",
"set",
"of",
"strings",
"."
] | 4b230ac843494cb10e46ddc2848f5b5d377d7b72 | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/model/AttributeValue.java#L243-L252 |
36,468 | mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/model/AttributeValue.java | AttributeValue.setNS | public void setNS(java.util.Collection<String> nS) {
if (nS == null) {
this.nS = null;
return;
}
java.util.List<String> nSCopy = new java.util.ArrayList<String>(nS.size());
nSCopy.addAll(nS);
this.nS = nSCopy;
} | java | public void setNS(java.util.Collection<String> nS) {
if (nS == null) {
this.nS = null;
return;
}
java.util.List<String> nSCopy = new java.util.ArrayList<String>(nS.size());
nSCopy.addAll(nS);
this.nS = nSCopy;
} | [
"public",
"void",
"setNS",
"(",
"java",
".",
"util",
".",
"Collection",
"<",
"String",
">",
"nS",
")",
"{",
"if",
"(",
"nS",
"==",
"null",
")",
"{",
"this",
".",
"nS",
"=",
"null",
";",
"return",
";",
"}",
"java",
".",
"util",
".",
"List",
"<",... | A set of numbers.
@param nS A set of numbers. | [
"A",
"set",
"of",
"numbers",
"."
] | 4b230ac843494cb10e46ddc2848f5b5d377d7b72 | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/model/AttributeValue.java#L309-L318 |
36,469 | mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/model/AttributeValue.java | AttributeValue.setBS | public void setBS(java.util.Collection<java.nio.ByteBuffer> bS) {
if (bS == null) {
this.bS = null;
return;
}
java.util.List<java.nio.ByteBuffer> bSCopy = new java.util.ArrayList<java.nio.ByteBuffer>(bS.size());
bSCopy.addAll(bS);
this.bS = bSCopy;
} | java | public void setBS(java.util.Collection<java.nio.ByteBuffer> bS) {
if (bS == null) {
this.bS = null;
return;
}
java.util.List<java.nio.ByteBuffer> bSCopy = new java.util.ArrayList<java.nio.ByteBuffer>(bS.size());
bSCopy.addAll(bS);
this.bS = bSCopy;
} | [
"public",
"void",
"setBS",
"(",
"java",
".",
"util",
".",
"Collection",
"<",
"java",
".",
"nio",
".",
"ByteBuffer",
">",
"bS",
")",
"{",
"if",
"(",
"bS",
"==",
"null",
")",
"{",
"this",
".",
"bS",
"=",
"null",
";",
"return",
";",
"}",
"java",
"... | A set of binary attributes.
@param bS A set of binary attributes. | [
"A",
"set",
"of",
"binary",
"attributes",
"."
] | 4b230ac843494cb10e46ddc2848f5b5d377d7b72 | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/model/AttributeValue.java#L375-L384 |
36,470 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java | Deferred.when | public static Promise when(Object... d) {
int l = d.length;
Promise[] p = new Promise[l];
for (int i = 0; i < l; i++) {
p[i] = makePromise(d[i]);
}
return when(p);
} | java | public static Promise when(Object... d) {
int l = d.length;
Promise[] p = new Promise[l];
for (int i = 0; i < l; i++) {
p[i] = makePromise(d[i]);
}
return when(p);
} | [
"public",
"static",
"Promise",
"when",
"(",
"Object",
"...",
"d",
")",
"{",
"int",
"l",
"=",
"d",
".",
"length",
";",
"Promise",
"[",
"]",
"p",
"=",
"new",
"Promise",
"[",
"l",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"l",
... | Provides a way to execute callback functions based on one or more objects,
usually Deferred objects that represent asynchronous events.
Returns the Promise from a new "master" Deferred object that tracks the aggregate
state of all the Deferreds passed. The method will resolve its master
Deferred as soon as all the Deferreds resolve, or reject the master Deferred as
soon as one of the Deferreds is rejected | [
"Provides",
"a",
"way",
"to",
"execute",
"callback",
"functions",
"based",
"on",
"one",
"or",
"more",
"objects",
"usually",
"Deferred",
"objects",
"that",
"represent",
"asynchronous",
"events",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java#L279-L286 |
36,471 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/UiPlugin.java | UiPlugin.trigger | protected void trigger(GwtEvent<?> e, Function callback, Element element) {
trigger(e, callback, element, eventBus);
} | java | protected void trigger(GwtEvent<?> e, Function callback, Element element) {
trigger(e, callback, element, eventBus);
} | [
"protected",
"void",
"trigger",
"(",
"GwtEvent",
"<",
"?",
">",
"e",
",",
"Function",
"callback",
",",
"Element",
"element",
")",
"{",
"trigger",
"(",
"e",
",",
"callback",
",",
"element",
",",
"eventBus",
")",
";",
"}"
] | fire event and call callback function. | [
"fire",
"event",
"and",
"call",
"callback",
"function",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/UiPlugin.java#L172-L174 |
36,472 | mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java | PaginatedList.iterator | @Override
public Iterator<T> iterator() {
/*
* We make a copy of the allResults list to iterate over in order to
* avoid ConcurrentModificationExceptions caused by other methods
* loading more results into the list while someone iterates over it.
* This is a more severe problem than it might seem, because even
* innocuous-seeming operations such as contains() can modify the
* underlying result set.
*/
final List<T> allResultsCopy = new ArrayList<T>();
allResultsCopy.addAll(allResults);
final Iterator<T> iter = allResultsCopy.iterator();
return new Iterator<T>() {
Iterator<T> iterator = iter;
int pos = 0;
@Override
public boolean hasNext() {
return iterator.hasNext() || nextResultsAvailable();
}
@Override
public T next() {
if ( !iterator.hasNext() ) {
/*
* Our private copy of the result list may be out of date
* with the full one. If it is, we just need to update our
* private copy to get more results. If it's not, we need to
* fetch more results from the service.
*/
if ( allResults.size() == allResultsCopy.size() ) {
if ( !nextResultsAvailable() ) {
throw new NoSuchElementException();
}
moveNextResults();
}
if ( allResults.size() > allResultsCopy.size() )
allResultsCopy.addAll(allResults.subList(allResultsCopy.size(), allResults.size()));
iterator = allResultsCopy.listIterator(pos);
}
pos++;
return iterator.next();
}
@Override
public void remove() {
throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE);
}
};
} | java | @Override
public Iterator<T> iterator() {
/*
* We make a copy of the allResults list to iterate over in order to
* avoid ConcurrentModificationExceptions caused by other methods
* loading more results into the list while someone iterates over it.
* This is a more severe problem than it might seem, because even
* innocuous-seeming operations such as contains() can modify the
* underlying result set.
*/
final List<T> allResultsCopy = new ArrayList<T>();
allResultsCopy.addAll(allResults);
final Iterator<T> iter = allResultsCopy.iterator();
return new Iterator<T>() {
Iterator<T> iterator = iter;
int pos = 0;
@Override
public boolean hasNext() {
return iterator.hasNext() || nextResultsAvailable();
}
@Override
public T next() {
if ( !iterator.hasNext() ) {
/*
* Our private copy of the result list may be out of date
* with the full one. If it is, we just need to update our
* private copy to get more results. If it's not, we need to
* fetch more results from the service.
*/
if ( allResults.size() == allResultsCopy.size() ) {
if ( !nextResultsAvailable() ) {
throw new NoSuchElementException();
}
moveNextResults();
}
if ( allResults.size() > allResultsCopy.size() )
allResultsCopy.addAll(allResults.subList(allResultsCopy.size(), allResults.size()));
iterator = allResultsCopy.listIterator(pos);
}
pos++;
return iterator.next();
}
@Override
public void remove() {
throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE);
}
};
} | [
"@",
"Override",
"public",
"Iterator",
"<",
"T",
">",
"iterator",
"(",
")",
"{",
"/*\n * We make a copy of the allResults list to iterate over in order to\n * avoid ConcurrentModificationExceptions caused by other methods\n * loading more results into the list while som... | Returns an iterator over this list that lazily initializes results as
necessary. | [
"Returns",
"an",
"iterator",
"over",
"this",
"list",
"that",
"lazily",
"initializes",
"results",
"as",
"necessary",
"."
] | 4b230ac843494cb10e46ddc2848f5b5d377d7b72 | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java#L143-L199 |
36,473 | mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java | PaginatedList.subList | @Override
public List<T> subList(int arg0, int arg1) {
while ( allResults.size() < arg1 && nextResultsAvailable() ) {
moveNextResults();
}
return Collections.unmodifiableList(allResults.subList(arg0, arg1));
} | java | @Override
public List<T> subList(int arg0, int arg1) {
while ( allResults.size() < arg1 && nextResultsAvailable() ) {
moveNextResults();
}
return Collections.unmodifiableList(allResults.subList(arg0, arg1));
} | [
"@",
"Override",
"public",
"List",
"<",
"T",
">",
"subList",
"(",
"int",
"arg0",
",",
"int",
"arg1",
")",
"{",
"while",
"(",
"allResults",
".",
"size",
"(",
")",
"<",
"arg1",
"&&",
"nextResultsAvailable",
"(",
")",
")",
"{",
"moveNextResults",
"(",
"... | Returns a sub-list in the range specified, loading more results as
necessary. | [
"Returns",
"a",
"sub",
"-",
"list",
"in",
"the",
"range",
"specified",
"loading",
"more",
"results",
"as",
"necessary",
"."
] | 4b230ac843494cb10e46ddc2848f5b5d377d7b72 | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java#L247-L254 |
36,474 | mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java | PaginatedList.indexOf | @Override
public int indexOf(Object arg0) {
int indexOf = allResults.indexOf(arg0);
if ( indexOf >= 0 )
return indexOf;
while ( nextResultsAvailable() ) {
indexOf = nextResults.indexOf(arg0);
int size = allResults.size();
moveNextResults();
if ( indexOf >= 0 )
return indexOf + size;
}
return -1;
} | java | @Override
public int indexOf(Object arg0) {
int indexOf = allResults.indexOf(arg0);
if ( indexOf >= 0 )
return indexOf;
while ( nextResultsAvailable() ) {
indexOf = nextResults.indexOf(arg0);
int size = allResults.size();
moveNextResults();
if ( indexOf >= 0 )
return indexOf + size;
}
return -1;
} | [
"@",
"Override",
"public",
"int",
"indexOf",
"(",
"Object",
"arg0",
")",
"{",
"int",
"indexOf",
"=",
"allResults",
".",
"indexOf",
"(",
"arg0",
")",
";",
"if",
"(",
"indexOf",
">=",
"0",
")",
"return",
"indexOf",
";",
"while",
"(",
"nextResultsAvailable"... | Returns the first index of the object given in the list. Additional
results are loaded incrementally as necessary. | [
"Returns",
"the",
"first",
"index",
"of",
"the",
"object",
"given",
"in",
"the",
"list",
".",
"Additional",
"results",
"are",
"loaded",
"incrementally",
"as",
"necessary",
"."
] | 4b230ac843494cb10e46ddc2848f5b5d377d7b72 | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java#L260-L275 |
36,475 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java | Transform.supportsTransform3d | private static boolean supportsTransform3d() {
if (transform == null) {
return false;
}
String rotate = "rotateY(1deg)";
divStyle.setProperty(transform, rotate);
rotate = divStyle.getProperty(transform);
return rotate != null && !rotate.isEmpty();
} | java | private static boolean supportsTransform3d() {
if (transform == null) {
return false;
}
String rotate = "rotateY(1deg)";
divStyle.setProperty(transform, rotate);
rotate = divStyle.getProperty(transform);
return rotate != null && !rotate.isEmpty();
} | [
"private",
"static",
"boolean",
"supportsTransform3d",
"(",
")",
"{",
"if",
"(",
"transform",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"String",
"rotate",
"=",
"\"rotateY(1deg)\"",
";",
"divStyle",
".",
"setProperty",
"(",
"transform",
",",
"rota... | Some browsers like HTMLUnit only support 2d transformations | [
"Some",
"browsers",
"like",
"HTMLUnit",
"only",
"support",
"2d",
"transformations"
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java#L75-L83 |
36,476 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java | Transform.getVendorPropertyName | public static String getVendorPropertyName(String prop) {
// we prefer vendor specific names by default
String vendorProp = JsUtils.camelize("-" + prefix + "-" + prop);
if (JsUtils.hasProperty(divStyle, vendorProp)) {
return vendorProp;
}
if (JsUtils.hasProperty(divStyle, prop)) {
return prop;
}
String camelProp = JsUtils.camelize(prop);
if (JsUtils.hasProperty(divStyle, camelProp)) {
return camelProp;
}
return null;
} | java | public static String getVendorPropertyName(String prop) {
// we prefer vendor specific names by default
String vendorProp = JsUtils.camelize("-" + prefix + "-" + prop);
if (JsUtils.hasProperty(divStyle, vendorProp)) {
return vendorProp;
}
if (JsUtils.hasProperty(divStyle, prop)) {
return prop;
}
String camelProp = JsUtils.camelize(prop);
if (JsUtils.hasProperty(divStyle, camelProp)) {
return camelProp;
}
return null;
} | [
"public",
"static",
"String",
"getVendorPropertyName",
"(",
"String",
"prop",
")",
"{",
"// we prefer vendor specific names by default",
"String",
"vendorProp",
"=",
"JsUtils",
".",
"camelize",
"(",
"\"-\"",
"+",
"prefix",
"+",
"\"-\"",
"+",
"prop",
")",
";",
"if"... | Compute the correct CSS property name for a specific browser vendor. | [
"Compute",
"the",
"correct",
"CSS",
"property",
"name",
"for",
"a",
"specific",
"browser",
"vendor",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java#L88-L102 |
36,477 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java | Transform.getInstance | public static Transform getInstance(Element e, String initial) {
Transform t = GQuery.data(e, TRANSFORM);
if (t == null || initial != null) {
if (initial == null) {
initial = GQuery.getSelectorEngine().getDocumentStyleImpl().curCSS(e, transform, false);
}
t = new Transform(initial);
GQuery.data(e, TRANSFORM, t);
}
return t;
} | java | public static Transform getInstance(Element e, String initial) {
Transform t = GQuery.data(e, TRANSFORM);
if (t == null || initial != null) {
if (initial == null) {
initial = GQuery.getSelectorEngine().getDocumentStyleImpl().curCSS(e, transform, false);
}
t = new Transform(initial);
GQuery.data(e, TRANSFORM, t);
}
return t;
} | [
"public",
"static",
"Transform",
"getInstance",
"(",
"Element",
"e",
",",
"String",
"initial",
")",
"{",
"Transform",
"t",
"=",
"GQuery",
".",
"data",
"(",
"e",
",",
"TRANSFORM",
")",
";",
"if",
"(",
"t",
"==",
"null",
"||",
"initial",
"!=",
"null",
... | Return the Transform dictionary object of an element, but reseting
historical values and setting them to the initial value passed. | [
"Return",
"the",
"Transform",
"dictionary",
"object",
"of",
"an",
"element",
"but",
"reseting",
"historical",
"values",
"and",
"setting",
"them",
"to",
"the",
"initial",
"value",
"passed",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java#L123-L133 |
36,478 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java | Transform.parse | private void parse(String s) {
if (s != null) {
for (MatchResult r = transformParseRegex.exec(s); r != null; r = transformParseRegex.exec(s)) {
setFromString(vendorProperty(r.getGroup(1)), r.getGroup(2));
}
}
} | java | private void parse(String s) {
if (s != null) {
for (MatchResult r = transformParseRegex.exec(s); r != null; r = transformParseRegex.exec(s)) {
setFromString(vendorProperty(r.getGroup(1)), r.getGroup(2));
}
}
} | [
"private",
"void",
"parse",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"!=",
"null",
")",
"{",
"for",
"(",
"MatchResult",
"r",
"=",
"transformParseRegex",
".",
"exec",
"(",
"s",
")",
";",
"r",
"!=",
"null",
";",
"r",
"=",
"transformParseRegex",
... | Parse a transform value as string and fills the dictionary map. | [
"Parse",
"a",
"transform",
"value",
"as",
"string",
"and",
"fills",
"the",
"dictionary",
"map",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java#L163-L169 |
36,479 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java | Transform.setFromString | public void setFromString(String prop, String ...val) {
if (val.length == 1) {
String[] vals = val[0].split("[\\s,]+");
set(prop, vals);
} else {
set(prop, val);
}
} | java | public void setFromString(String prop, String ...val) {
if (val.length == 1) {
String[] vals = val[0].split("[\\s,]+");
set(prop, vals);
} else {
set(prop, val);
}
} | [
"public",
"void",
"setFromString",
"(",
"String",
"prop",
",",
"String",
"...",
"val",
")",
"{",
"if",
"(",
"val",
".",
"length",
"==",
"1",
")",
"{",
"String",
"[",
"]",
"vals",
"=",
"val",
"[",
"0",
"]",
".",
"split",
"(",
"\"[\\\\s,]+\"",
")",
... | Set a transform multi-value giving either a set of strings or
just an string of values separated by comma. | [
"Set",
"a",
"transform",
"multi",
"-",
"value",
"giving",
"either",
"a",
"set",
"of",
"strings",
"or",
"just",
"an",
"string",
"of",
"values",
"separated",
"by",
"comma",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transform.java#L182-L189 |
36,480 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java | QueuePlugin.clearQueue | @SuppressWarnings("unchecked")
public T clearQueue(String name) {
for (Element e : elements()) {
queue(e, name, null).clear();
}
return (T) this;
} | java | @SuppressWarnings("unchecked")
public T clearQueue(String name) {
for (Element e : elements()) {
queue(e, name, null).clear();
}
return (T) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"clearQueue",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"Element",
"e",
":",
"elements",
"(",
")",
")",
"{",
"queue",
"(",
"e",
",",
"name",
",",
"null",
")",
".",
"clear",
"(",
... | remove all queued function from the named queue. | [
"remove",
"all",
"queued",
"function",
"from",
"the",
"named",
"queue",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java#L94-L100 |
36,481 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java | QueuePlugin.delay | @SuppressWarnings("unchecked")
public T delay(int milliseconds, String name, Function... funcs) {
for (Element e : elements()) {
queue(e, name, new DelayFunction(e, name, milliseconds, funcs));
}
return (T) this;
} | java | @SuppressWarnings("unchecked")
public T delay(int milliseconds, String name, Function... funcs) {
for (Element e : elements()) {
queue(e, name, new DelayFunction(e, name, milliseconds, funcs));
}
return (T) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"delay",
"(",
"int",
"milliseconds",
",",
"String",
"name",
",",
"Function",
"...",
"funcs",
")",
"{",
"for",
"(",
"Element",
"e",
":",
"elements",
"(",
")",
")",
"{",
"queue",
"(",
"e"... | Add a delay in the named queue. | [
"Add",
"a",
"delay",
"in",
"the",
"named",
"queue",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java#L112-L118 |
36,482 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java | QueuePlugin.dequeue | @SuppressWarnings("unchecked")
public T dequeue(String name) {
for (Element e : elements()) {
dequeueCurrentAndRunNext(e, name);
}
return (T) this;
} | java | @SuppressWarnings("unchecked")
public T dequeue(String name) {
for (Element e : elements()) {
dequeueCurrentAndRunNext(e, name);
}
return (T) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"dequeue",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"Element",
"e",
":",
"elements",
"(",
")",
")",
"{",
"dequeueCurrentAndRunNext",
"(",
"e",
",",
"name",
")",
";",
"}",
"return",
... | Removes a queued function from the front of the named queue and executes it. | [
"Removes",
"a",
"queued",
"function",
"from",
"the",
"front",
"of",
"the",
"named",
"queue",
"and",
"executes",
"it",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java#L130-L136 |
36,483 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java | QueuePlugin.promise | public Promise promise(final String name) {
final Promise.Deferred dfd = Deferred();
// This is the unique instance of the resolve function which will be added to each element.
final Function resolve = new Function() {
// Because it is an inner function, the counter cannot final outside the function
int count = 1;
// Inner functions don't have constructors, we use a block to initialize it
{
for (Element elem : elements()) {
// Add this resolve function only to those elements with active queue
if (queue(elem, name, null) != null) {
emptyHooks(elem, name).add(this);
count++;
}
}
}
public void f() {
if (--count == 0) {
dfd.resolve(QueuePlugin.this);
}
}
};
// Run the function and resolve it in case there are not elements with active queue
resolve.f(this, name);
return dfd.promise();
} | java | public Promise promise(final String name) {
final Promise.Deferred dfd = Deferred();
// This is the unique instance of the resolve function which will be added to each element.
final Function resolve = new Function() {
// Because it is an inner function, the counter cannot final outside the function
int count = 1;
// Inner functions don't have constructors, we use a block to initialize it
{
for (Element elem : elements()) {
// Add this resolve function only to those elements with active queue
if (queue(elem, name, null) != null) {
emptyHooks(elem, name).add(this);
count++;
}
}
}
public void f() {
if (--count == 0) {
dfd.resolve(QueuePlugin.this);
}
}
};
// Run the function and resolve it in case there are not elements with active queue
resolve.f(this, name);
return dfd.promise();
} | [
"public",
"Promise",
"promise",
"(",
"final",
"String",
"name",
")",
"{",
"final",
"Promise",
".",
"Deferred",
"dfd",
"=",
"Deferred",
"(",
")",
";",
"// This is the unique instance of the resolve function which will be added to each element.",
"final",
"Function",
"resol... | Returns a dynamically generated Promise that is resolved once all actions
in the named queue have ended. | [
"Returns",
"a",
"dynamically",
"generated",
"Promise",
"that",
"is",
"resolved",
"once",
"all",
"actions",
"in",
"the",
"named",
"queue",
"have",
"ended",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java#L150-L179 |
36,484 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java | QueuePlugin.queue | public int queue(String name) {
Queue<?> q = isEmpty() ? null : queue(get(0), name, null);
return q == null ? 0 : q.size();
} | java | public int queue(String name) {
Queue<?> q = isEmpty() ? null : queue(get(0), name, null);
return q == null ? 0 : q.size();
} | [
"public",
"int",
"queue",
"(",
"String",
"name",
")",
"{",
"Queue",
"<",
"?",
">",
"q",
"=",
"isEmpty",
"(",
")",
"?",
"null",
":",
"queue",
"(",
"get",
"(",
"0",
")",
",",
"name",
",",
"null",
")",
";",
"return",
"q",
"==",
"null",
"?",
"0",... | Show the number of functions to be executed on the first matched element
in the named queue. | [
"Show",
"the",
"number",
"of",
"functions",
"to",
"be",
"executed",
"on",
"the",
"first",
"matched",
"element",
"in",
"the",
"named",
"queue",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java#L193-L196 |
36,485 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java | QueuePlugin.queue | @SuppressWarnings("unchecked")
public T queue(Function... funcs) {
for (Element e : elements()) {
for (Function f : funcs) {
queue(e, DEFAULT_NAME, f);
}
}
return (T) this;
} | java | @SuppressWarnings("unchecked")
public T queue(Function... funcs) {
for (Element e : elements()) {
for (Function f : funcs) {
queue(e, DEFAULT_NAME, f);
}
}
return (T) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"queue",
"(",
"Function",
"...",
"funcs",
")",
"{",
"for",
"(",
"Element",
"e",
":",
"elements",
"(",
")",
")",
"{",
"for",
"(",
"Function",
"f",
":",
"funcs",
")",
"{",
"queue",
"(",... | Adds new functions, to be executed, onto the end of the effects
queue of all matched elements. | [
"Adds",
"new",
"functions",
"to",
"be",
"executed",
"onto",
"the",
"end",
"of",
"the",
"effects",
"queue",
"of",
"all",
"matched",
"elements",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java#L202-L210 |
36,486 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java | QueuePlugin.queue | @SuppressWarnings("unchecked")
public T queue(final String name, Function... funcs) {
for (final Function f : funcs) {
for (Element e : elements()) {
queue(e, name, f);
}
}
return (T) this;
} | java | @SuppressWarnings("unchecked")
public T queue(final String name, Function... funcs) {
for (final Function f : funcs) {
for (Element e : elements()) {
queue(e, name, f);
}
}
return (T) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"queue",
"(",
"final",
"String",
"name",
",",
"Function",
"...",
"funcs",
")",
"{",
"for",
"(",
"final",
"Function",
"f",
":",
"funcs",
")",
"{",
"for",
"(",
"Element",
"e",
":",
"eleme... | Adds new functions, to be executed, onto the end of the named
queue of all matched elements. | [
"Adds",
"new",
"functions",
"to",
"be",
"executed",
"onto",
"the",
"end",
"of",
"the",
"named",
"queue",
"of",
"all",
"matched",
"elements",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java#L216-L224 |
36,487 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java | QueuePlugin.queue | @SuppressWarnings("unchecked")
public T queue(String name, Queue<?> queue) {
for (Element e : elements()) {
replacequeue(e, name, queue);
}
return (T) this;
} | java | @SuppressWarnings("unchecked")
public T queue(String name, Queue<?> queue) {
for (Element e : elements()) {
replacequeue(e, name, queue);
}
return (T) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"queue",
"(",
"String",
"name",
",",
"Queue",
"<",
"?",
">",
"queue",
")",
"{",
"for",
"(",
"Element",
"e",
":",
"elements",
"(",
")",
")",
"{",
"replacequeue",
"(",
"e",
",",
"name",... | Replaces the current named queue with the given queue on all matched elements. | [
"Replaces",
"the",
"current",
"named",
"queue",
"with",
"the",
"given",
"queue",
"on",
"all",
"matched",
"elements",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java#L236-L242 |
36,488 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java | QueuePlugin.dequeueIfNotDoneYet | public void dequeueIfNotDoneYet(Element elem, String name, Object object) {
@SuppressWarnings("rawtypes")
Queue queue = queue(elem, name, null);
if (queue != null && object.equals(queue.peek())) {
dequeueCurrentAndRunNext(elem, name);
}
} | java | public void dequeueIfNotDoneYet(Element elem, String name, Object object) {
@SuppressWarnings("rawtypes")
Queue queue = queue(elem, name, null);
if (queue != null && object.equals(queue.peek())) {
dequeueCurrentAndRunNext(elem, name);
}
} | [
"public",
"void",
"dequeueIfNotDoneYet",
"(",
"Element",
"elem",
",",
"String",
"name",
",",
"Object",
"object",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"Queue",
"queue",
"=",
"queue",
"(",
"elem",
",",
"name",
",",
"null",
")",
";",
... | Dequeue the object and run the next if it is the first
in the queue. | [
"Dequeue",
"the",
"object",
"and",
"run",
"the",
"next",
"if",
"it",
"is",
"the",
"first",
"in",
"the",
"queue",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java#L357-L363 |
36,489 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/FunctionDeferred.java | FunctionDeferred.f | public final Object f(Object... args) {
return dfd != null &&
(cache == CacheType.ALL ||
cache == CacheType.RESOLVED && dfd.promise().isResolved() ||
cache == CacheType.REJECTED && dfd.promise().isRejected())
? dfd.promise()
: new PromiseFunction() {
public void f(Deferred dfd) {
FunctionDeferred.this.resolve = resolve;
FunctionDeferred.this.reject = reject;
FunctionDeferred.this.dfd = dfd;
FunctionDeferred.this.f(dfd);
}
};
} | java | public final Object f(Object... args) {
return dfd != null &&
(cache == CacheType.ALL ||
cache == CacheType.RESOLVED && dfd.promise().isResolved() ||
cache == CacheType.REJECTED && dfd.promise().isRejected())
? dfd.promise()
: new PromiseFunction() {
public void f(Deferred dfd) {
FunctionDeferred.this.resolve = resolve;
FunctionDeferred.this.reject = reject;
FunctionDeferred.this.dfd = dfd;
FunctionDeferred.this.f(dfd);
}
};
} | [
"public",
"final",
"Object",
"f",
"(",
"Object",
"...",
"args",
")",
"{",
"return",
"dfd",
"!=",
"null",
"&&",
"(",
"cache",
"==",
"CacheType",
".",
"ALL",
"||",
"cache",
"==",
"CacheType",
".",
"RESOLVED",
"&&",
"dfd",
".",
"promise",
"(",
")",
".",... | This function is called when the previous promise in the pipe
is resolved. | [
"This",
"function",
"is",
"called",
"when",
"the",
"previous",
"promise",
"in",
"the",
"pipe",
"is",
"resolved",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/FunctionDeferred.java#L71-L85 |
36,490 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java | Function.getArgumentJSO | @SuppressWarnings("unchecked")
public <T extends JavaScriptObject> T getArgumentJSO(int argIdx, int pos) {
return (T) getArgument(argIdx, pos, JavaScriptObject.class);
} | java | @SuppressWarnings("unchecked")
public <T extends JavaScriptObject> T getArgumentJSO(int argIdx, int pos) {
return (T) getArgument(argIdx, pos, JavaScriptObject.class);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
"extends",
"JavaScriptObject",
">",
"T",
"getArgumentJSO",
"(",
"int",
"argIdx",
",",
"int",
"pos",
")",
"{",
"return",
"(",
"T",
")",
"getArgument",
"(",
"argIdx",
",",
"pos",
",",
... | Utility method for safety getting a JavaScriptObject present at a certain
position in the list of arguments composed by arrays. | [
"Utility",
"method",
"for",
"safety",
"getting",
"a",
"JavaScriptObject",
"present",
"at",
"a",
"certain",
"position",
"in",
"the",
"list",
"of",
"arguments",
"composed",
"by",
"arrays",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java#L148-L151 |
36,491 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java | Function.getArgumentArray | public Object[] getArgumentArray(int idx) {
Object o = idx < 0 ? arguments : getArgument(idx);
if (o != null) {
return o.getClass().isArray() ? (Object[]) o : new Object[] {o};
} else if (idx == 0) {
return arguments;
}
return new Object[0];
} | java | public Object[] getArgumentArray(int idx) {
Object o = idx < 0 ? arguments : getArgument(idx);
if (o != null) {
return o.getClass().isArray() ? (Object[]) o : new Object[] {o};
} else if (idx == 0) {
return arguments;
}
return new Object[0];
} | [
"public",
"Object",
"[",
"]",
"getArgumentArray",
"(",
"int",
"idx",
")",
"{",
"Object",
"o",
"=",
"idx",
"<",
"0",
"?",
"arguments",
":",
"getArgument",
"(",
"idx",
")",
";",
"if",
"(",
"o",
"!=",
"null",
")",
"{",
"return",
"o",
".",
"getClass",
... | Utility method for safety getting an array present at a certain
position in the list of arguments.
Useful for Deferred chains where result of each resolved
promise is set as an array in the arguments list.
Always returns an array. | [
"Utility",
"method",
"for",
"safety",
"getting",
"an",
"array",
"present",
"at",
"a",
"certain",
"position",
"in",
"the",
"list",
"of",
"arguments",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java#L170-L178 |
36,492 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java | Function.getArgument | public <T> T getArgument(int idx, Class<? extends T> type) {
return getArgument(-1, idx, type);
} | java | public <T> T getArgument(int idx, Class<? extends T> type) {
return getArgument(-1, idx, type);
} | [
"public",
"<",
"T",
">",
"T",
"getArgument",
"(",
"int",
"idx",
",",
"Class",
"<",
"?",
"extends",
"T",
">",
"type",
")",
"{",
"return",
"getArgument",
"(",
"-",
"1",
",",
"idx",
",",
"type",
")",
";",
"}"
] | Safety return the argument in the position idx.
If the element class is not of the requested type it returns null and
you don't get casting exeption. | [
"Safety",
"return",
"the",
"argument",
"in",
"the",
"position",
"idx",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java#L221-L223 |
36,493 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java | Function.getArgument | @SuppressWarnings("unchecked")
public <T> T getArgument(int argIdx, int pos, Class<? extends T> type) {
Object[] objs = getArgumentArray(argIdx);
Object o = objs.length > pos ? objs[pos] : null;
if (o != null && (
// When type is null we don't safety check
type == null ||
// The object is an instance of the type requested
o.getClass() == type ||
// Overlay types
type == JavaScriptObject.class && o instanceof JavaScriptObject
)) {
return (T) o;
}
return null;
} | java | @SuppressWarnings("unchecked")
public <T> T getArgument(int argIdx, int pos, Class<? extends T> type) {
Object[] objs = getArgumentArray(argIdx);
Object o = objs.length > pos ? objs[pos] : null;
if (o != null && (
// When type is null we don't safety check
type == null ||
// The object is an instance of the type requested
o.getClass() == type ||
// Overlay types
type == JavaScriptObject.class && o instanceof JavaScriptObject
)) {
return (T) o;
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"getArgument",
"(",
"int",
"argIdx",
",",
"int",
"pos",
",",
"Class",
"<",
"?",
"extends",
"T",
">",
"type",
")",
"{",
"Object",
"[",
"]",
"objs",
"=",
"getArgumentArray"... | Utility method for safety getting an object present at a certain
position in the list of arguments composed by arrays.
Useful for Deferred chains where result of each resolved
promise is set as an array in the arguments list.
When the object found in the array doesn't match the type required it returns a null.
Note: If type is null, we don't check the class of the object found andd you could
eventually get a casting exception. | [
"Utility",
"method",
"for",
"safety",
"getting",
"an",
"object",
"present",
"at",
"a",
"certain",
"position",
"in",
"the",
"list",
"of",
"arguments",
"composed",
"by",
"arrays",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java#L238-L253 |
36,494 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java | Function.f | public Object f(Widget w, int i) {
setElement(w.getElement());
setIndex(i);
f(w);
return null;
} | java | public Object f(Widget w, int i) {
setElement(w.getElement());
setIndex(i);
f(w);
return null;
} | [
"public",
"Object",
"f",
"(",
"Widget",
"w",
",",
"int",
"i",
")",
"{",
"setElement",
"(",
"w",
".",
"getElement",
"(",
")",
")",
";",
"setIndex",
"(",
"i",
")",
";",
"f",
"(",
"w",
")",
";",
"return",
"null",
";",
"}"
] | Override this for GQuery methods which loop over matched widgets and
invoke a callback on each widget.
NOTE: If your query has non-widget elements you might need to override
'public void f()' or 'public void f(Element e)' to handle these elements and
avoid a runtime exception. | [
"Override",
"this",
"for",
"GQuery",
"methods",
"which",
"loop",
"over",
"matched",
"widgets",
"and",
"invoke",
"a",
"callback",
"on",
"each",
"widget",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java#L385-L390 |
36,495 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java | Function.f | public void f(int i, Object... args) {
setIndex(i);
setArguments(args);
if (args.length == 1 && args[0] instanceof JavaScriptObject) {
if (JsUtils.isElement((JavaScriptObject) args[0])) {
setElement((com.google.gwt.dom.client.Element) args[0]);
f(getElement(), i);
} else if (JsUtils.isEvent((JavaScriptObject) args[0])) {
setEvent((Event) args[0]);
f(getEvent());
} else {
f();
}
}
} | java | public void f(int i, Object... args) {
setIndex(i);
setArguments(args);
if (args.length == 1 && args[0] instanceof JavaScriptObject) {
if (JsUtils.isElement((JavaScriptObject) args[0])) {
setElement((com.google.gwt.dom.client.Element) args[0]);
f(getElement(), i);
} else if (JsUtils.isEvent((JavaScriptObject) args[0])) {
setEvent((Event) args[0]);
f(getEvent());
} else {
f();
}
}
} | [
"public",
"void",
"f",
"(",
"int",
"i",
",",
"Object",
"...",
"args",
")",
"{",
"setIndex",
"(",
"i",
")",
";",
"setArguments",
"(",
"args",
")",
";",
"if",
"(",
"args",
".",
"length",
"==",
"1",
"&&",
"args",
"[",
"0",
"]",
"instanceof",
"JavaSc... | Override this method for bound callbacks. | [
"Override",
"this",
"method",
"for",
"bound",
"callbacks",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java#L411-L425 |
36,496 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java | Function.f | public boolean f(Event e, Object... arg) {
setArguments(arg);
setEvent(e);
return f(e);
} | java | public boolean f(Event e, Object... arg) {
setArguments(arg);
setEvent(e);
return f(e);
} | [
"public",
"boolean",
"f",
"(",
"Event",
"e",
",",
"Object",
"...",
"arg",
")",
"{",
"setArguments",
"(",
"arg",
")",
";",
"setEvent",
"(",
"e",
")",
";",
"return",
"f",
"(",
"e",
")",
";",
"}"
] | Override this method for bound event handlers if you wish to deal with
per-handler user data.
@return boolean false means stop propagation and prevent default | [
"Override",
"this",
"method",
"for",
"bound",
"event",
"handlers",
"if",
"you",
"wish",
"to",
"deal",
"with",
"per",
"-",
"handler",
"user",
"data",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java#L433-L437 |
36,497 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java | Function.f | public void f(Widget w) {
setElement(w.getElement());
if (loop) {
loop = false;
f();
} else {
f(w.getElement().<com.google.gwt.dom.client.Element> cast());
}
} | java | public void f(Widget w) {
setElement(w.getElement());
if (loop) {
loop = false;
f();
} else {
f(w.getElement().<com.google.gwt.dom.client.Element> cast());
}
} | [
"public",
"void",
"f",
"(",
"Widget",
"w",
")",
"{",
"setElement",
"(",
"w",
".",
"getElement",
"(",
")",
")",
";",
"if",
"(",
"loop",
")",
"{",
"loop",
"=",
"false",
";",
"f",
"(",
")",
";",
"}",
"else",
"{",
"f",
"(",
"w",
".",
"getElement"... | Override this for GQuery methods which take a callback, but do not expect a
return value, apply to a single widget.
NOTE: If your query has non-widget elements you might need to override
'public void f()' or 'public void f(Element e)' to handle these elements and
avoid a runtime exception. | [
"Override",
"this",
"for",
"GQuery",
"methods",
"which",
"take",
"a",
"callback",
"but",
"do",
"not",
"expect",
"a",
"return",
"value",
"apply",
"to",
"a",
"single",
"widget",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java#L490-L498 |
36,498 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java | Ajax.ajax | public static Promise ajax(Settings settings) {
resolveSettings(settings);
final Function onSuccess = settings.getSuccess();
if (onSuccess != null) {
onSuccess.setElement(settings.getContext());
}
final Function onError = settings.getError();
if (onError != null) {
onError.setElement(settings.getContext());
}
final String dataType = settings.getDataType();
Promise ret = null;
if ("jsonp".equalsIgnoreCase(dataType)) {
ret = GQ.getAjaxTransport().getJsonP(settings);
} else if ("loadscript".equalsIgnoreCase(dataType)) {
ret = GQ.getAjaxTransport().getLoadScript(settings);
} else {
ret = GQ.getAjaxTransport().getXhr(settings)
.then(new Function() {
public Object f(Object... args) {
Response response = arguments(0);
Request request = arguments(1);
Object retData = response.getText();
if (retData != null && !"".equals(retData)) {
try {
if ("xml".equalsIgnoreCase(dataType)) {
retData = JsUtils.parseXML(response.getText());
} else if ("json".equalsIgnoreCase(dataType)) {
retData = GQ.create(response.getText());
} else {
retData = response.getText();
if ("script".equalsIgnoreCase(dataType)) {
ScriptInjector.fromString((String) retData).setWindow(window).inject();
}
}
} catch (Exception e) {
if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) {
GWT.getUncaughtExceptionHandler().onUncaughtException(e);
} else {
e.printStackTrace();
}
}
}
return new Object[] {retData, "success", request, response};
}
}, new Function() {
public Object f(Object... args) {
Throwable exception = arguments(0);
Request request = getArgument(1, Request.class);
String msg = String.valueOf(exception);
return new Object[] {null, msg, request, null, exception};
}
});
}
if (onSuccess != null) {
ret.done(onSuccess);
}
if (onError != null) {
ret.fail(onError);
}
return ret;
} | java | public static Promise ajax(Settings settings) {
resolveSettings(settings);
final Function onSuccess = settings.getSuccess();
if (onSuccess != null) {
onSuccess.setElement(settings.getContext());
}
final Function onError = settings.getError();
if (onError != null) {
onError.setElement(settings.getContext());
}
final String dataType = settings.getDataType();
Promise ret = null;
if ("jsonp".equalsIgnoreCase(dataType)) {
ret = GQ.getAjaxTransport().getJsonP(settings);
} else if ("loadscript".equalsIgnoreCase(dataType)) {
ret = GQ.getAjaxTransport().getLoadScript(settings);
} else {
ret = GQ.getAjaxTransport().getXhr(settings)
.then(new Function() {
public Object f(Object... args) {
Response response = arguments(0);
Request request = arguments(1);
Object retData = response.getText();
if (retData != null && !"".equals(retData)) {
try {
if ("xml".equalsIgnoreCase(dataType)) {
retData = JsUtils.parseXML(response.getText());
} else if ("json".equalsIgnoreCase(dataType)) {
retData = GQ.create(response.getText());
} else {
retData = response.getText();
if ("script".equalsIgnoreCase(dataType)) {
ScriptInjector.fromString((String) retData).setWindow(window).inject();
}
}
} catch (Exception e) {
if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) {
GWT.getUncaughtExceptionHandler().onUncaughtException(e);
} else {
e.printStackTrace();
}
}
}
return new Object[] {retData, "success", request, response};
}
}, new Function() {
public Object f(Object... args) {
Throwable exception = arguments(0);
Request request = getArgument(1, Request.class);
String msg = String.valueOf(exception);
return new Object[] {null, msg, request, null, exception};
}
});
}
if (onSuccess != null) {
ret.done(onSuccess);
}
if (onError != null) {
ret.fail(onError);
}
return ret;
} | [
"public",
"static",
"Promise",
"ajax",
"(",
"Settings",
"settings",
")",
"{",
"resolveSettings",
"(",
"settings",
")",
";",
"final",
"Function",
"onSuccess",
"=",
"settings",
".",
"getSuccess",
"(",
")",
";",
"if",
"(",
"onSuccess",
"!=",
"null",
")",
"{",... | Perform an ajax request to the server.
Example:
<pre>
import static com.google.gwt.query.client.GQ.*
...
Properties properties = $$("dataType: xml, type: post; data: {q: 'gwt'}, headers: {X-Powered-By: GQuery}");
ajax("test.php", new Function() {
public void f() {
Element xmlElem = getData()[0];
System.out.println($("message", xmlElem));
}
}, new Function(){
public void f() {
System.err.println("Ajax Error: " + getData()[1]);
}
}, properties);
</pre> | [
"Perform",
"an",
"ajax",
"request",
"to",
"the",
"server",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java#L162-L228 |
36,499 | ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java | JsCache.checkNull | public static final <T extends JavaScriptObject> T checkNull(T js) {
if (!GWT.isProdMode() && js == null) {
throw new NullPointerException();
}
return js;
} | java | public static final <T extends JavaScriptObject> T checkNull(T js) {
if (!GWT.isProdMode() && js == null) {
throw new NullPointerException();
}
return js;
} | [
"public",
"static",
"final",
"<",
"T",
"extends",
"JavaScriptObject",
">",
"T",
"checkNull",
"(",
"T",
"js",
")",
"{",
"if",
"(",
"!",
"GWT",
".",
"isProdMode",
"(",
")",
"&&",
"js",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
... | Throw a NPE when a js is null. | [
"Throw",
"a",
"NPE",
"when",
"a",
"js",
"is",
"null",
"."
] | 93e02bc8eb030081061c56134ebee1f585981107 | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java#L259-L264 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.