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
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
164,300 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxBaseMessageViewHolder.java | CTInboxBaseMessageViewHolder.calculateDisplayTimestamp | String calculateDisplayTimestamp(long time){
long now = System.currentTimeMillis()/1000;
long diff = now-time;
if(diff < 60){
return "Just Now";
}else if(diff > 60 && diff < 59*60){
return (diff/(60)) + " mins ago";
}else if(diff > 59*60 && diff < 23*59*60 ){
return diff/(60*60) > 1 ? diff/(60*60) + " hours ago" : diff/(60*60) + " hour ago";
}else if(diff > 24*60*60 && diff < 48*60*60){
return "Yesterday";
}else {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM");
return sdf.format(new Date(time));
}
} | java | String calculateDisplayTimestamp(long time){
long now = System.currentTimeMillis()/1000;
long diff = now-time;
if(diff < 60){
return "Just Now";
}else if(diff > 60 && diff < 59*60){
return (diff/(60)) + " mins ago";
}else if(diff > 59*60 && diff < 23*59*60 ){
return diff/(60*60) > 1 ? diff/(60*60) + " hours ago" : diff/(60*60) + " hour ago";
}else if(diff > 24*60*60 && diff < 48*60*60){
return "Yesterday";
}else {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM");
return sdf.format(new Date(time));
}
} | [
"String",
"calculateDisplayTimestamp",
"(",
"long",
"time",
")",
"{",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"/",
"1000",
";",
"long",
"diff",
"=",
"now",
"-",
"time",
";",
"if",
"(",
"diff",
"<",
"60",
")",
"{",
"return",
"\"Just Now\"",
";",
"}",
"else",
"if",
"(",
"diff",
">",
"60",
"&&",
"diff",
"<",
"59",
"*",
"60",
")",
"{",
"return",
"(",
"diff",
"/",
"(",
"60",
")",
")",
"+",
"\" mins ago\"",
";",
"}",
"else",
"if",
"(",
"diff",
">",
"59",
"*",
"60",
"&&",
"diff",
"<",
"23",
"*",
"59",
"*",
"60",
")",
"{",
"return",
"diff",
"/",
"(",
"60",
"*",
"60",
")",
">",
"1",
"?",
"diff",
"/",
"(",
"60",
"*",
"60",
")",
"+",
"\" hours ago\"",
":",
"diff",
"/",
"(",
"60",
"*",
"60",
")",
"+",
"\" hour ago\"",
";",
"}",
"else",
"if",
"(",
"diff",
">",
"24",
"*",
"60",
"*",
"60",
"&&",
"diff",
"<",
"48",
"*",
"60",
"*",
"60",
")",
"{",
"return",
"\"Yesterday\"",
";",
"}",
"else",
"{",
"@",
"SuppressLint",
"(",
"\"SimpleDateFormat\"",
")",
"SimpleDateFormat",
"sdf",
"=",
"new",
"SimpleDateFormat",
"(",
"\"dd MMM\"",
")",
";",
"return",
"sdf",
".",
"format",
"(",
"new",
"Date",
"(",
"time",
")",
")",
";",
"}",
"}"
] | Logic for timestamp
@param time Epoch date of creation
@return String timestamp | [
"Logic",
"for",
"timestamp"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxBaseMessageViewHolder.java#L71-L87 |
164,301 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxStyleConfig.java | CTInboxStyleConfig.setTabs | public void setTabs(ArrayList<String>tabs) {
if (tabs == null || tabs.size() <= 0) return;
if (platformSupportsTabs) {
ArrayList<String> toAdd;
if (tabs.size() > MAX_TABS) {
toAdd = new ArrayList<>(tabs.subList(0, MAX_TABS));
} else {
toAdd = tabs;
}
this.tabs = toAdd.toArray(new String[0]);
} else {
Logger.d("Please upgrade com.android.support:design library to v28.0.0 to enable Tabs for App Inbox, dropping Tabs");
}
} | java | public void setTabs(ArrayList<String>tabs) {
if (tabs == null || tabs.size() <= 0) return;
if (platformSupportsTabs) {
ArrayList<String> toAdd;
if (tabs.size() > MAX_TABS) {
toAdd = new ArrayList<>(tabs.subList(0, MAX_TABS));
} else {
toAdd = tabs;
}
this.tabs = toAdd.toArray(new String[0]);
} else {
Logger.d("Please upgrade com.android.support:design library to v28.0.0 to enable Tabs for App Inbox, dropping Tabs");
}
} | [
"public",
"void",
"setTabs",
"(",
"ArrayList",
"<",
"String",
">",
"tabs",
")",
"{",
"if",
"(",
"tabs",
"==",
"null",
"||",
"tabs",
".",
"size",
"(",
")",
"<=",
"0",
")",
"return",
";",
"if",
"(",
"platformSupportsTabs",
")",
"{",
"ArrayList",
"<",
"String",
">",
"toAdd",
";",
"if",
"(",
"tabs",
".",
"size",
"(",
")",
">",
"MAX_TABS",
")",
"{",
"toAdd",
"=",
"new",
"ArrayList",
"<>",
"(",
"tabs",
".",
"subList",
"(",
"0",
",",
"MAX_TABS",
")",
")",
";",
"}",
"else",
"{",
"toAdd",
"=",
"tabs",
";",
"}",
"this",
".",
"tabs",
"=",
"toAdd",
".",
"toArray",
"(",
"new",
"String",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"Logger",
".",
"d",
"(",
"\"Please upgrade com.android.support:design library to v28.0.0 to enable Tabs for App Inbox, dropping Tabs\"",
")",
";",
"}",
"}"
] | Sets the name of the optional two tabs.
The contents of the tabs are filtered based on the name of the tab.
@param tabs ArrayList of Strings | [
"Sets",
"the",
"name",
"of",
"the",
"optional",
"two",
"tabs",
".",
"The",
"contents",
"of",
"the",
"tabs",
"are",
"filtered",
"based",
"on",
"the",
"name",
"of",
"the",
"tab",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxStyleConfig.java#L184-L198 |
164,302 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/EventHandler.java | EventHandler.push | @Deprecated
@SuppressWarnings("deprecation")
public void push(String eventName, HashMap<String, Object> chargeDetails,
ArrayList<HashMap<String, Object>> items)
throws InvalidEventNameException {
// This method is for only charged events
if (!eventName.equals(Constants.CHARGED_EVENT)) {
throw new InvalidEventNameException("Not a charged event");
}
CleverTapAPI cleverTapAPI = weakReference.get();
if(cleverTapAPI == null){
Logger.d("CleverTap Instance is null.");
} else {
cleverTapAPI.pushChargedEvent(chargeDetails, items);
}
} | java | @Deprecated
@SuppressWarnings("deprecation")
public void push(String eventName, HashMap<String, Object> chargeDetails,
ArrayList<HashMap<String, Object>> items)
throws InvalidEventNameException {
// This method is for only charged events
if (!eventName.equals(Constants.CHARGED_EVENT)) {
throw new InvalidEventNameException("Not a charged event");
}
CleverTapAPI cleverTapAPI = weakReference.get();
if(cleverTapAPI == null){
Logger.d("CleverTap Instance is null.");
} else {
cleverTapAPI.pushChargedEvent(chargeDetails, items);
}
} | [
"@",
"Deprecated",
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"void",
"push",
"(",
"String",
"eventName",
",",
"HashMap",
"<",
"String",
",",
"Object",
">",
"chargeDetails",
",",
"ArrayList",
"<",
"HashMap",
"<",
"String",
",",
"Object",
">",
">",
"items",
")",
"throws",
"InvalidEventNameException",
"{",
"// This method is for only charged events",
"if",
"(",
"!",
"eventName",
".",
"equals",
"(",
"Constants",
".",
"CHARGED_EVENT",
")",
")",
"{",
"throw",
"new",
"InvalidEventNameException",
"(",
"\"Not a charged event\"",
")",
";",
"}",
"CleverTapAPI",
"cleverTapAPI",
"=",
"weakReference",
".",
"get",
"(",
")",
";",
"if",
"(",
"cleverTapAPI",
"==",
"null",
")",
"{",
"Logger",
".",
"d",
"(",
"\"CleverTap Instance is null.\"",
")",
";",
"}",
"else",
"{",
"cleverTapAPI",
".",
"pushChargedEvent",
"(",
"chargeDetails",
",",
"items",
")",
";",
"}",
"}"
] | Push an event which describes a purchase made.
@param eventName Has to be specified as "Charged". Anything other than this
will result in an {@link InvalidEventNameException} being thrown.
@param chargeDetails A {@link HashMap}, with keys as strings, and values as {@link String},
{@link Integer}, {@link Long}, {@link Boolean}, {@link Float}, {@link Double},
{@link java.util.Date}, or {@link Character}
@param items An {@link ArrayList} which contains up to 15 {@link HashMap} objects,
where each HashMap object describes a particular item purchased
@throws InvalidEventNameException Thrown if the event name is not "Charged"
@deprecated use {@link CleverTapAPI#pushChargedEvent(HashMap chargeDetails, ArrayList items)} | [
"Push",
"an",
"event",
"which",
"describes",
"a",
"purchase",
"made",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/EventHandler.java#L68-L83 |
164,303 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessage.java | CTInboxMessage.getCarouselImages | public ArrayList<String> getCarouselImages(){
ArrayList<String> carouselImages = new ArrayList<>();
for(CTInboxMessageContent ctInboxMessageContent: getInboxMessageContents()){
carouselImages.add(ctInboxMessageContent.getMedia());
}
return carouselImages;
} | java | public ArrayList<String> getCarouselImages(){
ArrayList<String> carouselImages = new ArrayList<>();
for(CTInboxMessageContent ctInboxMessageContent: getInboxMessageContents()){
carouselImages.add(ctInboxMessageContent.getMedia());
}
return carouselImages;
} | [
"public",
"ArrayList",
"<",
"String",
">",
"getCarouselImages",
"(",
")",
"{",
"ArrayList",
"<",
"String",
">",
"carouselImages",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"CTInboxMessageContent",
"ctInboxMessageContent",
":",
"getInboxMessageContents",
"(",
")",
")",
"{",
"carouselImages",
".",
"add",
"(",
"ctInboxMessageContent",
".",
"getMedia",
"(",
")",
")",
";",
"}",
"return",
"carouselImages",
";",
"}"
] | Returns an ArrayList of String URLs of the Carousel Images
@return ArrayList of Strings | [
"Returns",
"an",
"ArrayList",
"of",
"String",
"URLs",
"of",
"the",
"Carousel",
"Images"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessage.java#L251-L257 |
164,304 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.storeObject | synchronized int storeObject(JSONObject obj, Table table) {
if (!this.belowMemThreshold()) {
Logger.v("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = table.getName();
Cursor cursor = null;
int count = DB_UPDATE_ERROR;
//noinspection TryFinallyCanBeTryWithResources
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put(KEY_CREATED_AT, System.currentTimeMillis());
db.insert(tableName, null, cv);
cursor = db.rawQuery("SELECT COUNT(*) FROM " + tableName, null);
cursor.moveToFirst();
count = cursor.getInt(0);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
if (cursor != null) {
cursor.close();
cursor = null;
}
dbHelper.deleteDatabase();
} finally {
if (cursor != null) {
cursor.close();
}
dbHelper.close();
}
return count;
} | java | synchronized int storeObject(JSONObject obj, Table table) {
if (!this.belowMemThreshold()) {
Logger.v("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = table.getName();
Cursor cursor = null;
int count = DB_UPDATE_ERROR;
//noinspection TryFinallyCanBeTryWithResources
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put(KEY_CREATED_AT, System.currentTimeMillis());
db.insert(tableName, null, cv);
cursor = db.rawQuery("SELECT COUNT(*) FROM " + tableName, null);
cursor.moveToFirst();
count = cursor.getInt(0);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
if (cursor != null) {
cursor.close();
cursor = null;
}
dbHelper.deleteDatabase();
} finally {
if (cursor != null) {
cursor.close();
}
dbHelper.close();
}
return count;
} | [
"synchronized",
"int",
"storeObject",
"(",
"JSONObject",
"obj",
",",
"Table",
"table",
")",
"{",
"if",
"(",
"!",
"this",
".",
"belowMemThreshold",
"(",
")",
")",
"{",
"Logger",
".",
"v",
"(",
"\"There is not enough space left on the device to store data, data discarded\"",
")",
";",
"return",
"DB_OUT_OF_MEMORY_ERROR",
";",
"}",
"final",
"String",
"tableName",
"=",
"table",
".",
"getName",
"(",
")",
";",
"Cursor",
"cursor",
"=",
"null",
";",
"int",
"count",
"=",
"DB_UPDATE_ERROR",
";",
"//noinspection TryFinallyCanBeTryWithResources",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"final",
"ContentValues",
"cv",
"=",
"new",
"ContentValues",
"(",
")",
";",
"cv",
".",
"put",
"(",
"KEY_DATA",
",",
"obj",
".",
"toString",
"(",
")",
")",
";",
"cv",
".",
"put",
"(",
"KEY_CREATED_AT",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"db",
".",
"insert",
"(",
"tableName",
",",
"null",
",",
"cv",
")",
";",
"cursor",
"=",
"db",
".",
"rawQuery",
"(",
"\"SELECT COUNT(*) FROM \"",
"+",
"tableName",
",",
"null",
")",
";",
"cursor",
".",
"moveToFirst",
"(",
")",
";",
"count",
"=",
"cursor",
".",
"getInt",
"(",
"0",
")",
";",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error adding data to table \"",
"+",
"tableName",
"+",
"\" Recreating DB\"",
")",
";",
"if",
"(",
"cursor",
"!=",
"null",
")",
"{",
"cursor",
".",
"close",
"(",
")",
";",
"cursor",
"=",
"null",
";",
"}",
"dbHelper",
".",
"deleteDatabase",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"cursor",
"!=",
"null",
")",
"{",
"cursor",
".",
"close",
"(",
")",
";",
"}",
"dbHelper",
".",
"close",
"(",
")",
";",
"}",
"return",
"count",
";",
"}"
] | Adds a JSON string to the DB.
@param obj the JSON to record
@param table the table to insert into
@return the number of rows in the table, or DB_OUT_OF_MEMORY_ERROR/DB_UPDATE_ERROR | [
"Adds",
"a",
"JSON",
"string",
"to",
"the",
"DB",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L209-L246 |
164,305 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.storeUserProfile | synchronized long storeUserProfile(String id, JSONObject obj) {
if (id == null) return DB_UPDATE_ERROR;
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = Table.USER_PROFILES.getName();
long ret = DB_UPDATE_ERROR;
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put("_id", id);
ret = db.insertWithOnConflict(tableName, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
return ret;
} | java | synchronized long storeUserProfile(String id, JSONObject obj) {
if (id == null) return DB_UPDATE_ERROR;
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = Table.USER_PROFILES.getName();
long ret = DB_UPDATE_ERROR;
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put("_id", id);
ret = db.insertWithOnConflict(tableName, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
return ret;
} | [
"synchronized",
"long",
"storeUserProfile",
"(",
"String",
"id",
",",
"JSONObject",
"obj",
")",
"{",
"if",
"(",
"id",
"==",
"null",
")",
"return",
"DB_UPDATE_ERROR",
";",
"if",
"(",
"!",
"this",
".",
"belowMemThreshold",
"(",
")",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"There is not enough space left on the device to store data, data discarded\"",
")",
";",
"return",
"DB_OUT_OF_MEMORY_ERROR",
";",
"}",
"final",
"String",
"tableName",
"=",
"Table",
".",
"USER_PROFILES",
".",
"getName",
"(",
")",
";",
"long",
"ret",
"=",
"DB_UPDATE_ERROR",
";",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"final",
"ContentValues",
"cv",
"=",
"new",
"ContentValues",
"(",
")",
";",
"cv",
".",
"put",
"(",
"KEY_DATA",
",",
"obj",
".",
"toString",
"(",
")",
")",
";",
"cv",
".",
"put",
"(",
"\"_id\"",
",",
"id",
")",
";",
"ret",
"=",
"db",
".",
"insertWithOnConflict",
"(",
"tableName",
",",
"null",
",",
"cv",
",",
"SQLiteDatabase",
".",
"CONFLICT_REPLACE",
")",
";",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error adding data to table \"",
"+",
"tableName",
"+",
"\" Recreating DB\"",
")",
";",
"dbHelper",
".",
"deleteDatabase",
"(",
")",
";",
"}",
"finally",
"{",
"dbHelper",
".",
"close",
"(",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Adds a JSON string representing to the DB.
@param obj the JSON to record
@return the number of rows in the table, or DB_OUT_OF_MEMORY_ERROR/DB_UPDATE_ERROR | [
"Adds",
"a",
"JSON",
"string",
"representing",
"to",
"the",
"DB",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L254-L280 |
164,306 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.removeUserProfile | synchronized void removeUserProfile(String id) {
if (id == null) return;
final String tableName = Table.USER_PROFILES.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tableName, "_id = ?", new String[]{id});
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing user profile from " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
} | java | synchronized void removeUserProfile(String id) {
if (id == null) return;
final String tableName = Table.USER_PROFILES.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tableName, "_id = ?", new String[]{id});
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing user profile from " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
} | [
"synchronized",
"void",
"removeUserProfile",
"(",
"String",
"id",
")",
"{",
"if",
"(",
"id",
"==",
"null",
")",
"return",
";",
"final",
"String",
"tableName",
"=",
"Table",
".",
"USER_PROFILES",
".",
"getName",
"(",
")",
";",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"db",
".",
"delete",
"(",
"tableName",
",",
"\"_id = ?\"",
",",
"new",
"String",
"[",
"]",
"{",
"id",
"}",
")",
";",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error removing user profile from \"",
"+",
"tableName",
"+",
"\" Recreating DB\"",
")",
";",
"dbHelper",
".",
"deleteDatabase",
"(",
")",
";",
"}",
"finally",
"{",
"dbHelper",
".",
"close",
"(",
")",
";",
"}",
"}"
] | remove the user profile with id from the db. | [
"remove",
"the",
"user",
"profile",
"with",
"id",
"from",
"the",
"db",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L285-L298 |
164,307 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.removeEvents | synchronized void removeEvents(Table table) {
final String tName = table.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tName, null, null);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing all events from table " + tName + " Recreating DB");
deleteDB();
} finally {
dbHelper.close();
}
} | java | synchronized void removeEvents(Table table) {
final String tName = table.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tName, null, null);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing all events from table " + tName + " Recreating DB");
deleteDB();
} finally {
dbHelper.close();
}
} | [
"synchronized",
"void",
"removeEvents",
"(",
"Table",
"table",
")",
"{",
"final",
"String",
"tName",
"=",
"table",
".",
"getName",
"(",
")",
";",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"db",
".",
"delete",
"(",
"tName",
",",
"null",
",",
"null",
")",
";",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error removing all events from table \"",
"+",
"tName",
"+",
"\" Recreating DB\"",
")",
";",
"deleteDB",
"(",
")",
";",
"}",
"finally",
"{",
"dbHelper",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Removes all events from table
@param table the table to remove events | [
"Removes",
"all",
"events",
"from",
"table"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L338-L350 |
164,308 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.fetchEvents | synchronized JSONObject fetchEvents(Table table, final int limit) {
final String tName = table.getName();
Cursor cursor = null;
String lastId = null;
final JSONArray events = new JSONArray();
//noinspection TryFinallyCanBeTryWithResources
try {
final SQLiteDatabase db = dbHelper.getReadableDatabase();
cursor = db.rawQuery("SELECT * FROM " + tName +
" ORDER BY " + KEY_CREATED_AT + " ASC LIMIT " + limit, null);
while (cursor.moveToNext()) {
if (cursor.isLast()) {
lastId = cursor.getString(cursor.getColumnIndex("_id"));
}
try {
final JSONObject j = new JSONObject(cursor.getString(cursor.getColumnIndex(KEY_DATA)));
events.put(j);
} catch (final JSONException e) {
// Ignore
}
}
} catch (final SQLiteException e) {
getConfigLogger().verbose("Could not fetch records out of database " + tName + ".", e);
lastId = null;
} finally {
dbHelper.close();
if (cursor != null) {
cursor.close();
}
}
if (lastId != null) {
try {
final JSONObject ret = new JSONObject();
ret.put(lastId, events);
return ret;
} catch (JSONException e) {
// ignore
}
}
return null;
} | java | synchronized JSONObject fetchEvents(Table table, final int limit) {
final String tName = table.getName();
Cursor cursor = null;
String lastId = null;
final JSONArray events = new JSONArray();
//noinspection TryFinallyCanBeTryWithResources
try {
final SQLiteDatabase db = dbHelper.getReadableDatabase();
cursor = db.rawQuery("SELECT * FROM " + tName +
" ORDER BY " + KEY_CREATED_AT + " ASC LIMIT " + limit, null);
while (cursor.moveToNext()) {
if (cursor.isLast()) {
lastId = cursor.getString(cursor.getColumnIndex("_id"));
}
try {
final JSONObject j = new JSONObject(cursor.getString(cursor.getColumnIndex(KEY_DATA)));
events.put(j);
} catch (final JSONException e) {
// Ignore
}
}
} catch (final SQLiteException e) {
getConfigLogger().verbose("Could not fetch records out of database " + tName + ".", e);
lastId = null;
} finally {
dbHelper.close();
if (cursor != null) {
cursor.close();
}
}
if (lastId != null) {
try {
final JSONObject ret = new JSONObject();
ret.put(lastId, events);
return ret;
} catch (JSONException e) {
// ignore
}
}
return null;
} | [
"synchronized",
"JSONObject",
"fetchEvents",
"(",
"Table",
"table",
",",
"final",
"int",
"limit",
")",
"{",
"final",
"String",
"tName",
"=",
"table",
".",
"getName",
"(",
")",
";",
"Cursor",
"cursor",
"=",
"null",
";",
"String",
"lastId",
"=",
"null",
";",
"final",
"JSONArray",
"events",
"=",
"new",
"JSONArray",
"(",
")",
";",
"//noinspection TryFinallyCanBeTryWithResources",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getReadableDatabase",
"(",
")",
";",
"cursor",
"=",
"db",
".",
"rawQuery",
"(",
"\"SELECT * FROM \"",
"+",
"tName",
"+",
"\" ORDER BY \"",
"+",
"KEY_CREATED_AT",
"+",
"\" ASC LIMIT \"",
"+",
"limit",
",",
"null",
")",
";",
"while",
"(",
"cursor",
".",
"moveToNext",
"(",
")",
")",
"{",
"if",
"(",
"cursor",
".",
"isLast",
"(",
")",
")",
"{",
"lastId",
"=",
"cursor",
".",
"getString",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"\"_id\"",
")",
")",
";",
"}",
"try",
"{",
"final",
"JSONObject",
"j",
"=",
"new",
"JSONObject",
"(",
"cursor",
".",
"getString",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"KEY_DATA",
")",
")",
")",
";",
"events",
".",
"put",
"(",
"j",
")",
";",
"}",
"catch",
"(",
"final",
"JSONException",
"e",
")",
"{",
"// Ignore",
"}",
"}",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Could not fetch records out of database \"",
"+",
"tName",
"+",
"\".\"",
",",
"e",
")",
";",
"lastId",
"=",
"null",
";",
"}",
"finally",
"{",
"dbHelper",
".",
"close",
"(",
")",
";",
"if",
"(",
"cursor",
"!=",
"null",
")",
"{",
"cursor",
".",
"close",
"(",
")",
";",
"}",
"}",
"if",
"(",
"lastId",
"!=",
"null",
")",
"{",
"try",
"{",
"final",
"JSONObject",
"ret",
"=",
"new",
"JSONObject",
"(",
")",
";",
"ret",
".",
"put",
"(",
"lastId",
",",
"events",
")",
";",
"return",
"ret",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"// ignore",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns a JSONObject keyed with the lastId retrieved and a value of a JSONArray of the retrieved JSONObject events
@param table the table to read from
@return JSONObject containing the max row ID and a JSONArray of the JSONObject events or null | [
"Returns",
"a",
"JSONObject",
"keyed",
"with",
"the",
"lastId",
"retrieved",
"and",
"a",
"value",
"of",
"a",
"JSONArray",
"of",
"the",
"retrieved",
"JSONObject",
"events"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L413-L459 |
164,309 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.storeUninstallTimestamp | synchronized void storeUninstallTimestamp() {
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return ;
}
final String tableName = Table.UNINSTALL_TS.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_CREATED_AT, System.currentTimeMillis());
db.insert(tableName, null, cv);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
} | java | synchronized void storeUninstallTimestamp() {
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return ;
}
final String tableName = Table.UNINSTALL_TS.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_CREATED_AT, System.currentTimeMillis());
db.insert(tableName, null, cv);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
} | [
"synchronized",
"void",
"storeUninstallTimestamp",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"belowMemThreshold",
"(",
")",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"There is not enough space left on the device to store data, data discarded\"",
")",
";",
"return",
";",
"}",
"final",
"String",
"tableName",
"=",
"Table",
".",
"UNINSTALL_TS",
".",
"getName",
"(",
")",
";",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"final",
"ContentValues",
"cv",
"=",
"new",
"ContentValues",
"(",
")",
";",
"cv",
".",
"put",
"(",
"KEY_CREATED_AT",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"db",
".",
"insert",
"(",
"tableName",
",",
"null",
",",
"cv",
")",
";",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error adding data to table \"",
"+",
"tableName",
"+",
"\" Recreating DB\"",
")",
";",
"dbHelper",
".",
"deleteDatabase",
"(",
")",
";",
"}",
"finally",
"{",
"dbHelper",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Adds a String timestamp representing uninstall flag to the DB. | [
"Adds",
"a",
"String",
"timestamp",
"representing",
"uninstall",
"flag",
"to",
"the",
"DB",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L588-L608 |
164,310 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.deleteMessageForId | synchronized boolean deleteMessageForId(String messageId, String userId){
if(messageId == null || userId == null) return false;
final String tName = Table.INBOX_MESSAGES.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tName, _ID + " = ? AND " + USER_ID + " = ?", new String[]{messageId,userId});
return true;
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing stale records from " + tName, e);
return false;
} finally {
dbHelper.close();
}
} | java | synchronized boolean deleteMessageForId(String messageId, String userId){
if(messageId == null || userId == null) return false;
final String tName = Table.INBOX_MESSAGES.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tName, _ID + " = ? AND " + USER_ID + " = ?", new String[]{messageId,userId});
return true;
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing stale records from " + tName, e);
return false;
} finally {
dbHelper.close();
}
} | [
"synchronized",
"boolean",
"deleteMessageForId",
"(",
"String",
"messageId",
",",
"String",
"userId",
")",
"{",
"if",
"(",
"messageId",
"==",
"null",
"||",
"userId",
"==",
"null",
")",
"return",
"false",
";",
"final",
"String",
"tName",
"=",
"Table",
".",
"INBOX_MESSAGES",
".",
"getName",
"(",
")",
";",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"db",
".",
"delete",
"(",
"tName",
",",
"_ID",
"+",
"\" = ? AND \"",
"+",
"USER_ID",
"+",
"\" = ?\"",
",",
"new",
"String",
"[",
"]",
"{",
"messageId",
",",
"userId",
"}",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error removing stale records from \"",
"+",
"tName",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"finally",
"{",
"dbHelper",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Deletes the inbox message for given messageId
@param messageId String messageId
@return boolean value based on success of operation | [
"Deletes",
"the",
"inbox",
"message",
"for",
"given",
"messageId"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L672-L687 |
164,311 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.markReadMessageForId | synchronized boolean markReadMessageForId(String messageId, String userId){
if(messageId == null || userId == null) return false;
final String tName = Table.INBOX_MESSAGES.getName();
try{
final SQLiteDatabase db = dbHelper.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(IS_READ,1);
db.update(Table.INBOX_MESSAGES.getName(), cv,_ID + " = ? AND " + USER_ID + " = ?",new String[]{messageId,userId});
return true;
}catch (final SQLiteException e){
getConfigLogger().verbose("Error removing stale records from " + tName, e);
return false;
} finally {
dbHelper.close();
}
} | java | synchronized boolean markReadMessageForId(String messageId, String userId){
if(messageId == null || userId == null) return false;
final String tName = Table.INBOX_MESSAGES.getName();
try{
final SQLiteDatabase db = dbHelper.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(IS_READ,1);
db.update(Table.INBOX_MESSAGES.getName(), cv,_ID + " = ? AND " + USER_ID + " = ?",new String[]{messageId,userId});
return true;
}catch (final SQLiteException e){
getConfigLogger().verbose("Error removing stale records from " + tName, e);
return false;
} finally {
dbHelper.close();
}
} | [
"synchronized",
"boolean",
"markReadMessageForId",
"(",
"String",
"messageId",
",",
"String",
"userId",
")",
"{",
"if",
"(",
"messageId",
"==",
"null",
"||",
"userId",
"==",
"null",
")",
"return",
"false",
";",
"final",
"String",
"tName",
"=",
"Table",
".",
"INBOX_MESSAGES",
".",
"getName",
"(",
")",
";",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"ContentValues",
"cv",
"=",
"new",
"ContentValues",
"(",
")",
";",
"cv",
".",
"put",
"(",
"IS_READ",
",",
"1",
")",
";",
"db",
".",
"update",
"(",
"Table",
".",
"INBOX_MESSAGES",
".",
"getName",
"(",
")",
",",
"cv",
",",
"_ID",
"+",
"\" = ? AND \"",
"+",
"USER_ID",
"+",
"\" = ?\"",
",",
"new",
"String",
"[",
"]",
"{",
"messageId",
",",
"userId",
"}",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error removing stale records from \"",
"+",
"tName",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"finally",
"{",
"dbHelper",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Marks inbox message as read for given messageId
@param messageId String messageId
@return boolean value depending on success of operation | [
"Marks",
"inbox",
"message",
"as",
"read",
"for",
"given",
"messageId"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L694-L710 |
164,312 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.getMessages | synchronized ArrayList<CTMessageDAO> getMessages(String userId){
final String tName = Table.INBOX_MESSAGES.getName();
Cursor cursor;
ArrayList<CTMessageDAO> messageDAOArrayList = new ArrayList<>();
try{
final SQLiteDatabase db = dbHelper.getWritableDatabase();
cursor= db.rawQuery("SELECT * FROM "+tName+" WHERE " + USER_ID + " = ? ORDER BY " + KEY_CREATED_AT+ " DESC", new String[]{userId});
if(cursor != null) {
while(cursor.moveToNext()){
CTMessageDAO ctMessageDAO = new CTMessageDAO();
ctMessageDAO.setId(cursor.getString(cursor.getColumnIndex(_ID)));
ctMessageDAO.setJsonData(new JSONObject(cursor.getString(cursor.getColumnIndex(KEY_DATA))));
ctMessageDAO.setWzrkParams(new JSONObject(cursor.getString(cursor.getColumnIndex(WZRKPARAMS))));
ctMessageDAO.setDate(cursor.getLong(cursor.getColumnIndex(KEY_CREATED_AT)));
ctMessageDAO.setExpires(cursor.getLong(cursor.getColumnIndex(EXPIRES)));
ctMessageDAO.setRead(cursor.getInt(cursor.getColumnIndex(IS_READ)));
ctMessageDAO.setUserId(cursor.getString(cursor.getColumnIndex(USER_ID)));
ctMessageDAO.setTags(cursor.getString(cursor.getColumnIndex(TAGS)));
ctMessageDAO.setCampaignId(cursor.getString(cursor.getColumnIndex(CAMPAIGN)));
messageDAOArrayList.add(ctMessageDAO);
}
cursor.close();
}
return messageDAOArrayList;
}catch (final SQLiteException e){
getConfigLogger().verbose("Error retrieving records from " + tName, e);
return null;
} catch (JSONException e) {
getConfigLogger().verbose("Error retrieving records from " + tName, e.getMessage());
return null;
} finally {
dbHelper.close();
}
} | java | synchronized ArrayList<CTMessageDAO> getMessages(String userId){
final String tName = Table.INBOX_MESSAGES.getName();
Cursor cursor;
ArrayList<CTMessageDAO> messageDAOArrayList = new ArrayList<>();
try{
final SQLiteDatabase db = dbHelper.getWritableDatabase();
cursor= db.rawQuery("SELECT * FROM "+tName+" WHERE " + USER_ID + " = ? ORDER BY " + KEY_CREATED_AT+ " DESC", new String[]{userId});
if(cursor != null) {
while(cursor.moveToNext()){
CTMessageDAO ctMessageDAO = new CTMessageDAO();
ctMessageDAO.setId(cursor.getString(cursor.getColumnIndex(_ID)));
ctMessageDAO.setJsonData(new JSONObject(cursor.getString(cursor.getColumnIndex(KEY_DATA))));
ctMessageDAO.setWzrkParams(new JSONObject(cursor.getString(cursor.getColumnIndex(WZRKPARAMS))));
ctMessageDAO.setDate(cursor.getLong(cursor.getColumnIndex(KEY_CREATED_AT)));
ctMessageDAO.setExpires(cursor.getLong(cursor.getColumnIndex(EXPIRES)));
ctMessageDAO.setRead(cursor.getInt(cursor.getColumnIndex(IS_READ)));
ctMessageDAO.setUserId(cursor.getString(cursor.getColumnIndex(USER_ID)));
ctMessageDAO.setTags(cursor.getString(cursor.getColumnIndex(TAGS)));
ctMessageDAO.setCampaignId(cursor.getString(cursor.getColumnIndex(CAMPAIGN)));
messageDAOArrayList.add(ctMessageDAO);
}
cursor.close();
}
return messageDAOArrayList;
}catch (final SQLiteException e){
getConfigLogger().verbose("Error retrieving records from " + tName, e);
return null;
} catch (JSONException e) {
getConfigLogger().verbose("Error retrieving records from " + tName, e.getMessage());
return null;
} finally {
dbHelper.close();
}
} | [
"synchronized",
"ArrayList",
"<",
"CTMessageDAO",
">",
"getMessages",
"(",
"String",
"userId",
")",
"{",
"final",
"String",
"tName",
"=",
"Table",
".",
"INBOX_MESSAGES",
".",
"getName",
"(",
")",
";",
"Cursor",
"cursor",
";",
"ArrayList",
"<",
"CTMessageDAO",
">",
"messageDAOArrayList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"cursor",
"=",
"db",
".",
"rawQuery",
"(",
"\"SELECT * FROM \"",
"+",
"tName",
"+",
"\" WHERE \"",
"+",
"USER_ID",
"+",
"\" = ? ORDER BY \"",
"+",
"KEY_CREATED_AT",
"+",
"\" DESC\"",
",",
"new",
"String",
"[",
"]",
"{",
"userId",
"}",
")",
";",
"if",
"(",
"cursor",
"!=",
"null",
")",
"{",
"while",
"(",
"cursor",
".",
"moveToNext",
"(",
")",
")",
"{",
"CTMessageDAO",
"ctMessageDAO",
"=",
"new",
"CTMessageDAO",
"(",
")",
";",
"ctMessageDAO",
".",
"setId",
"(",
"cursor",
".",
"getString",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"_ID",
")",
")",
")",
";",
"ctMessageDAO",
".",
"setJsonData",
"(",
"new",
"JSONObject",
"(",
"cursor",
".",
"getString",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"KEY_DATA",
")",
")",
")",
")",
";",
"ctMessageDAO",
".",
"setWzrkParams",
"(",
"new",
"JSONObject",
"(",
"cursor",
".",
"getString",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"WZRKPARAMS",
")",
")",
")",
")",
";",
"ctMessageDAO",
".",
"setDate",
"(",
"cursor",
".",
"getLong",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"KEY_CREATED_AT",
")",
")",
")",
";",
"ctMessageDAO",
".",
"setExpires",
"(",
"cursor",
".",
"getLong",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"EXPIRES",
")",
")",
")",
";",
"ctMessageDAO",
".",
"setRead",
"(",
"cursor",
".",
"getInt",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"IS_READ",
")",
")",
")",
";",
"ctMessageDAO",
".",
"setUserId",
"(",
"cursor",
".",
"getString",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"USER_ID",
")",
")",
")",
";",
"ctMessageDAO",
".",
"setTags",
"(",
"cursor",
".",
"getString",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"TAGS",
")",
")",
")",
";",
"ctMessageDAO",
".",
"setCampaignId",
"(",
"cursor",
".",
"getString",
"(",
"cursor",
".",
"getColumnIndex",
"(",
"CAMPAIGN",
")",
")",
")",
";",
"messageDAOArrayList",
".",
"add",
"(",
"ctMessageDAO",
")",
";",
"}",
"cursor",
".",
"close",
"(",
")",
";",
"}",
"return",
"messageDAOArrayList",
";",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error retrieving records from \"",
"+",
"tName",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error retrieving records from \"",
"+",
"tName",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"finally",
"{",
"dbHelper",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Retrieves list of inbox messages based on given userId
@param userId String userid
@return ArrayList of {@link CTMessageDAO} | [
"Retrieves",
"list",
"of",
"inbox",
"messages",
"based",
"on",
"given",
"userId"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L717-L750 |
164,313 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readContents | private void readContents(int maxFrames) {
// Read GIF file content blocks.
boolean done = false;
while (!(done || err() || header.frameCount > maxFrames)) {
int code = read();
switch (code) {
// Image separator.
case 0x2C:
// The graphics control extension is optional, but will always come first if it exists.
// If one did
// exist, there will be a non-null current frame which we should use. However if one
// did not exist,
// the current frame will be null and we must create it here. See issue #134.
if (header.currentFrame == null) {
header.currentFrame = new GifFrame();
}
readBitmap();
break;
// Extension.
case 0x21:
code = read();
switch (code) {
// Graphics control extension.
case 0xf9:
// Start a new frame.
header.currentFrame = new GifFrame();
readGraphicControlExt();
break;
// Application extension.
case 0xff:
readBlock();
String app = "";
for (int i = 0; i < 11; i++) {
app += (char) block[i];
}
if (app.equals("NETSCAPE2.0")) {
readNetscapeExt();
} else {
// Don't care.
skip();
}
break;
// Comment extension.
case 0xfe:
skip();
break;
// Plain text extension.
case 0x01:
skip();
break;
// Uninteresting extension.
default:
skip();
}
break;
// Terminator.
case 0x3b:
done = true;
break;
// Bad byte, but keep going and see what happens break;
case 0x00:
default:
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
}
} | java | private void readContents(int maxFrames) {
// Read GIF file content blocks.
boolean done = false;
while (!(done || err() || header.frameCount > maxFrames)) {
int code = read();
switch (code) {
// Image separator.
case 0x2C:
// The graphics control extension is optional, but will always come first if it exists.
// If one did
// exist, there will be a non-null current frame which we should use. However if one
// did not exist,
// the current frame will be null and we must create it here. See issue #134.
if (header.currentFrame == null) {
header.currentFrame = new GifFrame();
}
readBitmap();
break;
// Extension.
case 0x21:
code = read();
switch (code) {
// Graphics control extension.
case 0xf9:
// Start a new frame.
header.currentFrame = new GifFrame();
readGraphicControlExt();
break;
// Application extension.
case 0xff:
readBlock();
String app = "";
for (int i = 0; i < 11; i++) {
app += (char) block[i];
}
if (app.equals("NETSCAPE2.0")) {
readNetscapeExt();
} else {
// Don't care.
skip();
}
break;
// Comment extension.
case 0xfe:
skip();
break;
// Plain text extension.
case 0x01:
skip();
break;
// Uninteresting extension.
default:
skip();
}
break;
// Terminator.
case 0x3b:
done = true;
break;
// Bad byte, but keep going and see what happens break;
case 0x00:
default:
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
}
} | [
"private",
"void",
"readContents",
"(",
"int",
"maxFrames",
")",
"{",
"// Read GIF file content blocks.",
"boolean",
"done",
"=",
"false",
";",
"while",
"(",
"!",
"(",
"done",
"||",
"err",
"(",
")",
"||",
"header",
".",
"frameCount",
">",
"maxFrames",
")",
")",
"{",
"int",
"code",
"=",
"read",
"(",
")",
";",
"switch",
"(",
"code",
")",
"{",
"// Image separator.",
"case",
"0x2C",
":",
"// The graphics control extension is optional, but will always come first if it exists.",
"// If one did",
"// exist, there will be a non-null current frame which we should use. However if one",
"// did not exist,",
"// the current frame will be null and we must create it here. See issue #134.",
"if",
"(",
"header",
".",
"currentFrame",
"==",
"null",
")",
"{",
"header",
".",
"currentFrame",
"=",
"new",
"GifFrame",
"(",
")",
";",
"}",
"readBitmap",
"(",
")",
";",
"break",
";",
"// Extension.",
"case",
"0x21",
":",
"code",
"=",
"read",
"(",
")",
";",
"switch",
"(",
"code",
")",
"{",
"// Graphics control extension.",
"case",
"0xf9",
":",
"// Start a new frame.",
"header",
".",
"currentFrame",
"=",
"new",
"GifFrame",
"(",
")",
";",
"readGraphicControlExt",
"(",
")",
";",
"break",
";",
"// Application extension.",
"case",
"0xff",
":",
"readBlock",
"(",
")",
";",
"String",
"app",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"11",
";",
"i",
"++",
")",
"{",
"app",
"+=",
"(",
"char",
")",
"block",
"[",
"i",
"]",
";",
"}",
"if",
"(",
"app",
".",
"equals",
"(",
"\"NETSCAPE2.0\"",
")",
")",
"{",
"readNetscapeExt",
"(",
")",
";",
"}",
"else",
"{",
"// Don't care.",
"skip",
"(",
")",
";",
"}",
"break",
";",
"// Comment extension.",
"case",
"0xfe",
":",
"skip",
"(",
")",
";",
"break",
";",
"// Plain text extension.",
"case",
"0x01",
":",
"skip",
"(",
")",
";",
"break",
";",
"// Uninteresting extension.",
"default",
":",
"skip",
"(",
")",
";",
"}",
"break",
";",
"// Terminator.",
"case",
"0x3b",
":",
"done",
"=",
"true",
";",
"break",
";",
"// Bad byte, but keep going and see what happens break;",
"case",
"0x00",
":",
"default",
":",
"header",
".",
"status",
"=",
"GifDecoder",
".",
"STATUS_FORMAT_ERROR",
";",
"}",
"}",
"}"
] | Main file parser. Reads GIF content blocks. Stops after reading maxFrames | [
"Main",
"file",
"parser",
".",
"Reads",
"GIF",
"content",
"blocks",
".",
"Stops",
"after",
"reading",
"maxFrames"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L115-L180 |
164,314 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readBitmap | private void readBitmap() {
// (sub)image position & size.
header.currentFrame.ix = readShort();
header.currentFrame.iy = readShort();
header.currentFrame.iw = readShort();
header.currentFrame.ih = readShort();
int packed = read();
// 1 - local color table flag interlace
boolean lctFlag = (packed & 0x80) != 0;
int lctSize = (int) Math.pow(2, (packed & 0x07) + 1);
// 3 - sort flag
// 4-5 - reserved lctSize = 2 << (packed & 7); // 6-8 - local color
// table size
header.currentFrame.interlace = (packed & 0x40) != 0;
if (lctFlag) {
// Read table.
header.currentFrame.lct = readColorTable(lctSize);
} else {
// No local color table.
header.currentFrame.lct = null;
}
// Save this as the decoding position pointer.
header.currentFrame.bufferFrameStart = rawData.position();
// False decode pixel data to advance buffer.
skipImageData();
if (err()) {
return;
}
header.frameCount++;
// Add image to frame.
header.frames.add(header.currentFrame);
} | java | private void readBitmap() {
// (sub)image position & size.
header.currentFrame.ix = readShort();
header.currentFrame.iy = readShort();
header.currentFrame.iw = readShort();
header.currentFrame.ih = readShort();
int packed = read();
// 1 - local color table flag interlace
boolean lctFlag = (packed & 0x80) != 0;
int lctSize = (int) Math.pow(2, (packed & 0x07) + 1);
// 3 - sort flag
// 4-5 - reserved lctSize = 2 << (packed & 7); // 6-8 - local color
// table size
header.currentFrame.interlace = (packed & 0x40) != 0;
if (lctFlag) {
// Read table.
header.currentFrame.lct = readColorTable(lctSize);
} else {
// No local color table.
header.currentFrame.lct = null;
}
// Save this as the decoding position pointer.
header.currentFrame.bufferFrameStart = rawData.position();
// False decode pixel data to advance buffer.
skipImageData();
if (err()) {
return;
}
header.frameCount++;
// Add image to frame.
header.frames.add(header.currentFrame);
} | [
"private",
"void",
"readBitmap",
"(",
")",
"{",
"// (sub)image position & size.",
"header",
".",
"currentFrame",
".",
"ix",
"=",
"readShort",
"(",
")",
";",
"header",
".",
"currentFrame",
".",
"iy",
"=",
"readShort",
"(",
")",
";",
"header",
".",
"currentFrame",
".",
"iw",
"=",
"readShort",
"(",
")",
";",
"header",
".",
"currentFrame",
".",
"ih",
"=",
"readShort",
"(",
")",
";",
"int",
"packed",
"=",
"read",
"(",
")",
";",
"// 1 - local color table flag interlace",
"boolean",
"lctFlag",
"=",
"(",
"packed",
"&",
"0x80",
")",
"!=",
"0",
";",
"int",
"lctSize",
"=",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
"2",
",",
"(",
"packed",
"&",
"0x07",
")",
"+",
"1",
")",
";",
"// 3 - sort flag",
"// 4-5 - reserved lctSize = 2 << (packed & 7); // 6-8 - local color",
"// table size",
"header",
".",
"currentFrame",
".",
"interlace",
"=",
"(",
"packed",
"&",
"0x40",
")",
"!=",
"0",
";",
"if",
"(",
"lctFlag",
")",
"{",
"// Read table.",
"header",
".",
"currentFrame",
".",
"lct",
"=",
"readColorTable",
"(",
"lctSize",
")",
";",
"}",
"else",
"{",
"// No local color table.",
"header",
".",
"currentFrame",
".",
"lct",
"=",
"null",
";",
"}",
"// Save this as the decoding position pointer.",
"header",
".",
"currentFrame",
".",
"bufferFrameStart",
"=",
"rawData",
".",
"position",
"(",
")",
";",
"// False decode pixel data to advance buffer.",
"skipImageData",
"(",
")",
";",
"if",
"(",
"err",
"(",
")",
")",
"{",
"return",
";",
"}",
"header",
".",
"frameCount",
"++",
";",
"// Add image to frame.",
"header",
".",
"frames",
".",
"add",
"(",
"header",
".",
"currentFrame",
")",
";",
"}"
] | Reads next frame image. | [
"Reads",
"next",
"frame",
"image",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L213-L249 |
164,315 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readNetscapeExt | private void readNetscapeExt() {
do {
readBlock();
if (block[0] == 1) {
// Loop count sub-block.
int b1 = ((int) block[1]) & 0xff;
int b2 = ((int) block[2]) & 0xff;
header.loopCount = (b2 << 8) | b1;
if(header.loopCount == 0) {
header.loopCount = GifDecoder.LOOP_FOREVER;
}
}
} while ((blockSize > 0) && !err());
} | java | private void readNetscapeExt() {
do {
readBlock();
if (block[0] == 1) {
// Loop count sub-block.
int b1 = ((int) block[1]) & 0xff;
int b2 = ((int) block[2]) & 0xff;
header.loopCount = (b2 << 8) | b1;
if(header.loopCount == 0) {
header.loopCount = GifDecoder.LOOP_FOREVER;
}
}
} while ((blockSize > 0) && !err());
} | [
"private",
"void",
"readNetscapeExt",
"(",
")",
"{",
"do",
"{",
"readBlock",
"(",
")",
";",
"if",
"(",
"block",
"[",
"0",
"]",
"==",
"1",
")",
"{",
"// Loop count sub-block.",
"int",
"b1",
"=",
"(",
"(",
"int",
")",
"block",
"[",
"1",
"]",
")",
"&",
"0xff",
";",
"int",
"b2",
"=",
"(",
"(",
"int",
")",
"block",
"[",
"2",
"]",
")",
"&",
"0xff",
";",
"header",
".",
"loopCount",
"=",
"(",
"b2",
"<<",
"8",
")",
"|",
"b1",
";",
"if",
"(",
"header",
".",
"loopCount",
"==",
"0",
")",
"{",
"header",
".",
"loopCount",
"=",
"GifDecoder",
".",
"LOOP_FOREVER",
";",
"}",
"}",
"}",
"while",
"(",
"(",
"blockSize",
">",
"0",
")",
"&&",
"!",
"err",
"(",
")",
")",
";",
"}"
] | Reads Netscape extension to obtain iteration count. | [
"Reads",
"Netscape",
"extension",
"to",
"obtain",
"iteration",
"count",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L254-L267 |
164,316 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readLSD | private void readLSD() {
// Logical screen size.
header.width = readShort();
header.height = readShort();
// Packed fields
int packed = read();
// 1 : global color table flag.
header.gctFlag = (packed & 0x80) != 0;
// 2-4 : color resolution.
// 5 : gct sort flag.
// 6-8 : gct size.
header.gctSize = 2 << (packed & 7);
// Background color index.
header.bgIndex = read();
// Pixel aspect ratio
header.pixelAspect = read();
} | java | private void readLSD() {
// Logical screen size.
header.width = readShort();
header.height = readShort();
// Packed fields
int packed = read();
// 1 : global color table flag.
header.gctFlag = (packed & 0x80) != 0;
// 2-4 : color resolution.
// 5 : gct sort flag.
// 6-8 : gct size.
header.gctSize = 2 << (packed & 7);
// Background color index.
header.bgIndex = read();
// Pixel aspect ratio
header.pixelAspect = read();
} | [
"private",
"void",
"readLSD",
"(",
")",
"{",
"// Logical screen size.",
"header",
".",
"width",
"=",
"readShort",
"(",
")",
";",
"header",
".",
"height",
"=",
"readShort",
"(",
")",
";",
"// Packed fields",
"int",
"packed",
"=",
"read",
"(",
")",
";",
"// 1 : global color table flag.",
"header",
".",
"gctFlag",
"=",
"(",
"packed",
"&",
"0x80",
")",
"!=",
"0",
";",
"// 2-4 : color resolution.",
"// 5 : gct sort flag.",
"// 6-8 : gct size.",
"header",
".",
"gctSize",
"=",
"2",
"<<",
"(",
"packed",
"&",
"7",
")",
";",
"// Background color index.",
"header",
".",
"bgIndex",
"=",
"read",
"(",
")",
";",
"// Pixel aspect ratio",
"header",
".",
"pixelAspect",
"=",
"read",
"(",
")",
";",
"}"
] | Reads Logical Screen Descriptor. | [
"Reads",
"Logical",
"Screen",
"Descriptor",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L292-L308 |
164,317 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readColorTable | private int[] readColorTable(int ncolors) {
int nbytes = 3 * ncolors;
int[] tab = null;
byte[] c = new byte[nbytes];
try {
rawData.get(c);
// Max size to avoid bounds checks.
tab = new int[MAX_BLOCK_SIZE];
int i = 0;
int j = 0;
while (i < ncolors) {
int r = ((int) c[j++]) & 0xff;
int g = ((int) c[j++]) & 0xff;
int b = ((int) c[j++]) & 0xff;
tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b;
}
} catch (BufferUnderflowException e) {
//if (Log.isLoggable(TAG, Log.DEBUG)) {
Logger.d(TAG, "Format Error Reading Color Table", e);
//}
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
return tab;
} | java | private int[] readColorTable(int ncolors) {
int nbytes = 3 * ncolors;
int[] tab = null;
byte[] c = new byte[nbytes];
try {
rawData.get(c);
// Max size to avoid bounds checks.
tab = new int[MAX_BLOCK_SIZE];
int i = 0;
int j = 0;
while (i < ncolors) {
int r = ((int) c[j++]) & 0xff;
int g = ((int) c[j++]) & 0xff;
int b = ((int) c[j++]) & 0xff;
tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b;
}
} catch (BufferUnderflowException e) {
//if (Log.isLoggable(TAG, Log.DEBUG)) {
Logger.d(TAG, "Format Error Reading Color Table", e);
//}
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
return tab;
} | [
"private",
"int",
"[",
"]",
"readColorTable",
"(",
"int",
"ncolors",
")",
"{",
"int",
"nbytes",
"=",
"3",
"*",
"ncolors",
";",
"int",
"[",
"]",
"tab",
"=",
"null",
";",
"byte",
"[",
"]",
"c",
"=",
"new",
"byte",
"[",
"nbytes",
"]",
";",
"try",
"{",
"rawData",
".",
"get",
"(",
"c",
")",
";",
"// Max size to avoid bounds checks.",
"tab",
"=",
"new",
"int",
"[",
"MAX_BLOCK_SIZE",
"]",
";",
"int",
"i",
"=",
"0",
";",
"int",
"j",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"ncolors",
")",
"{",
"int",
"r",
"=",
"(",
"(",
"int",
")",
"c",
"[",
"j",
"++",
"]",
")",
"&",
"0xff",
";",
"int",
"g",
"=",
"(",
"(",
"int",
")",
"c",
"[",
"j",
"++",
"]",
")",
"&",
"0xff",
";",
"int",
"b",
"=",
"(",
"(",
"int",
")",
"c",
"[",
"j",
"++",
"]",
")",
"&",
"0xff",
";",
"tab",
"[",
"i",
"++",
"]",
"=",
"0xff000000",
"|",
"(",
"r",
"<<",
"16",
")",
"|",
"(",
"g",
"<<",
"8",
")",
"|",
"b",
";",
"}",
"}",
"catch",
"(",
"BufferUnderflowException",
"e",
")",
"{",
"//if (Log.isLoggable(TAG, Log.DEBUG)) {",
"Logger",
".",
"d",
"(",
"TAG",
",",
"\"Format Error Reading Color Table\"",
",",
"e",
")",
";",
"//}",
"header",
".",
"status",
"=",
"GifDecoder",
".",
"STATUS_FORMAT_ERROR",
";",
"}",
"return",
"tab",
";",
"}"
] | Reads color table as 256 RGB integer values.
@param ncolors int number of colors to read.
@return int array containing 256 colors (packed ARGB with full alpha). | [
"Reads",
"color",
"table",
"as",
"256",
"RGB",
"integer",
"values",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L316-L342 |
164,318 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.skip | private void skip() {
try {
int blockSize;
do {
blockSize = read();
rawData.position(rawData.position() + blockSize);
} while (blockSize > 0);
} catch (IllegalArgumentException ex) {
}
} | java | private void skip() {
try {
int blockSize;
do {
blockSize = read();
rawData.position(rawData.position() + blockSize);
} while (blockSize > 0);
} catch (IllegalArgumentException ex) {
}
} | [
"private",
"void",
"skip",
"(",
")",
"{",
"try",
"{",
"int",
"blockSize",
";",
"do",
"{",
"blockSize",
"=",
"read",
"(",
")",
";",
"rawData",
".",
"position",
"(",
"rawData",
".",
"position",
"(",
")",
"+",
"blockSize",
")",
";",
"}",
"while",
"(",
"blockSize",
">",
"0",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ex",
")",
"{",
"}",
"}"
] | Skips variable length blocks up to and including next zero length block. | [
"Skips",
"variable",
"length",
"blocks",
"up",
"to",
"and",
"including",
"next",
"zero",
"length",
"block",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L357-L366 |
164,319 | CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.read | private int read() {
int curByte = 0;
try {
curByte = rawData.get() & 0xFF;
} catch (Exception e) {
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
return curByte;
} | java | private int read() {
int curByte = 0;
try {
curByte = rawData.get() & 0xFF;
} catch (Exception e) {
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
return curByte;
} | [
"private",
"int",
"read",
"(",
")",
"{",
"int",
"curByte",
"=",
"0",
";",
"try",
"{",
"curByte",
"=",
"rawData",
".",
"get",
"(",
")",
"&",
"0xFF",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"header",
".",
"status",
"=",
"GifDecoder",
".",
"STATUS_FORMAT_ERROR",
";",
"}",
"return",
"curByte",
";",
"}"
] | Reads a single byte from the input stream. | [
"Reads",
"a",
"single",
"byte",
"from",
"the",
"input",
"stream",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L399-L407 |
164,320 | SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/builder/TreeScanner.java | TreeScanner.isToIgnore | private boolean isToIgnore(CtElement element) {
if (element instanceof CtStatementList && !(element instanceof CtCase)) {
if (element.getRoleInParent() == CtRole.ELSE || element.getRoleInParent() == CtRole.THEN) {
return false;
}
return true;
}
return element.isImplicit() || element instanceof CtReference;
} | java | private boolean isToIgnore(CtElement element) {
if (element instanceof CtStatementList && !(element instanceof CtCase)) {
if (element.getRoleInParent() == CtRole.ELSE || element.getRoleInParent() == CtRole.THEN) {
return false;
}
return true;
}
return element.isImplicit() || element instanceof CtReference;
} | [
"private",
"boolean",
"isToIgnore",
"(",
"CtElement",
"element",
")",
"{",
"if",
"(",
"element",
"instanceof",
"CtStatementList",
"&&",
"!",
"(",
"element",
"instanceof",
"CtCase",
")",
")",
"{",
"if",
"(",
"element",
".",
"getRoleInParent",
"(",
")",
"==",
"CtRole",
".",
"ELSE",
"||",
"element",
".",
"getRoleInParent",
"(",
")",
"==",
"CtRole",
".",
"THEN",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"return",
"element",
".",
"isImplicit",
"(",
")",
"||",
"element",
"instanceof",
"CtReference",
";",
"}"
] | Ignore some element from the AST
@param element
@return | [
"Ignore",
"some",
"element",
"from",
"the",
"AST"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/builder/TreeScanner.java#L71-L79 |
164,321 | SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/builder/Json4SpoonGenerator.java | Json4SpoonGenerator.getJSONwithOperations | public JsonObject getJSONwithOperations(TreeContext context, ITree tree, List<Operation> operations) {
OperationNodePainter opNodePainter = new OperationNodePainter(operations);
Collection<NodePainter> painters = new ArrayList<NodePainter>();
painters.add(opNodePainter);
return getJSONwithCustorLabels(context, tree, painters);
} | java | public JsonObject getJSONwithOperations(TreeContext context, ITree tree, List<Operation> operations) {
OperationNodePainter opNodePainter = new OperationNodePainter(operations);
Collection<NodePainter> painters = new ArrayList<NodePainter>();
painters.add(opNodePainter);
return getJSONwithCustorLabels(context, tree, painters);
} | [
"public",
"JsonObject",
"getJSONwithOperations",
"(",
"TreeContext",
"context",
",",
"ITree",
"tree",
",",
"List",
"<",
"Operation",
">",
"operations",
")",
"{",
"OperationNodePainter",
"opNodePainter",
"=",
"new",
"OperationNodePainter",
"(",
"operations",
")",
";",
"Collection",
"<",
"NodePainter",
">",
"painters",
"=",
"new",
"ArrayList",
"<",
"NodePainter",
">",
"(",
")",
";",
"painters",
".",
"add",
"(",
"opNodePainter",
")",
";",
"return",
"getJSONwithCustorLabels",
"(",
"context",
",",
"tree",
",",
"painters",
")",
";",
"}"
] | Decorates a node with the affected operator, if any.
@param context
@param tree
@param operations
@return | [
"Decorates",
"a",
"node",
"with",
"the",
"affected",
"operator",
"if",
"any",
"."
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/builder/Json4SpoonGenerator.java#L76-L82 |
164,322 | SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/diff/ActionClassifier.java | ActionClassifier.getRootActions | public List<Action> getRootActions() {
final List<Action> rootActions = srcUpdTrees.stream().map(t -> originalActionsSrc.get(t))
.collect(Collectors.toList());
rootActions.addAll(srcDelTrees.stream() //
.filter(t -> !srcDelTrees.contains(t.getParent()) && !srcUpdTrees.contains(t.getParent())) //
.map(t -> originalActionsSrc.get(t)) //
.collect(Collectors.toList()));
rootActions.addAll(dstAddTrees.stream() //
.filter(t -> !dstAddTrees.contains(t.getParent()) && !dstUpdTrees.contains(t.getParent())) //
.map(t -> originalActionsDst.get(t)) //
.collect(Collectors.toList()));
rootActions.addAll(dstMvTrees.stream() //
.filter(t -> !dstMvTrees.contains(t.getParent())) //
.map(t -> originalActionsDst.get(t)) //
.collect(Collectors.toList()));
rootActions.removeAll(Collections.singleton(null));
return rootActions;
} | java | public List<Action> getRootActions() {
final List<Action> rootActions = srcUpdTrees.stream().map(t -> originalActionsSrc.get(t))
.collect(Collectors.toList());
rootActions.addAll(srcDelTrees.stream() //
.filter(t -> !srcDelTrees.contains(t.getParent()) && !srcUpdTrees.contains(t.getParent())) //
.map(t -> originalActionsSrc.get(t)) //
.collect(Collectors.toList()));
rootActions.addAll(dstAddTrees.stream() //
.filter(t -> !dstAddTrees.contains(t.getParent()) && !dstUpdTrees.contains(t.getParent())) //
.map(t -> originalActionsDst.get(t)) //
.collect(Collectors.toList()));
rootActions.addAll(dstMvTrees.stream() //
.filter(t -> !dstMvTrees.contains(t.getParent())) //
.map(t -> originalActionsDst.get(t)) //
.collect(Collectors.toList()));
rootActions.removeAll(Collections.singleton(null));
return rootActions;
} | [
"public",
"List",
"<",
"Action",
">",
"getRootActions",
"(",
")",
"{",
"final",
"List",
"<",
"Action",
">",
"rootActions",
"=",
"srcUpdTrees",
".",
"stream",
"(",
")",
".",
"map",
"(",
"t",
"->",
"originalActionsSrc",
".",
"get",
"(",
"t",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"rootActions",
".",
"addAll",
"(",
"srcDelTrees",
".",
"stream",
"(",
")",
"//",
".",
"filter",
"(",
"t",
"->",
"!",
"srcDelTrees",
".",
"contains",
"(",
"t",
".",
"getParent",
"(",
")",
")",
"&&",
"!",
"srcUpdTrees",
".",
"contains",
"(",
"t",
".",
"getParent",
"(",
")",
")",
")",
"//",
".",
"map",
"(",
"t",
"->",
"originalActionsSrc",
".",
"get",
"(",
"t",
")",
")",
"//",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"rootActions",
".",
"addAll",
"(",
"dstAddTrees",
".",
"stream",
"(",
")",
"//",
".",
"filter",
"(",
"t",
"->",
"!",
"dstAddTrees",
".",
"contains",
"(",
"t",
".",
"getParent",
"(",
")",
")",
"&&",
"!",
"dstUpdTrees",
".",
"contains",
"(",
"t",
".",
"getParent",
"(",
")",
")",
")",
"//",
".",
"map",
"(",
"t",
"->",
"originalActionsDst",
".",
"get",
"(",
"t",
")",
")",
"//",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"rootActions",
".",
"addAll",
"(",
"dstMvTrees",
".",
"stream",
"(",
")",
"//",
".",
"filter",
"(",
"t",
"->",
"!",
"dstMvTrees",
".",
"contains",
"(",
"t",
".",
"getParent",
"(",
")",
")",
")",
"//",
".",
"map",
"(",
"t",
"->",
"originalActionsDst",
".",
"get",
"(",
"t",
")",
")",
"//",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"rootActions",
".",
"removeAll",
"(",
"Collections",
".",
"singleton",
"(",
"null",
")",
")",
";",
"return",
"rootActions",
";",
"}"
] | This method retrieves ONLY the ROOT actions | [
"This",
"method",
"retrieves",
"ONLY",
"the",
"ROOT",
"actions"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/diff/ActionClassifier.java#L72-L93 |
164,323 | SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/AstComparator.java | AstComparator.compare | public Diff compare(File f1, File f2) throws Exception {
return this.compare(getCtType(f1), getCtType(f2));
} | java | public Diff compare(File f1, File f2) throws Exception {
return this.compare(getCtType(f1), getCtType(f2));
} | [
"public",
"Diff",
"compare",
"(",
"File",
"f1",
",",
"File",
"f2",
")",
"throws",
"Exception",
"{",
"return",
"this",
".",
"compare",
"(",
"getCtType",
"(",
"f1",
")",
",",
"getCtType",
"(",
"f2",
")",
")",
";",
"}"
] | compares two java files | [
"compares",
"two",
"java",
"files"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/AstComparator.java#L76-L78 |
164,324 | SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/AstComparator.java | AstComparator.compare | public Diff compare(String left, String right) {
return compare(getCtType(left), getCtType(right));
} | java | public Diff compare(String left, String right) {
return compare(getCtType(left), getCtType(right));
} | [
"public",
"Diff",
"compare",
"(",
"String",
"left",
",",
"String",
"right",
")",
"{",
"return",
"compare",
"(",
"getCtType",
"(",
"left",
")",
",",
"getCtType",
"(",
"right",
")",
")",
";",
"}"
] | compares two snippet | [
"compares",
"two",
"snippet"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/AstComparator.java#L83-L85 |
164,325 | SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/AstComparator.java | AstComparator.compare | public Diff compare(CtElement left, CtElement right) {
final SpoonGumTreeBuilder scanner = new SpoonGumTreeBuilder();
return new DiffImpl(scanner.getTreeContext(), scanner.getTree(left), scanner.getTree(right));
} | java | public Diff compare(CtElement left, CtElement right) {
final SpoonGumTreeBuilder scanner = new SpoonGumTreeBuilder();
return new DiffImpl(scanner.getTreeContext(), scanner.getTree(left), scanner.getTree(right));
} | [
"public",
"Diff",
"compare",
"(",
"CtElement",
"left",
",",
"CtElement",
"right",
")",
"{",
"final",
"SpoonGumTreeBuilder",
"scanner",
"=",
"new",
"SpoonGumTreeBuilder",
"(",
")",
";",
"return",
"new",
"DiffImpl",
"(",
"scanner",
".",
"getTreeContext",
"(",
")",
",",
"scanner",
".",
"getTree",
"(",
"left",
")",
",",
"scanner",
".",
"getTree",
"(",
"right",
")",
")",
";",
"}"
] | compares two AST nodes | [
"compares",
"two",
"AST",
"nodes"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/AstComparator.java#L90-L93 |
164,326 | mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java | ArrayAdapterCompat.set | public void set(int index, T object) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.set(index, object);
} else {
mObjects.set(index, object);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | java | public void set(int index, T object) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.set(index, object);
} else {
mObjects.set(index, object);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | [
"public",
"void",
"set",
"(",
"int",
"index",
",",
"T",
"object",
")",
"{",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"mOriginalValues",
"!=",
"null",
")",
"{",
"mOriginalValues",
".",
"set",
"(",
"index",
",",
"object",
")",
";",
"}",
"else",
"{",
"mObjects",
".",
"set",
"(",
"index",
",",
"object",
")",
";",
"}",
"}",
"if",
"(",
"mNotifyOnChange",
")",
"notifyDataSetChanged",
"(",
")",
";",
"}"
] | set the specified object at index
@param object The object to add at the end of the array. | [
"set",
"the",
"specified",
"object",
"at",
"index"
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java#L152-L161 |
164,327 | mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java | ArrayAdapterCompat.addAll | public void addAll(int index, T... items) {
List<T> collection = Arrays.asList(items);
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.addAll(index, collection);
} else {
mObjects.addAll(index, collection);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | java | public void addAll(int index, T... items) {
List<T> collection = Arrays.asList(items);
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.addAll(index, collection);
} else {
mObjects.addAll(index, collection);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | [
"public",
"void",
"addAll",
"(",
"int",
"index",
",",
"T",
"...",
"items",
")",
"{",
"List",
"<",
"T",
">",
"collection",
"=",
"Arrays",
".",
"asList",
"(",
"items",
")",
";",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"mOriginalValues",
"!=",
"null",
")",
"{",
"mOriginalValues",
".",
"addAll",
"(",
"index",
",",
"collection",
")",
";",
"}",
"else",
"{",
"mObjects",
".",
"addAll",
"(",
"index",
",",
"collection",
")",
";",
"}",
"}",
"if",
"(",
"mNotifyOnChange",
")",
"notifyDataSetChanged",
"(",
")",
";",
"}"
] | Inserts the specified objects at the specified index in the array.
@param items The objects to insert into the array.
@param index The index at which the object must be inserted. | [
"Inserts",
"the",
"specified",
"objects",
"at",
"the",
"specified",
"index",
"in",
"the",
"array",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java#L228-L238 |
164,328 | mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java | ArrayAdapterCompat.removeAt | public void removeAt(int index) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.remove(index);
} else {
mObjects.remove(index);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | java | public void removeAt(int index) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.remove(index);
} else {
mObjects.remove(index);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | [
"public",
"void",
"removeAt",
"(",
"int",
"index",
")",
"{",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"mOriginalValues",
"!=",
"null",
")",
"{",
"mOriginalValues",
".",
"remove",
"(",
"index",
")",
";",
"}",
"else",
"{",
"mObjects",
".",
"remove",
"(",
"index",
")",
";",
"}",
"}",
"if",
"(",
"mNotifyOnChange",
")",
"notifyDataSetChanged",
"(",
")",
";",
"}"
] | Removes the specified object in index from the array.
@param index The index to remove. | [
"Removes",
"the",
"specified",
"object",
"in",
"index",
"from",
"the",
"array",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java#L316-L325 |
164,329 | mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java | ArrayAdapterCompat.removeAll | public boolean removeAll(Collection<?> collection) {
boolean result = false;
synchronized (mLock) {
Iterator<?> it;
if (mOriginalValues != null) {
it = mOriginalValues.iterator();
} else {
it = mObjects.iterator();
}
while (it.hasNext()) {
if (collection.contains(it.next())) {
it.remove();
result = true;
}
}
}
if (mNotifyOnChange) notifyDataSetChanged();
return result;
} | java | public boolean removeAll(Collection<?> collection) {
boolean result = false;
synchronized (mLock) {
Iterator<?> it;
if (mOriginalValues != null) {
it = mOriginalValues.iterator();
} else {
it = mObjects.iterator();
}
while (it.hasNext()) {
if (collection.contains(it.next())) {
it.remove();
result = true;
}
}
}
if (mNotifyOnChange) notifyDataSetChanged();
return result;
} | [
"public",
"boolean",
"removeAll",
"(",
"Collection",
"<",
"?",
">",
"collection",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"synchronized",
"(",
"mLock",
")",
"{",
"Iterator",
"<",
"?",
">",
"it",
";",
"if",
"(",
"mOriginalValues",
"!=",
"null",
")",
"{",
"it",
"=",
"mOriginalValues",
".",
"iterator",
"(",
")",
";",
"}",
"else",
"{",
"it",
"=",
"mObjects",
".",
"iterator",
"(",
")",
";",
"}",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"collection",
".",
"contains",
"(",
"it",
".",
"next",
"(",
")",
")",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"result",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"mNotifyOnChange",
")",
"notifyDataSetChanged",
"(",
")",
";",
"return",
"result",
";",
"}"
] | Removes the specified objects.
@param collection The collection to remove. | [
"Removes",
"the",
"specified",
"objects",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java#L333-L352 |
164,330 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java | AdvancedRecyclerArrayAdapter.addAll | public void addAll(@NonNull final Collection<T> collection) {
final int length = collection.size();
if (length == 0) {
return;
}
synchronized (mLock) {
final int position = getItemCount();
mObjects.addAll(collection);
notifyItemRangeInserted(position, length);
}
} | java | public void addAll(@NonNull final Collection<T> collection) {
final int length = collection.size();
if (length == 0) {
return;
}
synchronized (mLock) {
final int position = getItemCount();
mObjects.addAll(collection);
notifyItemRangeInserted(position, length);
}
} | [
"public",
"void",
"addAll",
"(",
"@",
"NonNull",
"final",
"Collection",
"<",
"T",
">",
"collection",
")",
"{",
"final",
"int",
"length",
"=",
"collection",
".",
"size",
"(",
")",
";",
"if",
"(",
"length",
"==",
"0",
")",
"{",
"return",
";",
"}",
"synchronized",
"(",
"mLock",
")",
"{",
"final",
"int",
"position",
"=",
"getItemCount",
"(",
")",
";",
"mObjects",
".",
"addAll",
"(",
"collection",
")",
";",
"notifyItemRangeInserted",
"(",
"position",
",",
"length",
")",
";",
"}",
"}"
] | Adds the specified list of objects at the end of the array.
@param collection The objects to add at the end of the array. | [
"Adds",
"the",
"specified",
"list",
"of",
"objects",
"at",
"the",
"end",
"of",
"the",
"array",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java#L81-L91 |
164,331 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java | AdvancedRecyclerArrayAdapter.getItem | @Nullable
public T getItem(final int position) {
if (position < 0 || position >= mObjects.size()) {
return null;
}
return mObjects.get(position);
} | java | @Nullable
public T getItem(final int position) {
if (position < 0 || position >= mObjects.size()) {
return null;
}
return mObjects.get(position);
} | [
"@",
"Nullable",
"public",
"T",
"getItem",
"(",
"final",
"int",
"position",
")",
"{",
"if",
"(",
"position",
"<",
"0",
"||",
"position",
">=",
"mObjects",
".",
"size",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"mObjects",
".",
"get",
"(",
"position",
")",
";",
"}"
] | Returns the item at the specified position.
@param position index of the item to return
@return the item at the specified position or {@code null} when not found | [
"Returns",
"the",
"item",
"at",
"the",
"specified",
"position",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java#L154-L160 |
164,332 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java | AdvancedRecyclerArrayAdapter.replaceItem | public void replaceItem(@NonNull final T oldObject, @NonNull final T newObject) {
synchronized (mLock) {
final int position = getPosition(oldObject);
if (position == -1) {
// not found, don't replace
return;
}
mObjects.remove(position);
mObjects.add(position, newObject);
if (isItemTheSame(oldObject, newObject)) {
if (isContentTheSame(oldObject, newObject)) {
// visible content hasn't changed, don't notify
return;
}
// item with same stable id has changed
notifyItemChanged(position, newObject);
} else {
// item replaced with another one with a different id
notifyItemRemoved(position);
notifyItemInserted(position);
}
}
} | java | public void replaceItem(@NonNull final T oldObject, @NonNull final T newObject) {
synchronized (mLock) {
final int position = getPosition(oldObject);
if (position == -1) {
// not found, don't replace
return;
}
mObjects.remove(position);
mObjects.add(position, newObject);
if (isItemTheSame(oldObject, newObject)) {
if (isContentTheSame(oldObject, newObject)) {
// visible content hasn't changed, don't notify
return;
}
// item with same stable id has changed
notifyItemChanged(position, newObject);
} else {
// item replaced with another one with a different id
notifyItemRemoved(position);
notifyItemInserted(position);
}
}
} | [
"public",
"void",
"replaceItem",
"(",
"@",
"NonNull",
"final",
"T",
"oldObject",
",",
"@",
"NonNull",
"final",
"T",
"newObject",
")",
"{",
"synchronized",
"(",
"mLock",
")",
"{",
"final",
"int",
"position",
"=",
"getPosition",
"(",
"oldObject",
")",
";",
"if",
"(",
"position",
"==",
"-",
"1",
")",
"{",
"// not found, don't replace",
"return",
";",
"}",
"mObjects",
".",
"remove",
"(",
"position",
")",
";",
"mObjects",
".",
"add",
"(",
"position",
",",
"newObject",
")",
";",
"if",
"(",
"isItemTheSame",
"(",
"oldObject",
",",
"newObject",
")",
")",
"{",
"if",
"(",
"isContentTheSame",
"(",
"oldObject",
",",
"newObject",
")",
")",
"{",
"// visible content hasn't changed, don't notify",
"return",
";",
"}",
"// item with same stable id has changed",
"notifyItemChanged",
"(",
"position",
",",
"newObject",
")",
";",
"}",
"else",
"{",
"// item replaced with another one with a different id",
"notifyItemRemoved",
"(",
"position",
")",
";",
"notifyItemInserted",
"(",
"position",
")",
";",
"}",
"}",
"}"
] | replaces the old with the new item. The new item will not be added when the old one is not
found.
@param oldObject will be removed
@param newObject is added only when hte old item is removed | [
"replaces",
"the",
"old",
"with",
"the",
"new",
"item",
".",
"The",
"new",
"item",
"will",
"not",
"be",
"added",
"when",
"the",
"old",
"one",
"is",
"not",
"found",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java#L283-L308 |
164,333 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/ViewUtils.java | ViewUtils.hideSystemUI | @TargetApi(VERSION_CODES.KITKAT)
public static void hideSystemUI(Activity activity) {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hideSelf and show.
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hideSelf nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hideSelf status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE
);
} | java | @TargetApi(VERSION_CODES.KITKAT)
public static void hideSystemUI(Activity activity) {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hideSelf and show.
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hideSelf nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hideSelf status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE
);
} | [
"@",
"TargetApi",
"(",
"VERSION_CODES",
".",
"KITKAT",
")",
"public",
"static",
"void",
"hideSystemUI",
"(",
"Activity",
"activity",
")",
"{",
"// Set the IMMERSIVE flag.",
"// Set the content to appear under the system bars so that the content",
"// doesn't resize when the system bars hideSelf and show.",
"View",
"decorView",
"=",
"activity",
".",
"getWindow",
"(",
")",
".",
"getDecorView",
"(",
")",
";",
"decorView",
".",
"setSystemUiVisibility",
"(",
"View",
".",
"SYSTEM_UI_FLAG_LAYOUT_STABLE",
"|",
"View",
".",
"SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION",
"|",
"View",
".",
"SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN",
"|",
"View",
".",
"SYSTEM_UI_FLAG_HIDE_NAVIGATION",
"// hideSelf nav bar",
"|",
"View",
".",
"SYSTEM_UI_FLAG_FULLSCREEN",
"// hideSelf status bar",
"|",
"View",
".",
"SYSTEM_UI_FLAG_IMMERSIVE",
")",
";",
"}"
] | This intro hides the system bars. | [
"This",
"intro",
"hides",
"the",
"system",
"bars",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/ViewUtils.java#L28-L42 |
164,334 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/ViewUtils.java | ViewUtils.showSystemUI | @TargetApi(VERSION_CODES.KITKAT)
public static void showSystemUI(Activity activity) {
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);
} | java | @TargetApi(VERSION_CODES.KITKAT)
public static void showSystemUI(Activity activity) {
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);
} | [
"@",
"TargetApi",
"(",
"VERSION_CODES",
".",
"KITKAT",
")",
"public",
"static",
"void",
"showSystemUI",
"(",
"Activity",
"activity",
")",
"{",
"View",
"decorView",
"=",
"activity",
".",
"getWindow",
"(",
")",
".",
"getDecorView",
"(",
")",
";",
"decorView",
".",
"setSystemUiVisibility",
"(",
"View",
".",
"SYSTEM_UI_FLAG_LAYOUT_STABLE",
"|",
"View",
".",
"SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION",
"|",
"View",
".",
"SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN",
")",
";",
"}"
] | except for the ones that make the content appear under the system bars. | [
"except",
"for",
"the",
"ones",
"that",
"make",
"the",
"content",
"appear",
"under",
"the",
"system",
"bars",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/ViewUtils.java#L46-L54 |
164,335 | mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/internal/AdapterWrapper.java | AdapterWrapper.getView | @Override
public View getView(int position, View convertView,
ViewGroup parent) {
return (wrapped.getView(position, convertView, parent));
} | java | @Override
public View getView(int position, View convertView,
ViewGroup parent) {
return (wrapped.getView(position, convertView, parent));
} | [
"@",
"Override",
"public",
"View",
"getView",
"(",
"int",
"position",
",",
"View",
"convertView",
",",
"ViewGroup",
"parent",
")",
"{",
"return",
"(",
"wrapped",
".",
"getView",
"(",
"position",
",",
"convertView",
",",
"parent",
")",
")",
";",
"}"
] | Get a View that displays the data at the specified
position in the data set.
@param position Position of the item whose data we want
@param convertView View to recycle, if not null
@param parent ViewGroup containing the returned View | [
"Get",
"a",
"View",
"that",
"displays",
"the",
"data",
"at",
"the",
"specified",
"position",
"in",
"the",
"data",
"set",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/internal/AdapterWrapper.java#L141-L145 |
164,336 | mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/dialog/v4/ProgressDialogFragment.java | ProgressDialogFragment.onDismiss | @Override
public void onDismiss(DialogInterface dialog) {
if (mOldDialog != null && mOldDialog == dialog) {
// This is the callback from the old progress dialog that was already dismissed before
// the device orientation change, so just ignore it.
return;
}
super.onDismiss(dialog);
} | java | @Override
public void onDismiss(DialogInterface dialog) {
if (mOldDialog != null && mOldDialog == dialog) {
// This is the callback from the old progress dialog that was already dismissed before
// the device orientation change, so just ignore it.
return;
}
super.onDismiss(dialog);
} | [
"@",
"Override",
"public",
"void",
"onDismiss",
"(",
"DialogInterface",
"dialog",
")",
"{",
"if",
"(",
"mOldDialog",
"!=",
"null",
"&&",
"mOldDialog",
"==",
"dialog",
")",
"{",
"// This is the callback from the old progress dialog that was already dismissed before",
"// the device orientation change, so just ignore it.",
"return",
";",
"}",
"super",
".",
"onDismiss",
"(",
"dialog",
")",
";",
"}"
] | There is a race condition that is not handled properly by the DialogFragment class.
If we don't check that this onDismiss callback isn't for the old progress dialog from before
the device orientation change, then this will cause the newly created dialog after the
orientation change to be dismissed immediately. | [
"There",
"is",
"a",
"race",
"condition",
"that",
"is",
"not",
"handled",
"properly",
"by",
"the",
"DialogFragment",
"class",
".",
"If",
"we",
"don",
"t",
"check",
"that",
"this",
"onDismiss",
"callback",
"isn",
"t",
"for",
"the",
"old",
"progress",
"dialog",
"from",
"before",
"the",
"device",
"orientation",
"change",
"then",
"this",
"will",
"cause",
"the",
"newly",
"created",
"dialog",
"after",
"the",
"orientation",
"change",
"to",
"be",
"dismissed",
"immediately",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/dialog/v4/ProgressDialogFragment.java#L123-L131 |
164,337 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/ReflectionUtils.java | ReflectionUtils.isToStringMethod | public static boolean isToStringMethod(Method method) {
return (method != null && method.getName().equals("readString") && method.getParameterTypes().length == 0);
} | java | public static boolean isToStringMethod(Method method) {
return (method != null && method.getName().equals("readString") && method.getParameterTypes().length == 0);
} | [
"public",
"static",
"boolean",
"isToStringMethod",
"(",
"Method",
"method",
")",
"{",
"return",
"(",
"method",
"!=",
"null",
"&&",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"readString\"",
")",
"&&",
"method",
".",
"getParameterTypes",
"(",
")",
".",
"length",
"==",
"0",
")",
";",
"}"
] | Determine whether the given method is a "readString" method.
@see Object#toString() | [
"Determine",
"whether",
"the",
"given",
"method",
"is",
"a",
"readString",
"method",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/ReflectionUtils.java#L411-L413 |
164,338 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/ReflectionUtils.java | ReflectionUtils.getUniqueDeclaredMethods | public static Method[] getUniqueDeclaredMethods(Class<?> leafClass) throws IllegalArgumentException {
final List<Method> methods = new ArrayList<Method>(32);
doWithMethods(leafClass, new MethodCallback() {
@Override
public void doWith(Method method) {
boolean knownSignature = false;
Method methodBeingOverriddenWithCovariantReturnType = null;
for (Method existingMethod : methods) {
if (method.getName().equals(existingMethod.getName()) &&
Arrays.equals(method.getParameterTypes(), existingMethod.getParameterTypes())) {
// Is this a covariant return type situation?
if (existingMethod.getReturnType() != method.getReturnType() &&
existingMethod.getReturnType().isAssignableFrom(method.getReturnType())) {
methodBeingOverriddenWithCovariantReturnType = existingMethod;
} else {
knownSignature = true;
}
break;
}
}
if (methodBeingOverriddenWithCovariantReturnType != null) {
methods.remove(methodBeingOverriddenWithCovariantReturnType);
}
if (!knownSignature) {
methods.add(method);
}
}
});
return methods.toArray(new Method[methods.size()]);
} | java | public static Method[] getUniqueDeclaredMethods(Class<?> leafClass) throws IllegalArgumentException {
final List<Method> methods = new ArrayList<Method>(32);
doWithMethods(leafClass, new MethodCallback() {
@Override
public void doWith(Method method) {
boolean knownSignature = false;
Method methodBeingOverriddenWithCovariantReturnType = null;
for (Method existingMethod : methods) {
if (method.getName().equals(existingMethod.getName()) &&
Arrays.equals(method.getParameterTypes(), existingMethod.getParameterTypes())) {
// Is this a covariant return type situation?
if (existingMethod.getReturnType() != method.getReturnType() &&
existingMethod.getReturnType().isAssignableFrom(method.getReturnType())) {
methodBeingOverriddenWithCovariantReturnType = existingMethod;
} else {
knownSignature = true;
}
break;
}
}
if (methodBeingOverriddenWithCovariantReturnType != null) {
methods.remove(methodBeingOverriddenWithCovariantReturnType);
}
if (!knownSignature) {
methods.add(method);
}
}
});
return methods.toArray(new Method[methods.size()]);
} | [
"public",
"static",
"Method",
"[",
"]",
"getUniqueDeclaredMethods",
"(",
"Class",
"<",
"?",
">",
"leafClass",
")",
"throws",
"IllegalArgumentException",
"{",
"final",
"List",
"<",
"Method",
">",
"methods",
"=",
"new",
"ArrayList",
"<",
"Method",
">",
"(",
"32",
")",
";",
"doWithMethods",
"(",
"leafClass",
",",
"new",
"MethodCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"doWith",
"(",
"Method",
"method",
")",
"{",
"boolean",
"knownSignature",
"=",
"false",
";",
"Method",
"methodBeingOverriddenWithCovariantReturnType",
"=",
"null",
";",
"for",
"(",
"Method",
"existingMethod",
":",
"methods",
")",
"{",
"if",
"(",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"existingMethod",
".",
"getName",
"(",
")",
")",
"&&",
"Arrays",
".",
"equals",
"(",
"method",
".",
"getParameterTypes",
"(",
")",
",",
"existingMethod",
".",
"getParameterTypes",
"(",
")",
")",
")",
"{",
"// Is this a covariant return type situation?",
"if",
"(",
"existingMethod",
".",
"getReturnType",
"(",
")",
"!=",
"method",
".",
"getReturnType",
"(",
")",
"&&",
"existingMethod",
".",
"getReturnType",
"(",
")",
".",
"isAssignableFrom",
"(",
"method",
".",
"getReturnType",
"(",
")",
")",
")",
"{",
"methodBeingOverriddenWithCovariantReturnType",
"=",
"existingMethod",
";",
"}",
"else",
"{",
"knownSignature",
"=",
"true",
";",
"}",
"break",
";",
"}",
"}",
"if",
"(",
"methodBeingOverriddenWithCovariantReturnType",
"!=",
"null",
")",
"{",
"methods",
".",
"remove",
"(",
"methodBeingOverriddenWithCovariantReturnType",
")",
";",
"}",
"if",
"(",
"!",
"knownSignature",
")",
"{",
"methods",
".",
"add",
"(",
"method",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"methods",
".",
"toArray",
"(",
"new",
"Method",
"[",
"methods",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] | Get the unique set of declared methods on the leaf class and all superclasses. Leaf
class methods are included first and while traversing the superclass hierarchy any methods found
with signatures matching a method already included are filtered out. | [
"Get",
"the",
"unique",
"set",
"of",
"declared",
"methods",
"on",
"the",
"leaf",
"class",
"and",
"all",
"superclasses",
".",
"Leaf",
"class",
"methods",
"are",
"included",
"first",
"and",
"while",
"traversing",
"the",
"superclass",
"hierarchy",
"any",
"methods",
"found",
"with",
"signatures",
"matching",
"a",
"method",
"already",
"included",
"are",
"filtered",
"out",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/ReflectionUtils.java#L547-L576 |
164,339 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java | WeakFastHashMap.put | @Override
public V put(K key, V value) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
V result = temp.put(key, value);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.put(key, value));
}
}
} | java | @Override
public V put(K key, V value) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
V result = temp.put(key, value);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.put(key, value));
}
}
} | [
"@",
"Override",
"public",
"V",
"put",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"if",
"(",
"fast",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"Map",
"<",
"K",
",",
"V",
">",
"temp",
"=",
"cloneMap",
"(",
"map",
")",
";",
"V",
"result",
"=",
"temp",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"map",
"=",
"temp",
";",
"return",
"(",
"result",
")",
";",
"}",
"}",
"else",
"{",
"synchronized",
"(",
"map",
")",
"{",
"return",
"(",
"map",
".",
"put",
"(",
"key",
",",
"value",
")",
")",
";",
"}",
"}",
"}"
] | Associate the specified value with the specified key in this map.
If the map previously contained a mapping for this key, the old
value is replaced and returned.
@param key the key with which the value is to be associated
@param value the value to be associated with this key
@return the value previously mapped to the key, or null | [
"Associate",
"the",
"specified",
"value",
"with",
"the",
"specified",
"key",
"in",
"this",
"map",
".",
"If",
"the",
"map",
"previously",
"contained",
"a",
"mapping",
"for",
"this",
"key",
"the",
"old",
"value",
"is",
"replaced",
"and",
"returned",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java#L357-L371 |
164,340 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java | WeakFastHashMap.putAll | @Override
public void putAll(Map<? extends K, ? extends V> in) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
temp.putAll(in);
map = temp;
}
} else {
synchronized (map) {
map.putAll(in);
}
}
} | java | @Override
public void putAll(Map<? extends K, ? extends V> in) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
temp.putAll(in);
map = temp;
}
} else {
synchronized (map) {
map.putAll(in);
}
}
} | [
"@",
"Override",
"public",
"void",
"putAll",
"(",
"Map",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"in",
")",
"{",
"if",
"(",
"fast",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"Map",
"<",
"K",
",",
"V",
">",
"temp",
"=",
"cloneMap",
"(",
"map",
")",
";",
"temp",
".",
"putAll",
"(",
"in",
")",
";",
"map",
"=",
"temp",
";",
"}",
"}",
"else",
"{",
"synchronized",
"(",
"map",
")",
"{",
"map",
".",
"putAll",
"(",
"in",
")",
";",
"}",
"}",
"}"
] | Copy all of the mappings from the specified map to this one, replacing
any mappings with the same keys.
@param in the map whose mappings are to be copied | [
"Copy",
"all",
"of",
"the",
"mappings",
"from",
"the",
"specified",
"map",
"to",
"this",
"one",
"replacing",
"any",
"mappings",
"with",
"the",
"same",
"keys",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java#L382-L395 |
164,341 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java | WeakFastHashMap.remove | @Override
public V remove(Object key) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
V result = temp.remove(key);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.remove(key));
}
}
} | java | @Override
public V remove(Object key) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
V result = temp.remove(key);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.remove(key));
}
}
} | [
"@",
"Override",
"public",
"V",
"remove",
"(",
"Object",
"key",
")",
"{",
"if",
"(",
"fast",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"Map",
"<",
"K",
",",
"V",
">",
"temp",
"=",
"cloneMap",
"(",
"map",
")",
";",
"V",
"result",
"=",
"temp",
".",
"remove",
"(",
"key",
")",
";",
"map",
"=",
"temp",
";",
"return",
"(",
"result",
")",
";",
"}",
"}",
"else",
"{",
"synchronized",
"(",
"map",
")",
"{",
"return",
"(",
"map",
".",
"remove",
"(",
"key",
")",
")",
";",
"}",
"}",
"}"
] | Remove any mapping for this key, and return any previously
mapped value.
@param key the key whose mapping is to be removed
@return the value removed, or null | [
"Remove",
"any",
"mapping",
"for",
"this",
"key",
"and",
"return",
"any",
"previously",
"mapped",
"value",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java#L404-L418 |
164,342 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java | IOUtils.isFileExist | public static boolean isFileExist(String filePath) {
if (StringUtils.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
return (file.exists() && file.isFile());
} | java | public static boolean isFileExist(String filePath) {
if (StringUtils.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
return (file.exists() && file.isFile());
} | [
"public",
"static",
"boolean",
"isFileExist",
"(",
"String",
"filePath",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"filePath",
")",
")",
"{",
"return",
"false",
";",
"}",
"File",
"file",
"=",
"new",
"File",
"(",
"filePath",
")",
";",
"return",
"(",
"file",
".",
"exists",
"(",
")",
"&&",
"file",
".",
"isFile",
"(",
")",
")",
";",
"}"
] | Indicates if this file represents a file on the underlying file system.
@param filePath
@return | [
"Indicates",
"if",
"this",
"file",
"represents",
"a",
"file",
"on",
"the",
"underlying",
"file",
"system",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java#L1436-L1443 |
164,343 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java | IOUtils.isFolderExist | public static boolean isFolderExist(String directoryPath) {
if (StringUtils.isEmpty(directoryPath)) {
return false;
}
File dire = new File(directoryPath);
return (dire.exists() && dire.isDirectory());
} | java | public static boolean isFolderExist(String directoryPath) {
if (StringUtils.isEmpty(directoryPath)) {
return false;
}
File dire = new File(directoryPath);
return (dire.exists() && dire.isDirectory());
} | [
"public",
"static",
"boolean",
"isFolderExist",
"(",
"String",
"directoryPath",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"directoryPath",
")",
")",
"{",
"return",
"false",
";",
"}",
"File",
"dire",
"=",
"new",
"File",
"(",
"directoryPath",
")",
";",
"return",
"(",
"dire",
".",
"exists",
"(",
")",
"&&",
"dire",
".",
"isDirectory",
"(",
")",
")",
";",
"}"
] | Indicates if this file represents a directory on the underlying file system.
@param directoryPath
@return | [
"Indicates",
"if",
"this",
"file",
"represents",
"a",
"directory",
"on",
"the",
"underlying",
"file",
"system",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java#L1451-L1458 |
164,344 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/AndroidUtils.java | AndroidUtils.addToMediaStore | public static void addToMediaStore(Context context, File file) {
String[] path = new String[]{file.getPath()};
MediaScannerConnection.scanFile(context, path, null, null);
} | java | public static void addToMediaStore(Context context, File file) {
String[] path = new String[]{file.getPath()};
MediaScannerConnection.scanFile(context, path, null, null);
} | [
"public",
"static",
"void",
"addToMediaStore",
"(",
"Context",
"context",
",",
"File",
"file",
")",
"{",
"String",
"[",
"]",
"path",
"=",
"new",
"String",
"[",
"]",
"{",
"file",
".",
"getPath",
"(",
")",
"}",
";",
"MediaScannerConnection",
".",
"scanFile",
"(",
"context",
",",
"path",
",",
"null",
",",
"null",
")",
";",
"}"
] | another media scan way | [
"another",
"media",
"scan",
"way"
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/AndroidUtils.java#L331-L334 |
164,345 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/io/CountingInputStream.java | CountingInputStream.skip | @Override
public synchronized long skip(final long length) throws IOException {
final long skip = super.skip(length);
this.count += skip;
return skip;
} | java | @Override
public synchronized long skip(final long length) throws IOException {
final long skip = super.skip(length);
this.count += skip;
return skip;
} | [
"@",
"Override",
"public",
"synchronized",
"long",
"skip",
"(",
"final",
"long",
"length",
")",
"throws",
"IOException",
"{",
"final",
"long",
"skip",
"=",
"super",
".",
"skip",
"(",
"length",
")",
";",
"this",
".",
"count",
"+=",
"skip",
";",
"return",
"skip",
";",
"}"
] | Skips the stream over the specified number of bytes, adding the skipped
amount to the count.
@param length the number of bytes to skip
@return the actual number of bytes skipped
@throws java.io.IOException if an I/O error occurs
@see java.io.InputStream#skip(long) | [
"Skips",
"the",
"stream",
"over",
"the",
"specified",
"number",
"of",
"bytes",
"adding",
"the",
"skipped",
"amount",
"to",
"the",
"count",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/io/CountingInputStream.java#L58-L63 |
164,346 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemRangeInserted | public final void notifyHeaderItemRangeInserted(int positionStart, int itemCount) {
int newHeaderItemCount = getHeaderItemCount();
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newHeaderItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (newHeaderItemCount - 1) + "].");
}
notifyItemRangeInserted(positionStart, itemCount);
} | java | public final void notifyHeaderItemRangeInserted(int positionStart, int itemCount) {
int newHeaderItemCount = getHeaderItemCount();
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newHeaderItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (newHeaderItemCount - 1) + "].");
}
notifyItemRangeInserted(positionStart, itemCount);
} | [
"public",
"final",
"void",
"notifyHeaderItemRangeInserted",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"int",
"newHeaderItemCount",
"=",
"getHeaderItemCount",
"(",
")",
";",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"newHeaderItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for header items [0 - \"",
"+",
"(",
"newHeaderItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeInserted",
"(",
"positionStart",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple header items are inserted.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"header",
"items",
"are",
"inserted",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L132-L138 |
164,347 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemChanged | public final void notifyHeaderItemChanged(int position) {
if (position < 0 || position >= headerItemCount) {
throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemChanged(position);
} | java | public final void notifyHeaderItemChanged(int position) {
if (position < 0 || position >= headerItemCount) {
throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemChanged(position);
} | [
"public",
"final",
"void",
"notifyHeaderItemChanged",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"position",
"<",
"0",
"||",
"position",
">=",
"headerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given position \"",
"+",
"position",
"+",
"\" is not within the position bounds for header items [0 - \"",
"+",
"(",
"headerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemChanged",
"(",
"position",
")",
";",
"}"
] | Notifies that a header item is changed.
@param position the position. | [
"Notifies",
"that",
"a",
"header",
"item",
"is",
"changed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L145-L150 |
164,348 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemRangeChanged | public final void notifyHeaderItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount >= headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart, itemCount);
} | java | public final void notifyHeaderItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount >= headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart, itemCount);
} | [
"public",
"final",
"void",
"notifyHeaderItemRangeChanged",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">=",
"headerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for header items [0 - \"",
"+",
"(",
"headerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeChanged",
"(",
"positionStart",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple header items are changed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"header",
"items",
"are",
"changed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L158-L163 |
164,349 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemMoved | public void notifyHeaderItemMoved(int fromPosition, int toPosition) {
if (fromPosition < 0 || toPosition < 0 || fromPosition >= headerItemCount || toPosition >= headerItemCount) {
throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition + " or toPosition " + toPosition + " is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemMoved(fromPosition, toPosition);
} | java | public void notifyHeaderItemMoved(int fromPosition, int toPosition) {
if (fromPosition < 0 || toPosition < 0 || fromPosition >= headerItemCount || toPosition >= headerItemCount) {
throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition + " or toPosition " + toPosition + " is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemMoved(fromPosition, toPosition);
} | [
"public",
"void",
"notifyHeaderItemMoved",
"(",
"int",
"fromPosition",
",",
"int",
"toPosition",
")",
"{",
"if",
"(",
"fromPosition",
"<",
"0",
"||",
"toPosition",
"<",
"0",
"||",
"fromPosition",
">=",
"headerItemCount",
"||",
"toPosition",
">=",
"headerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given fromPosition \"",
"+",
"fromPosition",
"+",
"\" or toPosition \"",
"+",
"toPosition",
"+",
"\" is not within the position bounds for header items [0 - \"",
"+",
"(",
"headerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemMoved",
"(",
"fromPosition",
",",
"toPosition",
")",
";",
"}"
] | Notifies that an existing header item is moved to another position.
@param fromPosition the original position.
@param toPosition the new position. | [
"Notifies",
"that",
"an",
"existing",
"header",
"item",
"is",
"moved",
"to",
"another",
"position",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L172-L177 |
164,350 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemRangeRemoved | public void notifyHeaderItemRangeRemoved(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart, itemCount);
} | java | public void notifyHeaderItemRangeRemoved(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart, itemCount);
} | [
"public",
"void",
"notifyHeaderItemRangeRemoved",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"headerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for header items [0 - \"",
"+",
"(",
"headerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeRemoved",
"(",
"positionStart",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple header items are removed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"header",
"items",
"are",
"removed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L197-L202 |
164,351 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyContentItemInserted | public final void notifyContentItemInserted(int position) {
int newHeaderItemCount = getHeaderItemCount();
int newContentItemCount = getContentItemCount();
if (position < 0 || position >= newContentItemCount) {
throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for content items [0 - " + (newContentItemCount - 1) + "].");
}
notifyItemInserted(position + newHeaderItemCount);
} | java | public final void notifyContentItemInserted(int position) {
int newHeaderItemCount = getHeaderItemCount();
int newContentItemCount = getContentItemCount();
if (position < 0 || position >= newContentItemCount) {
throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for content items [0 - " + (newContentItemCount - 1) + "].");
}
notifyItemInserted(position + newHeaderItemCount);
} | [
"public",
"final",
"void",
"notifyContentItemInserted",
"(",
"int",
"position",
")",
"{",
"int",
"newHeaderItemCount",
"=",
"getHeaderItemCount",
"(",
")",
";",
"int",
"newContentItemCount",
"=",
"getContentItemCount",
"(",
")",
";",
"if",
"(",
"position",
"<",
"0",
"||",
"position",
">=",
"newContentItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given position \"",
"+",
"position",
"+",
"\" is not within the position bounds for content items [0 - \"",
"+",
"(",
"newContentItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemInserted",
"(",
"position",
"+",
"newHeaderItemCount",
")",
";",
"}"
] | Notifies that a content item is inserted.
@param position the position of the content item. | [
"Notifies",
"that",
"a",
"content",
"item",
"is",
"inserted",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L209-L216 |
164,352 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyContentItemRangeInserted | public final void notifyContentItemRangeInserted(int positionStart, int itemCount) {
int newHeaderItemCount = getHeaderItemCount();
int newContentItemCount = getContentItemCount();
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newContentItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for content items [0 - "
+ (newContentItemCount - 1) + "].");
}
notifyItemRangeInserted(positionStart + newHeaderItemCount, itemCount);
} | java | public final void notifyContentItemRangeInserted(int positionStart, int itemCount) {
int newHeaderItemCount = getHeaderItemCount();
int newContentItemCount = getContentItemCount();
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newContentItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for content items [0 - "
+ (newContentItemCount - 1) + "].");
}
notifyItemRangeInserted(positionStart + newHeaderItemCount, itemCount);
} | [
"public",
"final",
"void",
"notifyContentItemRangeInserted",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"int",
"newHeaderItemCount",
"=",
"getHeaderItemCount",
"(",
")",
";",
"int",
"newContentItemCount",
"=",
"getContentItemCount",
"(",
")",
";",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"newContentItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for content items [0 - \"",
"+",
"(",
"newContentItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeInserted",
"(",
"positionStart",
"+",
"newHeaderItemCount",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple content items are inserted.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"content",
"items",
"are",
"inserted",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L224-L233 |
164,353 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyContentItemChanged | public final void notifyContentItemChanged(int position) {
if (position < 0 || position >= contentItemCount) {
throw new IndexOutOfBoundsException("The given position " + position
+ " is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "].");
}
notifyItemChanged(position + headerItemCount);
} | java | public final void notifyContentItemChanged(int position) {
if (position < 0 || position >= contentItemCount) {
throw new IndexOutOfBoundsException("The given position " + position
+ " is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "].");
}
notifyItemChanged(position + headerItemCount);
} | [
"public",
"final",
"void",
"notifyContentItemChanged",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"position",
"<",
"0",
"||",
"position",
">=",
"contentItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given position \"",
"+",
"position",
"+",
"\" is not within the position bounds for content items [0 - \"",
"+",
"(",
"contentItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemChanged",
"(",
"position",
"+",
"headerItemCount",
")",
";",
"}"
] | Notifies that a content item is changed.
@param position the position. | [
"Notifies",
"that",
"a",
"content",
"item",
"is",
"changed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L240-L246 |
164,354 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyContentItemRangeChanged | public final void notifyContentItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > contentItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for content items [0 - "
+ (contentItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart + headerItemCount, itemCount);
} | java | public final void notifyContentItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > contentItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for content items [0 - "
+ (contentItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart + headerItemCount, itemCount);
} | [
"public",
"final",
"void",
"notifyContentItemRangeChanged",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"contentItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for content items [0 - \"",
"+",
"(",
"contentItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeChanged",
"(",
"positionStart",
"+",
"headerItemCount",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple content items are changed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"content",
"items",
"are",
"changed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L254-L261 |
164,355 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyContentItemMoved | public final void notifyContentItemMoved(int fromPosition, int toPosition) {
if (fromPosition < 0 || toPosition < 0 || fromPosition >= contentItemCount || toPosition >= contentItemCount) {
throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition + " or toPosition "
+ toPosition + " is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "].");
}
notifyItemMoved(fromPosition + headerItemCount, toPosition + headerItemCount);
} | java | public final void notifyContentItemMoved(int fromPosition, int toPosition) {
if (fromPosition < 0 || toPosition < 0 || fromPosition >= contentItemCount || toPosition >= contentItemCount) {
throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition + " or toPosition "
+ toPosition + " is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "].");
}
notifyItemMoved(fromPosition + headerItemCount, toPosition + headerItemCount);
} | [
"public",
"final",
"void",
"notifyContentItemMoved",
"(",
"int",
"fromPosition",
",",
"int",
"toPosition",
")",
"{",
"if",
"(",
"fromPosition",
"<",
"0",
"||",
"toPosition",
"<",
"0",
"||",
"fromPosition",
">=",
"contentItemCount",
"||",
"toPosition",
">=",
"contentItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given fromPosition \"",
"+",
"fromPosition",
"+",
"\" or toPosition \"",
"+",
"toPosition",
"+",
"\" is not within the position bounds for content items [0 - \"",
"+",
"(",
"contentItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemMoved",
"(",
"fromPosition",
"+",
"headerItemCount",
",",
"toPosition",
"+",
"headerItemCount",
")",
";",
"}"
] | Notifies that an existing content item is moved to another position.
@param fromPosition the original position.
@param toPosition the new position. | [
"Notifies",
"that",
"an",
"existing",
"content",
"item",
"is",
"moved",
"to",
"another",
"position",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L269-L275 |
164,356 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyContentItemRemoved | public final void notifyContentItemRemoved(int position) {
if (position < 0 || position >= contentItemCount) {
throw new IndexOutOfBoundsException("The given position " + position
+ " is not within the position bounds for content items [0 - "
+ (contentItemCount - 1) + "].");
}
notifyItemRemoved(position + headerItemCount);
} | java | public final void notifyContentItemRemoved(int position) {
if (position < 0 || position >= contentItemCount) {
throw new IndexOutOfBoundsException("The given position " + position
+ " is not within the position bounds for content items [0 - "
+ (contentItemCount - 1) + "].");
}
notifyItemRemoved(position + headerItemCount);
} | [
"public",
"final",
"void",
"notifyContentItemRemoved",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"position",
"<",
"0",
"||",
"position",
">=",
"contentItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given position \"",
"+",
"position",
"+",
"\" is not within the position bounds for content items [0 - \"",
"+",
"(",
"contentItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRemoved",
"(",
"position",
"+",
"headerItemCount",
")",
";",
"}"
] | Notifies that a content item is removed.
@param position the position. | [
"Notifies",
"that",
"a",
"content",
"item",
"is",
"removed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L282-L289 |
164,357 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyContentItemRangeRemoved | public final void notifyContentItemRangeRemoved(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > contentItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for content items [0 - "
+ (contentItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart + headerItemCount, itemCount);
} | java | public final void notifyContentItemRangeRemoved(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > contentItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for content items [0 - "
+ (contentItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart + headerItemCount, itemCount);
} | [
"public",
"final",
"void",
"notifyContentItemRangeRemoved",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"contentItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for content items [0 - \"",
"+",
"(",
"contentItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeRemoved",
"(",
"positionStart",
"+",
"headerItemCount",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple content items are removed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"content",
"items",
"are",
"removed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L297-L304 |
164,358 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyFooterItemInserted | public final void notifyFooterItemInserted(int position) {
int newHeaderItemCount = getHeaderItemCount();
int newContentItemCount = getContentItemCount();
int newFooterItemCount = getFooterItemCount();
// if (position < 0 || position >= newFooterItemCount) {
// throw new IndexOutOfBoundsException("The given position " + position
// + " is not within the position bounds for footer items [0 - "
// + (newFooterItemCount - 1) + "].");
// }
notifyItemInserted(position + newHeaderItemCount + newContentItemCount);
} | java | public final void notifyFooterItemInserted(int position) {
int newHeaderItemCount = getHeaderItemCount();
int newContentItemCount = getContentItemCount();
int newFooterItemCount = getFooterItemCount();
// if (position < 0 || position >= newFooterItemCount) {
// throw new IndexOutOfBoundsException("The given position " + position
// + " is not within the position bounds for footer items [0 - "
// + (newFooterItemCount - 1) + "].");
// }
notifyItemInserted(position + newHeaderItemCount + newContentItemCount);
} | [
"public",
"final",
"void",
"notifyFooterItemInserted",
"(",
"int",
"position",
")",
"{",
"int",
"newHeaderItemCount",
"=",
"getHeaderItemCount",
"(",
")",
";",
"int",
"newContentItemCount",
"=",
"getContentItemCount",
"(",
")",
";",
"int",
"newFooterItemCount",
"=",
"getFooterItemCount",
"(",
")",
";",
"// if (position < 0 || position >= newFooterItemCount) {",
"// throw new IndexOutOfBoundsException(\"The given position \" + position",
"// + \" is not within the position bounds for footer items [0 - \"",
"// + (newFooterItemCount - 1) + \"].\");",
"// }",
"notifyItemInserted",
"(",
"position",
"+",
"newHeaderItemCount",
"+",
"newContentItemCount",
")",
";",
"}"
] | Notifies that a footer item is inserted.
@param position the position of the content item. | [
"Notifies",
"that",
"a",
"footer",
"item",
"is",
"inserted",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L311-L321 |
164,359 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyFooterItemRangeInserted | public final void notifyFooterItemRangeInserted(int positionStart, int itemCount) {
int newHeaderItemCount = getHeaderItemCount();
int newContentItemCount = getContentItemCount();
int newFooterItemCount = getFooterItemCount();
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newFooterItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - "
+ (newFooterItemCount - 1) + "].");
}
notifyItemRangeInserted(positionStart + newHeaderItemCount + newContentItemCount, itemCount);
} | java | public final void notifyFooterItemRangeInserted(int positionStart, int itemCount) {
int newHeaderItemCount = getHeaderItemCount();
int newContentItemCount = getContentItemCount();
int newFooterItemCount = getFooterItemCount();
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newFooterItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - "
+ (newFooterItemCount - 1) + "].");
}
notifyItemRangeInserted(positionStart + newHeaderItemCount + newContentItemCount, itemCount);
} | [
"public",
"final",
"void",
"notifyFooterItemRangeInserted",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"int",
"newHeaderItemCount",
"=",
"getHeaderItemCount",
"(",
")",
";",
"int",
"newContentItemCount",
"=",
"getContentItemCount",
"(",
")",
";",
"int",
"newFooterItemCount",
"=",
"getFooterItemCount",
"(",
")",
";",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"newFooterItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for footer items [0 - \"",
"+",
"(",
"newFooterItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeInserted",
"(",
"positionStart",
"+",
"newHeaderItemCount",
"+",
"newContentItemCount",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple footer items are inserted.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"footer",
"items",
"are",
"inserted",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L329-L339 |
164,360 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyFooterItemChanged | public final void notifyFooterItemChanged(int position) {
if (position < 0 || position >= footerItemCount) {
throw new IndexOutOfBoundsException("The given position " + position
+ " is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemChanged(position + headerItemCount + contentItemCount);
} | java | public final void notifyFooterItemChanged(int position) {
if (position < 0 || position >= footerItemCount) {
throw new IndexOutOfBoundsException("The given position " + position
+ " is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemChanged(position + headerItemCount + contentItemCount);
} | [
"public",
"final",
"void",
"notifyFooterItemChanged",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"position",
"<",
"0",
"||",
"position",
">=",
"footerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given position \"",
"+",
"position",
"+",
"\" is not within the position bounds for footer items [0 - \"",
"+",
"(",
"footerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemChanged",
"(",
"position",
"+",
"headerItemCount",
"+",
"contentItemCount",
")",
";",
"}"
] | Notifies that a footer item is changed.
@param position the position. | [
"Notifies",
"that",
"a",
"footer",
"item",
"is",
"changed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L346-L353 |
164,361 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyFooterItemRangeChanged | public final void notifyFooterItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart + headerItemCount + contentItemCount, itemCount);
} | java | public final void notifyFooterItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart + headerItemCount + contentItemCount, itemCount);
} | [
"public",
"final",
"void",
"notifyFooterItemRangeChanged",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"footerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for footer items [0 - \"",
"+",
"(",
"footerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeChanged",
"(",
"positionStart",
"+",
"headerItemCount",
"+",
"contentItemCount",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple footer items are changed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"footer",
"items",
"are",
"changed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L361-L368 |
164,362 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyFooterItemMoved | public final void notifyFooterItemMoved(int fromPosition, int toPosition) {
if (fromPosition < 0 || toPosition < 0 || fromPosition >= footerItemCount || toPosition >= footerItemCount) {
throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition
+ " or toPosition " + toPosition + " is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemMoved(fromPosition + headerItemCount + contentItemCount, toPosition + headerItemCount + contentItemCount);
} | java | public final void notifyFooterItemMoved(int fromPosition, int toPosition) {
if (fromPosition < 0 || toPosition < 0 || fromPosition >= footerItemCount || toPosition >= footerItemCount) {
throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition
+ " or toPosition " + toPosition + " is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemMoved(fromPosition + headerItemCount + contentItemCount, toPosition + headerItemCount + contentItemCount);
} | [
"public",
"final",
"void",
"notifyFooterItemMoved",
"(",
"int",
"fromPosition",
",",
"int",
"toPosition",
")",
"{",
"if",
"(",
"fromPosition",
"<",
"0",
"||",
"toPosition",
"<",
"0",
"||",
"fromPosition",
">=",
"footerItemCount",
"||",
"toPosition",
">=",
"footerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given fromPosition \"",
"+",
"fromPosition",
"+",
"\" or toPosition \"",
"+",
"toPosition",
"+",
"\" is not within the position bounds for footer items [0 - \"",
"+",
"(",
"footerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemMoved",
"(",
"fromPosition",
"+",
"headerItemCount",
"+",
"contentItemCount",
",",
"toPosition",
"+",
"headerItemCount",
"+",
"contentItemCount",
")",
";",
"}"
] | Notifies that an existing footer item is moved to another position.
@param fromPosition the original position.
@param toPosition the new position. | [
"Notifies",
"that",
"an",
"existing",
"footer",
"item",
"is",
"moved",
"to",
"another",
"position",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L376-L383 |
164,363 | mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyFooterItemRangeRemoved | public final void notifyFooterItemRangeRemoved(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart + headerItemCount + contentItemCount, itemCount);
} | java | public final void notifyFooterItemRangeRemoved(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart + headerItemCount + contentItemCount, itemCount);
} | [
"public",
"final",
"void",
"notifyFooterItemRangeRemoved",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"footerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for footer items [0 - \"",
"+",
"(",
"footerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeRemoved",
"(",
"positionStart",
"+",
"headerItemCount",
"+",
"contentItemCount",
",",
"itemCount",
")",
";",
"}"
] | Notifies that multiple footer items are removed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"footer",
"items",
"are",
"removed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L404-L411 |
164,364 | mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/list/AdapterExtend.java | AdapterExtend.getView | @Override
public View getView(int position, View convertView, ViewGroup parent) {
if (position == super.getCount() && isEnableRefreshing()) {
return (mFooter);
}
return (super.getView(position, convertView, parent));
} | java | @Override
public View getView(int position, View convertView, ViewGroup parent) {
if (position == super.getCount() && isEnableRefreshing()) {
return (mFooter);
}
return (super.getView(position, convertView, parent));
} | [
"@",
"Override",
"public",
"View",
"getView",
"(",
"int",
"position",
",",
"View",
"convertView",
",",
"ViewGroup",
"parent",
")",
"{",
"if",
"(",
"position",
"==",
"super",
".",
"getCount",
"(",
")",
"&&",
"isEnableRefreshing",
"(",
")",
")",
"{",
"return",
"(",
"mFooter",
")",
";",
"}",
"return",
"(",
"super",
".",
"getView",
"(",
"position",
",",
"convertView",
",",
"parent",
")",
")",
";",
"}"
] | Get a View that displays the data at the specified
position in the data set. In this case, if we are at
the end of the list and we are still in append mode, we
ask for a pending view and return it, plus kick off the
background task to append more data to the wrapped
adapter.
@param position Position of the item whose data we want
@param convertView View to recycle, if not null
@param parent ViewGroup containing the returned View | [
"Get",
"a",
"View",
"that",
"displays",
"the",
"data",
"at",
"the",
"specified",
"position",
"in",
"the",
"data",
"set",
".",
"In",
"this",
"case",
"if",
"we",
"are",
"at",
"the",
"end",
"of",
"the",
"list",
"and",
"we",
"are",
"still",
"in",
"append",
"mode",
"we",
"ask",
"for",
"a",
"pending",
"view",
"and",
"return",
"it",
"plus",
"kick",
"off",
"the",
"background",
"task",
"to",
"append",
"more",
"data",
"to",
"the",
"wrapped",
"adapter",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/list/AdapterExtend.java#L146-L152 |
164,365 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java | StringUtils.addStringToArray | public static String[] addStringToArray(String[] array, String str) {
if (isEmpty(array)) {
return new String[]{str};
}
String[] newArr = new String[array.length + 1];
System.arraycopy(array, 0, newArr, 0, array.length);
newArr[array.length] = str;
return newArr;
} | java | public static String[] addStringToArray(String[] array, String str) {
if (isEmpty(array)) {
return new String[]{str};
}
String[] newArr = new String[array.length + 1];
System.arraycopy(array, 0, newArr, 0, array.length);
newArr[array.length] = str;
return newArr;
} | [
"public",
"static",
"String",
"[",
"]",
"addStringToArray",
"(",
"String",
"[",
"]",
"array",
",",
"String",
"str",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"array",
")",
")",
"{",
"return",
"new",
"String",
"[",
"]",
"{",
"str",
"}",
";",
"}",
"String",
"[",
"]",
"newArr",
"=",
"new",
"String",
"[",
"array",
".",
"length",
"+",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"array",
",",
"0",
",",
"newArr",
",",
"0",
",",
"array",
".",
"length",
")",
";",
"newArr",
"[",
"array",
".",
"length",
"]",
"=",
"str",
";",
"return",
"newArr",
";",
"}"
] | Append the given String to the given String array, returning a new array
consisting of the input array contents plus the given String.
@param array the array to append to (can be <code>null</code>)
@param str the String to append
@return the new array (never <code>null</code>) | [
"Append",
"the",
"given",
"String",
"to",
"the",
"given",
"String",
"array",
"returning",
"a",
"new",
"array",
"consisting",
"of",
"the",
"input",
"array",
"contents",
"plus",
"the",
"given",
"String",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java#L887-L895 |
164,366 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java | StringUtils.sortStringArray | public static String[] sortStringArray(String[] array) {
if (isEmpty(array)) {
return new String[0];
}
Arrays.sort(array);
return array;
} | java | public static String[] sortStringArray(String[] array) {
if (isEmpty(array)) {
return new String[0];
}
Arrays.sort(array);
return array;
} | [
"public",
"static",
"String",
"[",
"]",
"sortStringArray",
"(",
"String",
"[",
"]",
"array",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"array",
")",
")",
"{",
"return",
"new",
"String",
"[",
"0",
"]",
";",
"}",
"Arrays",
".",
"sort",
"(",
"array",
")",
";",
"return",
"array",
";",
"}"
] | Turn given source String array into sorted array.
@param array the source array
@return the sorted array (never <code>null</code>) | [
"Turn",
"given",
"source",
"String",
"array",
"into",
"sorted",
"array",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java#L957-L963 |
164,367 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java | StringUtils.removeDuplicateStrings | public static String[] removeDuplicateStrings(String[] array) {
if (isEmpty(array)) {
return array;
}
Set<String> set = new TreeSet<String>();
Collections.addAll(set, array);
return toStringArray(set);
} | java | public static String[] removeDuplicateStrings(String[] array) {
if (isEmpty(array)) {
return array;
}
Set<String> set = new TreeSet<String>();
Collections.addAll(set, array);
return toStringArray(set);
} | [
"public",
"static",
"String",
"[",
"]",
"removeDuplicateStrings",
"(",
"String",
"[",
"]",
"array",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"array",
")",
")",
"{",
"return",
"array",
";",
"}",
"Set",
"<",
"String",
">",
"set",
"=",
"new",
"TreeSet",
"<",
"String",
">",
"(",
")",
";",
"Collections",
".",
"addAll",
"(",
"set",
",",
"array",
")",
";",
"return",
"toStringArray",
"(",
"set",
")",
";",
"}"
] | Remove duplicate Strings from the given array. Also sorts the array, as
it uses a TreeSet.
@param array the String array
@return an array without duplicates, in natural sort order | [
"Remove",
"duplicate",
"Strings",
"from",
"the",
"given",
"array",
".",
"Also",
"sorts",
"the",
"array",
"as",
"it",
"uses",
"a",
"TreeSet",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java#L1022-L1029 |
164,368 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java | StringUtils.commaDelimitedListToSet | public static Set<String> commaDelimitedListToSet(String str) {
Set<String> set = new TreeSet<String>();
String[] tokens = commaDelimitedListToStringArray(str);
Collections.addAll(set, tokens);
return set;
} | java | public static Set<String> commaDelimitedListToSet(String str) {
Set<String> set = new TreeSet<String>();
String[] tokens = commaDelimitedListToStringArray(str);
Collections.addAll(set, tokens);
return set;
} | [
"public",
"static",
"Set",
"<",
"String",
">",
"commaDelimitedListToSet",
"(",
"String",
"str",
")",
"{",
"Set",
"<",
"String",
">",
"set",
"=",
"new",
"TreeSet",
"<",
"String",
">",
"(",
")",
";",
"String",
"[",
"]",
"tokens",
"=",
"commaDelimitedListToStringArray",
"(",
"str",
")",
";",
"Collections",
".",
"addAll",
"(",
"set",
",",
"tokens",
")",
";",
"return",
"set",
";",
"}"
] | Convenience method to convert a CSV string list to a set. Note that this
will suppress duplicates.
@param str the input String
@return a Set of String entries in the list | [
"Convenience",
"method",
"to",
"convert",
"a",
"CSV",
"string",
"list",
"to",
"a",
"set",
".",
"Note",
"that",
"this",
"will",
"suppress",
"duplicates",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java#L1257-L1262 |
164,369 | mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java | StringUtils.toSafeFileName | public static String toSafeFileName(String name) {
int size = name.length();
StringBuilder builder = new StringBuilder(size * 2);
for (int i = 0; i < size; i++) {
char c = name.charAt(i);
boolean valid = c >= 'a' && c <= 'z';
valid = valid || (c >= 'A' && c <= 'Z');
valid = valid || (c >= '0' && c <= '9');
valid = valid || (c == '_') || (c == '-') || (c == '.');
if (valid) {
builder.append(c);
} else {
// Encode the character using hex notation
builder.append('x');
builder.append(Integer.toHexString(i));
}
}
return builder.toString();
} | java | public static String toSafeFileName(String name) {
int size = name.length();
StringBuilder builder = new StringBuilder(size * 2);
for (int i = 0; i < size; i++) {
char c = name.charAt(i);
boolean valid = c >= 'a' && c <= 'z';
valid = valid || (c >= 'A' && c <= 'Z');
valid = valid || (c >= '0' && c <= '9');
valid = valid || (c == '_') || (c == '-') || (c == '.');
if (valid) {
builder.append(c);
} else {
// Encode the character using hex notation
builder.append('x');
builder.append(Integer.toHexString(i));
}
}
return builder.toString();
} | [
"public",
"static",
"String",
"toSafeFileName",
"(",
"String",
"name",
")",
"{",
"int",
"size",
"=",
"name",
".",
"length",
"(",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"size",
"*",
"2",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"name",
".",
"charAt",
"(",
"i",
")",
";",
"boolean",
"valid",
"=",
"c",
">=",
"'",
"'",
"&&",
"c",
"<=",
"'",
"'",
";",
"valid",
"=",
"valid",
"||",
"(",
"c",
">=",
"'",
"'",
"&&",
"c",
"<=",
"'",
"'",
")",
";",
"valid",
"=",
"valid",
"||",
"(",
"c",
">=",
"'",
"'",
"&&",
"c",
"<=",
"'",
"'",
")",
";",
"valid",
"=",
"valid",
"||",
"(",
"c",
"==",
"'",
"'",
")",
"||",
"(",
"c",
"==",
"'",
"'",
")",
"||",
"(",
"c",
"==",
"'",
"'",
")",
";",
"if",
"(",
"valid",
")",
"{",
"builder",
".",
"append",
"(",
"c",
")",
";",
"}",
"else",
"{",
"// Encode the character using hex notation",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"builder",
".",
"append",
"(",
"Integer",
".",
"toHexString",
"(",
"i",
")",
")",
";",
"}",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | Converts any string into a string that is safe to use as a file name.
The result will only include ascii characters and numbers, and the "-","_", and "." characters. | [
"Converts",
"any",
"string",
"into",
"a",
"string",
"that",
"is",
"safe",
"to",
"use",
"as",
"a",
"file",
"name",
".",
"The",
"result",
"will",
"only",
"include",
"ascii",
"characters",
"and",
"numbers",
"and",
"the",
"-",
"_",
"and",
".",
"characters",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/StringUtils.java#L1525-L1544 |
164,370 | taskadapter/trello-java-wrapper | src/main/java/com/julienvey/trello/impl/TrelloImpl.java | TrelloImpl.getBoardMemberActivity | @Override
@Deprecated
public List<CardWithActions> getBoardMemberActivity(String boardId, String memberId,
String actionFilter, Argument... args) {
if (actionFilter == null)
actionFilter = "all";
Argument[] argsAndFilter = Arrays.copyOf(args, args.length + 1);
argsAndFilter[args.length] = new Argument("actions", actionFilter);
return asList(() -> get(createUrl(GET_BOARD_MEMBER_CARDS).params(argsAndFilter).asString(),
CardWithActions[].class, boardId, memberId));
} | java | @Override
@Deprecated
public List<CardWithActions> getBoardMemberActivity(String boardId, String memberId,
String actionFilter, Argument... args) {
if (actionFilter == null)
actionFilter = "all";
Argument[] argsAndFilter = Arrays.copyOf(args, args.length + 1);
argsAndFilter[args.length] = new Argument("actions", actionFilter);
return asList(() -> get(createUrl(GET_BOARD_MEMBER_CARDS).params(argsAndFilter).asString(),
CardWithActions[].class, boardId, memberId));
} | [
"@",
"Override",
"@",
"Deprecated",
"public",
"List",
"<",
"CardWithActions",
">",
"getBoardMemberActivity",
"(",
"String",
"boardId",
",",
"String",
"memberId",
",",
"String",
"actionFilter",
",",
"Argument",
"...",
"args",
")",
"{",
"if",
"(",
"actionFilter",
"==",
"null",
")",
"actionFilter",
"=",
"\"all\"",
";",
"Argument",
"[",
"]",
"argsAndFilter",
"=",
"Arrays",
".",
"copyOf",
"(",
"args",
",",
"args",
".",
"length",
"+",
"1",
")",
";",
"argsAndFilter",
"[",
"args",
".",
"length",
"]",
"=",
"new",
"Argument",
"(",
"\"actions\"",
",",
"actionFilter",
")",
";",
"return",
"asList",
"(",
"(",
")",
"->",
"get",
"(",
"createUrl",
"(",
"GET_BOARD_MEMBER_CARDS",
")",
".",
"params",
"(",
"argsAndFilter",
")",
".",
"asString",
"(",
")",
",",
"CardWithActions",
"[",
"]",
".",
"class",
",",
"boardId",
",",
"memberId",
")",
")",
";",
"}"
] | FIXME Remove this method | [
"FIXME",
"Remove",
"this",
"method"
] | 70d57a890e54307eab81659a3d420d05ea48bd5d | https://github.com/taskadapter/trello-java-wrapper/blob/70d57a890e54307eab81659a3d420d05ea48bd5d/src/main/java/com/julienvey/trello/impl/TrelloImpl.java#L232-L243 |
164,371 | codelibs/jcifs | src/main/java/jcifs/smb1/smb1/SigningDigest.java | SigningDigest.sign | void sign(byte[] data, int offset, int length,
ServerMessageBlock request, ServerMessageBlock response) {
request.signSeq = signSequence;
if( response != null ) {
response.signSeq = signSequence + 1;
response.verifyFailed = false;
}
try {
update(macSigningKey, 0, macSigningKey.length);
int index = offset + ServerMessageBlock.SIGNATURE_OFFSET;
for (int i = 0; i < 8; i++) data[index + i] = 0;
ServerMessageBlock.writeInt4(signSequence, data, index);
update(data, offset, length);
System.arraycopy(digest(), 0, data, index, 8);
if (bypass) {
bypass = false;
System.arraycopy("BSRSPYL ".getBytes(), 0, data, index, 8);
}
} catch (Exception ex) {
if( log.level > 0 )
ex.printStackTrace( log );
} finally {
signSequence += 2;
}
} | java | void sign(byte[] data, int offset, int length,
ServerMessageBlock request, ServerMessageBlock response) {
request.signSeq = signSequence;
if( response != null ) {
response.signSeq = signSequence + 1;
response.verifyFailed = false;
}
try {
update(macSigningKey, 0, macSigningKey.length);
int index = offset + ServerMessageBlock.SIGNATURE_OFFSET;
for (int i = 0; i < 8; i++) data[index + i] = 0;
ServerMessageBlock.writeInt4(signSequence, data, index);
update(data, offset, length);
System.arraycopy(digest(), 0, data, index, 8);
if (bypass) {
bypass = false;
System.arraycopy("BSRSPYL ".getBytes(), 0, data, index, 8);
}
} catch (Exception ex) {
if( log.level > 0 )
ex.printStackTrace( log );
} finally {
signSequence += 2;
}
} | [
"void",
"sign",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"length",
",",
"ServerMessageBlock",
"request",
",",
"ServerMessageBlock",
"response",
")",
"{",
"request",
".",
"signSeq",
"=",
"signSequence",
";",
"if",
"(",
"response",
"!=",
"null",
")",
"{",
"response",
".",
"signSeq",
"=",
"signSequence",
"+",
"1",
";",
"response",
".",
"verifyFailed",
"=",
"false",
";",
"}",
"try",
"{",
"update",
"(",
"macSigningKey",
",",
"0",
",",
"macSigningKey",
".",
"length",
")",
";",
"int",
"index",
"=",
"offset",
"+",
"ServerMessageBlock",
".",
"SIGNATURE_OFFSET",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"8",
";",
"i",
"++",
")",
"data",
"[",
"index",
"+",
"i",
"]",
"=",
"0",
";",
"ServerMessageBlock",
".",
"writeInt4",
"(",
"signSequence",
",",
"data",
",",
"index",
")",
";",
"update",
"(",
"data",
",",
"offset",
",",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"digest",
"(",
")",
",",
"0",
",",
"data",
",",
"index",
",",
"8",
")",
";",
"if",
"(",
"bypass",
")",
"{",
"bypass",
"=",
"false",
";",
"System",
".",
"arraycopy",
"(",
"\"BSRSPYL \"",
".",
"getBytes",
"(",
")",
",",
"0",
",",
"data",
",",
"index",
",",
"8",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"if",
"(",
"log",
".",
"level",
">",
"0",
")",
"ex",
".",
"printStackTrace",
"(",
"log",
")",
";",
"}",
"finally",
"{",
"signSequence",
"+=",
"2",
";",
"}",
"}"
] | Performs MAC signing of the SMB. This is done as follows.
The signature field of the SMB is overwritted with the sequence number;
The MD5 digest of the MAC signing key + the entire SMB is taken;
The first 8 bytes of this are placed in the signature field.
@param data The data.
@param offset The starting offset at which the SMB header begins.
@param length The length of the SMB data starting at offset. | [
"Performs",
"MAC",
"signing",
"of",
"the",
"SMB",
".",
"This",
"is",
"done",
"as",
"follows",
".",
"The",
"signature",
"field",
"of",
"the",
"SMB",
"is",
"overwritted",
"with",
"the",
"sequence",
"number",
";",
"The",
"MD5",
"digest",
"of",
"the",
"MAC",
"signing",
"key",
"+",
"the",
"entire",
"SMB",
"is",
"taken",
";",
"The",
"first",
"8",
"bytes",
"of",
"this",
"are",
"placed",
"in",
"the",
"signature",
"field",
"."
] | ac6a8ba2925648ae003ca2508aec32316065dc34 | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/smb1/SigningDigest.java#L125-L150 |
164,372 | codelibs/jcifs | src/main/java/jcifs/smb1/Config.java | Config.setProperty | public static Object setProperty( String key, String value ) {
return prp.setProperty( key, value );
} | java | public static Object setProperty( String key, String value ) {
return prp.setProperty( key, value );
} | [
"public",
"static",
"Object",
"setProperty",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"return",
"prp",
".",
"setProperty",
"(",
"key",
",",
"value",
")",
";",
"}"
] | Add a property. | [
"Add",
"a",
"property",
"."
] | ac6a8ba2925648ae003ca2508aec32316065dc34 | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/Config.java#L187-L189 |
164,373 | codelibs/jcifs | src/main/java/jcifs/smb1/netbios/NbtAddress.java | NbtAddress.getAllByAddress | public static NbtAddress[] getAllByAddress( NbtAddress addr )
throws UnknownHostException {
try {
NbtAddress[] addrs = CLIENT.getNodeStatus( addr );
cacheAddressArray( addrs );
return addrs;
} catch( UnknownHostException uhe ) {
throw new UnknownHostException( "no name with type 0x" +
Hexdump.toHexString( addr.hostName.hexCode, 2 ) +
((( addr.hostName.scope == null ) ||
( addr.hostName.scope.length() == 0 )) ?
" with no scope" : " with scope " + addr.hostName.scope ) +
" for host " + addr.getHostAddress() );
}
} | java | public static NbtAddress[] getAllByAddress( NbtAddress addr )
throws UnknownHostException {
try {
NbtAddress[] addrs = CLIENT.getNodeStatus( addr );
cacheAddressArray( addrs );
return addrs;
} catch( UnknownHostException uhe ) {
throw new UnknownHostException( "no name with type 0x" +
Hexdump.toHexString( addr.hostName.hexCode, 2 ) +
((( addr.hostName.scope == null ) ||
( addr.hostName.scope.length() == 0 )) ?
" with no scope" : " with scope " + addr.hostName.scope ) +
" for host " + addr.getHostAddress() );
}
} | [
"public",
"static",
"NbtAddress",
"[",
"]",
"getAllByAddress",
"(",
"NbtAddress",
"addr",
")",
"throws",
"UnknownHostException",
"{",
"try",
"{",
"NbtAddress",
"[",
"]",
"addrs",
"=",
"CLIENT",
".",
"getNodeStatus",
"(",
"addr",
")",
";",
"cacheAddressArray",
"(",
"addrs",
")",
";",
"return",
"addrs",
";",
"}",
"catch",
"(",
"UnknownHostException",
"uhe",
")",
"{",
"throw",
"new",
"UnknownHostException",
"(",
"\"no name with type 0x\"",
"+",
"Hexdump",
".",
"toHexString",
"(",
"addr",
".",
"hostName",
".",
"hexCode",
",",
"2",
")",
"+",
"(",
"(",
"(",
"addr",
".",
"hostName",
".",
"scope",
"==",
"null",
")",
"||",
"(",
"addr",
".",
"hostName",
".",
"scope",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"?",
"\" with no scope\"",
":",
"\" with scope \"",
"+",
"addr",
".",
"hostName",
".",
"scope",
")",
"+",
"\" for host \"",
"+",
"addr",
".",
"getHostAddress",
"(",
")",
")",
";",
"}",
"}"
] | Retrieve all addresses of a host by it's address. NetBIOS hosts can
have many names for a given IP address. The name and IP address make the
NetBIOS address. This provides a way to retrieve the other names for a
host with the same IP address.
@param addr the address to query
@throws UnknownHostException if address cannot be resolved | [
"Retrieve",
"all",
"addresses",
"of",
"a",
"host",
"by",
"it",
"s",
"address",
".",
"NetBIOS",
"hosts",
"can",
"have",
"many",
"names",
"for",
"a",
"given",
"IP",
"address",
".",
"The",
"name",
"and",
"IP",
"address",
"make",
"the",
"NetBIOS",
"address",
".",
"This",
"provides",
"a",
"way",
"to",
"retrieve",
"the",
"other",
"names",
"for",
"a",
"host",
"with",
"the",
"same",
"IP",
"address",
"."
] | ac6a8ba2925648ae003ca2508aec32316065dc34 | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/netbios/NbtAddress.java#L517-L531 |
164,374 | codelibs/jcifs | src/main/java/jcifs/smb1/UniAddress.java | UniAddress.getHostName | public String getHostName() {
if( addr instanceof NbtAddress ) {
return ((NbtAddress)addr).getHostName();
}
return ((InetAddress)addr).getHostName();
} | java | public String getHostName() {
if( addr instanceof NbtAddress ) {
return ((NbtAddress)addr).getHostName();
}
return ((InetAddress)addr).getHostName();
} | [
"public",
"String",
"getHostName",
"(",
")",
"{",
"if",
"(",
"addr",
"instanceof",
"NbtAddress",
")",
"{",
"return",
"(",
"(",
"NbtAddress",
")",
"addr",
")",
".",
"getHostName",
"(",
")",
";",
"}",
"return",
"(",
"(",
"InetAddress",
")",
"addr",
")",
".",
"getHostName",
"(",
")",
";",
"}"
] | Return the hostname of this address such as "MYCOMPUTER". | [
"Return",
"the",
"hostname",
"of",
"this",
"address",
"such",
"as",
"MYCOMPUTER",
"."
] | ac6a8ba2925648ae003ca2508aec32316065dc34 | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/UniAddress.java#L445-L450 |
164,375 | codelibs/jcifs | src/main/java/jcifs/smb1/UniAddress.java | UniAddress.getHostAddress | public String getHostAddress() {
if( addr instanceof NbtAddress ) {
return ((NbtAddress)addr).getHostAddress();
}
return ((InetAddress)addr).getHostAddress();
} | java | public String getHostAddress() {
if( addr instanceof NbtAddress ) {
return ((NbtAddress)addr).getHostAddress();
}
return ((InetAddress)addr).getHostAddress();
} | [
"public",
"String",
"getHostAddress",
"(",
")",
"{",
"if",
"(",
"addr",
"instanceof",
"NbtAddress",
")",
"{",
"return",
"(",
"(",
"NbtAddress",
")",
"addr",
")",
".",
"getHostAddress",
"(",
")",
";",
"}",
"return",
"(",
"(",
"InetAddress",
")",
"addr",
")",
".",
"getHostAddress",
"(",
")",
";",
"}"
] | Return the IP address as text such as "192.168.1.15". | [
"Return",
"the",
"IP",
"address",
"as",
"text",
"such",
"as",
"192",
".",
"168",
".",
"1",
".",
"15",
"."
] | ac6a8ba2925648ae003ca2508aec32316065dc34 | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/UniAddress.java#L456-L461 |
164,376 | codelibs/jcifs | src/main/java/jcifs/smb1/smb1/SmbFile.java | SmbFile.getUncPath | public String getUncPath() {
getUncPath0();
if( share == null ) {
return "\\\\" + url.getHost();
}
return "\\\\" + url.getHost() + canon.replace( '/', '\\' );
} | java | public String getUncPath() {
getUncPath0();
if( share == null ) {
return "\\\\" + url.getHost();
}
return "\\\\" + url.getHost() + canon.replace( '/', '\\' );
} | [
"public",
"String",
"getUncPath",
"(",
")",
"{",
"getUncPath0",
"(",
")",
";",
"if",
"(",
"share",
"==",
"null",
")",
"{",
"return",
"\"\\\\\\\\\"",
"+",
"url",
".",
"getHost",
"(",
")",
";",
"}",
"return",
"\"\\\\\\\\\"",
"+",
"url",
".",
"getHost",
"(",
")",
"+",
"canon",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"}"
] | Retuns the Windows UNC style path with backslashs intead of forward slashes.
@return The UNC path. | [
"Retuns",
"the",
"Windows",
"UNC",
"style",
"path",
"with",
"backslashs",
"intead",
"of",
"forward",
"slashes",
"."
] | ac6a8ba2925648ae003ca2508aec32316065dc34 | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/smb1/SmbFile.java#L1213-L1219 |
164,377 | codelibs/jcifs | src/main/java/jcifs/smb1/smb1/SmbFile.java | SmbFile.createNewFile | public void createNewFile() throws SmbException {
if( getUncPath0().length() == 1 ) {
throw new SmbException( "Invalid operation for workgroups, servers, or shares" );
}
close( open0( O_RDWR | O_CREAT | O_EXCL, 0, ATTR_NORMAL, 0 ), 0L );
} | java | public void createNewFile() throws SmbException {
if( getUncPath0().length() == 1 ) {
throw new SmbException( "Invalid operation for workgroups, servers, or shares" );
}
close( open0( O_RDWR | O_CREAT | O_EXCL, 0, ATTR_NORMAL, 0 ), 0L );
} | [
"public",
"void",
"createNewFile",
"(",
")",
"throws",
"SmbException",
"{",
"if",
"(",
"getUncPath0",
"(",
")",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"throw",
"new",
"SmbException",
"(",
"\"Invalid operation for workgroups, servers, or shares\"",
")",
";",
"}",
"close",
"(",
"open0",
"(",
"O_RDWR",
"|",
"O_CREAT",
"|",
"O_EXCL",
",",
"0",
",",
"ATTR_NORMAL",
",",
"0",
")",
",",
"0L",
")",
";",
"}"
] | Create a new file but fail if it already exists. The check for
existance of the file and it's creation are an atomic operation with
respect to other filesystem activities. | [
"Create",
"a",
"new",
"file",
"but",
"fail",
"if",
"it",
"already",
"exists",
".",
"The",
"check",
"for",
"existance",
"of",
"the",
"file",
"and",
"it",
"s",
"creation",
"are",
"an",
"atomic",
"operation",
"with",
"respect",
"to",
"other",
"filesystem",
"activities",
"."
] | ac6a8ba2925648ae003ca2508aec32316065dc34 | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/smb1/SmbFile.java#L2567-L2572 |
164,378 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/json/JsonReport.java | JsonReport.getProjectName | private String getProjectName() {
String pName = Strings.emptyToNull(projectName);
if (pName == null) {
pName = Strings.emptyToNull(junit4.getProject().getName());
}
if (pName == null) {
pName = "(unnamed project)";
}
return pName;
} | java | private String getProjectName() {
String pName = Strings.emptyToNull(projectName);
if (pName == null) {
pName = Strings.emptyToNull(junit4.getProject().getName());
}
if (pName == null) {
pName = "(unnamed project)";
}
return pName;
} | [
"private",
"String",
"getProjectName",
"(",
")",
"{",
"String",
"pName",
"=",
"Strings",
".",
"emptyToNull",
"(",
"projectName",
")",
";",
"if",
"(",
"pName",
"==",
"null",
")",
"{",
"pName",
"=",
"Strings",
".",
"emptyToNull",
"(",
"junit4",
".",
"getProject",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"pName",
"==",
"null",
")",
"{",
"pName",
"=",
"\"(unnamed project)\"",
";",
"}",
"return",
"pName",
";",
"}"
] | Return the project name or the default project name. | [
"Return",
"the",
"project",
"name",
"or",
"the",
"default",
"project",
"name",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/json/JsonReport.java#L184-L193 |
164,379 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/json/JsonReport.java | JsonReport.onSuiteResult | @Subscribe
@SuppressForbidden("legitimate printStackTrace().")
public void onSuiteResult(AggregatedSuiteResultEvent e) {
try {
if (jsonWriter == null)
return;
slaves.put(e.getSlave().id, e.getSlave());
e.serialize(jsonWriter, outputStreams);
} catch (Exception ex) {
ex.printStackTrace();
junit4.log("Error serializing to JSON file: "
+ Throwables.getStackTraceAsString(ex), Project.MSG_WARN);
if (jsonWriter != null) {
try {
jsonWriter.close();
} catch (Throwable ignored) {
// Ignore.
} finally {
jsonWriter = null;
}
}
}
} | java | @Subscribe
@SuppressForbidden("legitimate printStackTrace().")
public void onSuiteResult(AggregatedSuiteResultEvent e) {
try {
if (jsonWriter == null)
return;
slaves.put(e.getSlave().id, e.getSlave());
e.serialize(jsonWriter, outputStreams);
} catch (Exception ex) {
ex.printStackTrace();
junit4.log("Error serializing to JSON file: "
+ Throwables.getStackTraceAsString(ex), Project.MSG_WARN);
if (jsonWriter != null) {
try {
jsonWriter.close();
} catch (Throwable ignored) {
// Ignore.
} finally {
jsonWriter = null;
}
}
}
} | [
"@",
"Subscribe",
"@",
"SuppressForbidden",
"(",
"\"legitimate printStackTrace().\"",
")",
"public",
"void",
"onSuiteResult",
"(",
"AggregatedSuiteResultEvent",
"e",
")",
"{",
"try",
"{",
"if",
"(",
"jsonWriter",
"==",
"null",
")",
"return",
";",
"slaves",
".",
"put",
"(",
"e",
".",
"getSlave",
"(",
")",
".",
"id",
",",
"e",
".",
"getSlave",
"(",
")",
")",
";",
"e",
".",
"serialize",
"(",
"jsonWriter",
",",
"outputStreams",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"junit4",
".",
"log",
"(",
"\"Error serializing to JSON file: \"",
"+",
"Throwables",
".",
"getStackTraceAsString",
"(",
"ex",
")",
",",
"Project",
".",
"MSG_WARN",
")",
";",
"if",
"(",
"jsonWriter",
"!=",
"null",
")",
"{",
"try",
"{",
"jsonWriter",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"ignored",
")",
"{",
"// Ignore.",
"}",
"finally",
"{",
"jsonWriter",
"=",
"null",
";",
"}",
"}",
"}",
"}"
] | Emit information about a single suite and all of its tests. | [
"Emit",
"information",
"about",
"a",
"single",
"suite",
"and",
"all",
"of",
"its",
"tests",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/json/JsonReport.java#L198-L221 |
164,380 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/json/JsonReport.java | JsonReport.onQuit | @Subscribe
public void onQuit(AggregatedQuitEvent e) {
if (jsonWriter == null)
return;
try {
jsonWriter.endArray();
jsonWriter.name("slaves");
jsonWriter.beginObject();
for (Map.Entry<Integer, ForkedJvmInfo> entry : slaves.entrySet()) {
jsonWriter.name(Integer.toString(entry.getKey()));
entry.getValue().serialize(jsonWriter);
}
jsonWriter.endObject();
jsonWriter.endObject();
jsonWriter.flush();
if (!Strings.isNullOrEmpty(jsonpMethod)) {
writer.write(");");
}
jsonWriter.close();
jsonWriter = null;
writer = null;
if (method == OutputMethod.HTML) {
copyScaffolding(targetFile);
}
} catch (IOException x) {
junit4.log(x, Project.MSG_ERR);
}
} | java | @Subscribe
public void onQuit(AggregatedQuitEvent e) {
if (jsonWriter == null)
return;
try {
jsonWriter.endArray();
jsonWriter.name("slaves");
jsonWriter.beginObject();
for (Map.Entry<Integer, ForkedJvmInfo> entry : slaves.entrySet()) {
jsonWriter.name(Integer.toString(entry.getKey()));
entry.getValue().serialize(jsonWriter);
}
jsonWriter.endObject();
jsonWriter.endObject();
jsonWriter.flush();
if (!Strings.isNullOrEmpty(jsonpMethod)) {
writer.write(");");
}
jsonWriter.close();
jsonWriter = null;
writer = null;
if (method == OutputMethod.HTML) {
copyScaffolding(targetFile);
}
} catch (IOException x) {
junit4.log(x, Project.MSG_ERR);
}
} | [
"@",
"Subscribe",
"public",
"void",
"onQuit",
"(",
"AggregatedQuitEvent",
"e",
")",
"{",
"if",
"(",
"jsonWriter",
"==",
"null",
")",
"return",
";",
"try",
"{",
"jsonWriter",
".",
"endArray",
"(",
")",
";",
"jsonWriter",
".",
"name",
"(",
"\"slaves\"",
")",
";",
"jsonWriter",
".",
"beginObject",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"ForkedJvmInfo",
">",
"entry",
":",
"slaves",
".",
"entrySet",
"(",
")",
")",
"{",
"jsonWriter",
".",
"name",
"(",
"Integer",
".",
"toString",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
";",
"entry",
".",
"getValue",
"(",
")",
".",
"serialize",
"(",
"jsonWriter",
")",
";",
"}",
"jsonWriter",
".",
"endObject",
"(",
")",
";",
"jsonWriter",
".",
"endObject",
"(",
")",
";",
"jsonWriter",
".",
"flush",
"(",
")",
";",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"jsonpMethod",
")",
")",
"{",
"writer",
".",
"write",
"(",
"\");\"",
")",
";",
"}",
"jsonWriter",
".",
"close",
"(",
")",
";",
"jsonWriter",
"=",
"null",
";",
"writer",
"=",
"null",
";",
"if",
"(",
"method",
"==",
"OutputMethod",
".",
"HTML",
")",
"{",
"copyScaffolding",
"(",
"targetFile",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"x",
")",
"{",
"junit4",
".",
"log",
"(",
"x",
",",
"Project",
".",
"MSG_ERR",
")",
";",
"}",
"}"
] | All tests completed. | [
"All",
"tests",
"completed",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/json/JsonReport.java#L226-L259 |
164,381 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.setSeed | public void setSeed(String randomSeed) {
if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_RANDOM_SEED()))) {
String userProperty = getProject().getUserProperty(SYSPROP_RANDOM_SEED());
if (!userProperty.equals(randomSeed)) {
log("Ignoring seed attribute because it is overridden by user properties.", Project.MSG_WARN);
}
} else if (!Strings.isNullOrEmpty(randomSeed)) {
this.random = randomSeed;
}
} | java | public void setSeed(String randomSeed) {
if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_RANDOM_SEED()))) {
String userProperty = getProject().getUserProperty(SYSPROP_RANDOM_SEED());
if (!userProperty.equals(randomSeed)) {
log("Ignoring seed attribute because it is overridden by user properties.", Project.MSG_WARN);
}
} else if (!Strings.isNullOrEmpty(randomSeed)) {
this.random = randomSeed;
}
} | [
"public",
"void",
"setSeed",
"(",
"String",
"randomSeed",
")",
"{",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"getProject",
"(",
")",
".",
"getUserProperty",
"(",
"SYSPROP_RANDOM_SEED",
"(",
")",
")",
")",
")",
"{",
"String",
"userProperty",
"=",
"getProject",
"(",
")",
".",
"getUserProperty",
"(",
"SYSPROP_RANDOM_SEED",
"(",
")",
")",
";",
"if",
"(",
"!",
"userProperty",
".",
"equals",
"(",
"randomSeed",
")",
")",
"{",
"log",
"(",
"\"Ignoring seed attribute because it is overridden by user properties.\"",
",",
"Project",
".",
"MSG_WARN",
")",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"randomSeed",
")",
")",
"{",
"this",
".",
"random",
"=",
"randomSeed",
";",
"}",
"}"
] | Initial random seed used for shuffling test suites and other sources
of pseudo-randomness. If not set, any random value is set.
<p>The seed's format is compatible with {@link RandomizedRunner} so that
seed can be fixed for suites and methods alike. | [
"Initial",
"random",
"seed",
"used",
"for",
"shuffling",
"test",
"suites",
"and",
"other",
"sources",
"of",
"pseudo",
"-",
"randomness",
".",
"If",
"not",
"set",
"any",
"random",
"value",
"is",
"set",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L484-L493 |
164,382 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.setPrefix | public void setPrefix(String prefix) {
if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_PREFIX()))) {
log("Ignoring prefix attribute because it is overridden by user properties.", Project.MSG_WARN);
} else {
SysGlobals.initializeWith(prefix);
}
} | java | public void setPrefix(String prefix) {
if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_PREFIX()))) {
log("Ignoring prefix attribute because it is overridden by user properties.", Project.MSG_WARN);
} else {
SysGlobals.initializeWith(prefix);
}
} | [
"public",
"void",
"setPrefix",
"(",
"String",
"prefix",
")",
"{",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"getProject",
"(",
")",
".",
"getUserProperty",
"(",
"SYSPROP_PREFIX",
"(",
")",
")",
")",
")",
"{",
"log",
"(",
"\"Ignoring prefix attribute because it is overridden by user properties.\"",
",",
"Project",
".",
"MSG_WARN",
")",
";",
"}",
"else",
"{",
"SysGlobals",
".",
"initializeWith",
"(",
"prefix",
")",
";",
"}",
"}"
] | Initializes custom prefix for all junit4 properties. This must be consistent
across all junit4 invocations if done from the same classpath. Use only when REALLY needed. | [
"Initializes",
"custom",
"prefix",
"for",
"all",
"junit4",
"properties",
".",
"This",
"must",
"be",
"consistent",
"across",
"all",
"junit4",
"invocations",
"if",
"done",
"from",
"the",
"same",
"classpath",
".",
"Use",
"only",
"when",
"REALLY",
"needed",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L499-L505 |
164,383 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.addFileSet | public void addFileSet(FileSet fs) {
add(fs);
if (fs.getProject() == null) {
fs.setProject(getProject());
}
} | java | public void addFileSet(FileSet fs) {
add(fs);
if (fs.getProject() == null) {
fs.setProject(getProject());
}
} | [
"public",
"void",
"addFileSet",
"(",
"FileSet",
"fs",
")",
"{",
"add",
"(",
"fs",
")",
";",
"if",
"(",
"fs",
".",
"getProject",
"(",
")",
"==",
"null",
")",
"{",
"fs",
".",
"setProject",
"(",
"getProject",
"(",
")",
")",
";",
"}",
"}"
] | Adds a set of tests based on pattern matching. | [
"Adds",
"a",
"set",
"of",
"tests",
"based",
"on",
"pattern",
"matching",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L715-L720 |
164,384 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.addAssertions | public void addAssertions(Assertions asserts) {
if (getCommandline().getAssertions() != null) {
throw new BuildException("Only one assertion declaration is allowed");
}
getCommandline().setAssertions(asserts);
} | java | public void addAssertions(Assertions asserts) {
if (getCommandline().getAssertions() != null) {
throw new BuildException("Only one assertion declaration is allowed");
}
getCommandline().setAssertions(asserts);
} | [
"public",
"void",
"addAssertions",
"(",
"Assertions",
"asserts",
")",
"{",
"if",
"(",
"getCommandline",
"(",
")",
".",
"getAssertions",
"(",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Only one assertion declaration is allowed\"",
")",
";",
"}",
"getCommandline",
"(",
")",
".",
"setAssertions",
"(",
"asserts",
")",
";",
"}"
] | Add assertions to tests execution. | [
"Add",
"assertions",
"to",
"tests",
"execution",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L746-L751 |
164,385 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.validateArguments | private void validateArguments() throws BuildException {
Path tempDir = getTempDir();
if (tempDir == null) {
throw new BuildException("Temporary directory cannot be null.");
}
if (Files.exists(tempDir)) {
if (!Files.isDirectory(tempDir)) {
throw new BuildException("Temporary directory is not a folder: " + tempDir.toAbsolutePath());
}
} else {
try {
Files.createDirectories(tempDir);
} catch (IOException e) {
throw new BuildException("Failed to create temporary folder: " + tempDir, e);
}
}
} | java | private void validateArguments() throws BuildException {
Path tempDir = getTempDir();
if (tempDir == null) {
throw new BuildException("Temporary directory cannot be null.");
}
if (Files.exists(tempDir)) {
if (!Files.isDirectory(tempDir)) {
throw new BuildException("Temporary directory is not a folder: " + tempDir.toAbsolutePath());
}
} else {
try {
Files.createDirectories(tempDir);
} catch (IOException e) {
throw new BuildException("Failed to create temporary folder: " + tempDir, e);
}
}
} | [
"private",
"void",
"validateArguments",
"(",
")",
"throws",
"BuildException",
"{",
"Path",
"tempDir",
"=",
"getTempDir",
"(",
")",
";",
"if",
"(",
"tempDir",
"==",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Temporary directory cannot be null.\"",
")",
";",
"}",
"if",
"(",
"Files",
".",
"exists",
"(",
"tempDir",
")",
")",
"{",
"if",
"(",
"!",
"Files",
".",
"isDirectory",
"(",
"tempDir",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Temporary directory is not a folder: \"",
"+",
"tempDir",
".",
"toAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"Files",
".",
"createDirectories",
"(",
"tempDir",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Failed to create temporary folder: \"",
"+",
"tempDir",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Validate arguments. | [
"Validate",
"arguments",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L1134-L1152 |
164,386 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.validateJUnit4 | private void validateJUnit4() throws BuildException {
try {
Class<?> clazz = Class.forName("org.junit.runner.Description");
if (!Serializable.class.isAssignableFrom(clazz)) {
throw new BuildException("At least JUnit version 4.10 is required on junit4's taskdef classpath.");
}
} catch (ClassNotFoundException e) {
throw new BuildException("JUnit JAR must be added to junit4 taskdef's classpath.");
}
} | java | private void validateJUnit4() throws BuildException {
try {
Class<?> clazz = Class.forName("org.junit.runner.Description");
if (!Serializable.class.isAssignableFrom(clazz)) {
throw new BuildException("At least JUnit version 4.10 is required on junit4's taskdef classpath.");
}
} catch (ClassNotFoundException e) {
throw new BuildException("JUnit JAR must be added to junit4 taskdef's classpath.");
}
} | [
"private",
"void",
"validateJUnit4",
"(",
")",
"throws",
"BuildException",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"\"org.junit.runner.Description\"",
")",
";",
"if",
"(",
"!",
"Serializable",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"At least JUnit version 4.10 is required on junit4's taskdef classpath.\"",
")",
";",
"}",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"JUnit JAR must be added to junit4 taskdef's classpath.\"",
")",
";",
"}",
"}"
] | Validate JUnit4 presence in a concrete version. | [
"Validate",
"JUnit4",
"presence",
"in",
"a",
"concrete",
"version",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L1157-L1166 |
164,387 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.resolveFiles | private org.apache.tools.ant.types.Path resolveFiles(org.apache.tools.ant.types.Path path) {
org.apache.tools.ant.types.Path cloned = new org.apache.tools.ant.types.Path(getProject());
for (String location : path.list()) {
cloned.createPathElement().setLocation(new File(location));
}
return cloned;
} | java | private org.apache.tools.ant.types.Path resolveFiles(org.apache.tools.ant.types.Path path) {
org.apache.tools.ant.types.Path cloned = new org.apache.tools.ant.types.Path(getProject());
for (String location : path.list()) {
cloned.createPathElement().setLocation(new File(location));
}
return cloned;
} | [
"private",
"org",
".",
"apache",
".",
"tools",
".",
"ant",
".",
"types",
".",
"Path",
"resolveFiles",
"(",
"org",
".",
"apache",
".",
"tools",
".",
"ant",
".",
"types",
".",
"Path",
"path",
")",
"{",
"org",
".",
"apache",
".",
"tools",
".",
"ant",
".",
"types",
".",
"Path",
"cloned",
"=",
"new",
"org",
".",
"apache",
".",
"tools",
".",
"ant",
".",
"types",
".",
"Path",
"(",
"getProject",
"(",
")",
")",
";",
"for",
"(",
"String",
"location",
":",
"path",
".",
"list",
"(",
")",
")",
"{",
"cloned",
".",
"createPathElement",
"(",
")",
".",
"setLocation",
"(",
"new",
"File",
"(",
"location",
")",
")",
";",
"}",
"return",
"cloned",
";",
"}"
] | Resolve all files from a given path and simplify its definition. | [
"Resolve",
"all",
"files",
"from",
"a",
"given",
"path",
"and",
"simplify",
"its",
"definition",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L1334-L1340 |
164,388 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.determineForkedJvmCount | private int determineForkedJvmCount(TestsCollection testCollection) {
int cores = Runtime.getRuntime().availableProcessors();
int jvmCount;
if (this.parallelism.equals(PARALLELISM_AUTO)) {
if (cores >= 8) {
// Maximum parallel jvms is 4, conserve some memory and memory bandwidth.
jvmCount = 4;
} else if (cores >= 4) {
// Make some space for the aggregator.
jvmCount = 3;
} else if (cores == 3) {
// Yes, three-core chips are a thing.
jvmCount = 2;
} else {
// even for dual cores it usually makes no sense to fork more than one
// JVM.
jvmCount = 1;
}
} else if (this.parallelism.equals(PARALLELISM_MAX)) {
jvmCount = Runtime.getRuntime().availableProcessors();
} else {
try {
jvmCount = Math.max(1, Integer.parseInt(parallelism));
} catch (NumberFormatException e) {
throw new BuildException("parallelism must be 'auto', 'max' or a valid integer: "
+ parallelism);
}
}
if (!testCollection.hasReplicatedSuites()) {
jvmCount = Math.min(testCollection.testClasses.size(), jvmCount);
}
return jvmCount;
} | java | private int determineForkedJvmCount(TestsCollection testCollection) {
int cores = Runtime.getRuntime().availableProcessors();
int jvmCount;
if (this.parallelism.equals(PARALLELISM_AUTO)) {
if (cores >= 8) {
// Maximum parallel jvms is 4, conserve some memory and memory bandwidth.
jvmCount = 4;
} else if (cores >= 4) {
// Make some space for the aggregator.
jvmCount = 3;
} else if (cores == 3) {
// Yes, three-core chips are a thing.
jvmCount = 2;
} else {
// even for dual cores it usually makes no sense to fork more than one
// JVM.
jvmCount = 1;
}
} else if (this.parallelism.equals(PARALLELISM_MAX)) {
jvmCount = Runtime.getRuntime().availableProcessors();
} else {
try {
jvmCount = Math.max(1, Integer.parseInt(parallelism));
} catch (NumberFormatException e) {
throw new BuildException("parallelism must be 'auto', 'max' or a valid integer: "
+ parallelism);
}
}
if (!testCollection.hasReplicatedSuites()) {
jvmCount = Math.min(testCollection.testClasses.size(), jvmCount);
}
return jvmCount;
} | [
"private",
"int",
"determineForkedJvmCount",
"(",
"TestsCollection",
"testCollection",
")",
"{",
"int",
"cores",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"availableProcessors",
"(",
")",
";",
"int",
"jvmCount",
";",
"if",
"(",
"this",
".",
"parallelism",
".",
"equals",
"(",
"PARALLELISM_AUTO",
")",
")",
"{",
"if",
"(",
"cores",
">=",
"8",
")",
"{",
"// Maximum parallel jvms is 4, conserve some memory and memory bandwidth.",
"jvmCount",
"=",
"4",
";",
"}",
"else",
"if",
"(",
"cores",
">=",
"4",
")",
"{",
"// Make some space for the aggregator.",
"jvmCount",
"=",
"3",
";",
"}",
"else",
"if",
"(",
"cores",
"==",
"3",
")",
"{",
"// Yes, three-core chips are a thing.",
"jvmCount",
"=",
"2",
";",
"}",
"else",
"{",
"// even for dual cores it usually makes no sense to fork more than one",
"// JVM.",
"jvmCount",
"=",
"1",
";",
"}",
"}",
"else",
"if",
"(",
"this",
".",
"parallelism",
".",
"equals",
"(",
"PARALLELISM_MAX",
")",
")",
"{",
"jvmCount",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"availableProcessors",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"jvmCount",
"=",
"Math",
".",
"max",
"(",
"1",
",",
"Integer",
".",
"parseInt",
"(",
"parallelism",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"parallelism must be 'auto', 'max' or a valid integer: \"",
"+",
"parallelism",
")",
";",
"}",
"}",
"if",
"(",
"!",
"testCollection",
".",
"hasReplicatedSuites",
"(",
")",
")",
"{",
"jvmCount",
"=",
"Math",
".",
"min",
"(",
"testCollection",
".",
"testClasses",
".",
"size",
"(",
")",
",",
"jvmCount",
")",
";",
"}",
"return",
"jvmCount",
";",
"}"
] | Determine how many forked JVMs to use. | [
"Determine",
"how",
"many",
"forked",
"JVMs",
"to",
"use",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L1345-L1378 |
164,389 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.escapeAndJoin | private String escapeAndJoin(String[] commandline) {
// TODO: we should try to escape special characters here, depending on the OS.
StringBuilder b = new StringBuilder();
Pattern specials = Pattern.compile("[\\ ]");
for (String arg : commandline) {
if (b.length() > 0) {
b.append(" ");
}
if (specials.matcher(arg).find()) {
b.append('"').append(arg).append('"');
} else {
b.append(arg);
}
}
return b.toString();
} | java | private String escapeAndJoin(String[] commandline) {
// TODO: we should try to escape special characters here, depending on the OS.
StringBuilder b = new StringBuilder();
Pattern specials = Pattern.compile("[\\ ]");
for (String arg : commandline) {
if (b.length() > 0) {
b.append(" ");
}
if (specials.matcher(arg).find()) {
b.append('"').append(arg).append('"');
} else {
b.append(arg);
}
}
return b.toString();
} | [
"private",
"String",
"escapeAndJoin",
"(",
"String",
"[",
"]",
"commandline",
")",
"{",
"// TODO: we should try to escape special characters here, depending on the OS.",
"StringBuilder",
"b",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Pattern",
"specials",
"=",
"Pattern",
".",
"compile",
"(",
"\"[\\\\ ]\"",
")",
";",
"for",
"(",
"String",
"arg",
":",
"commandline",
")",
"{",
"if",
"(",
"b",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"b",
".",
"append",
"(",
"\" \"",
")",
";",
"}",
"if",
"(",
"specials",
".",
"matcher",
"(",
"arg",
")",
".",
"find",
"(",
")",
")",
"{",
"b",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"arg",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"b",
".",
"append",
"(",
"arg",
")",
";",
"}",
"}",
"return",
"b",
".",
"toString",
"(",
")",
";",
"}"
] | Try to provide an escaped, ready-to-use shell line to repeat a given command line. | [
"Try",
"to",
"provide",
"an",
"escaped",
"ready",
"-",
"to",
"-",
"use",
"shell",
"line",
"to",
"repeat",
"a",
"given",
"command",
"line",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L1617-L1633 |
164,390 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.forkProcess | @SuppressForbidden("legitimate sysstreams.")
private Execute forkProcess(ForkedJvmInfo slaveInfo, EventBus eventBus,
CommandlineJava commandline,
TailInputStream eventStream, OutputStream sysout, OutputStream syserr, RandomAccessFile streamsBuffer) {
try {
String tempDir = commandline.getSystemProperties().getVariablesVector().stream()
.filter(v -> v.getKey().equals("java.io.tmpdir"))
.map(v -> v.getValue())
.findAny()
.orElse(null);
final LocalSlaveStreamHandler streamHandler =
new LocalSlaveStreamHandler(
eventBus, testsClassLoader, System.err, eventStream,
sysout, syserr, heartbeat, streamsBuffer);
// Add certain properties to allow identification of the forked JVM from within
// the subprocess. This can be used for policy files etc.
final Path cwd = getWorkingDirectory(slaveInfo, tempDir);
Variable v = new Variable();
v.setKey(CHILDVM_SYSPROP_CWD);
v.setFile(cwd.toAbsolutePath().normalize().toFile());
commandline.addSysproperty(v);
v = new Variable();
v.setKey(SYSPROP_TEMPDIR);
v.setFile(getTempDir().toAbsolutePath().normalize().toFile());
commandline.addSysproperty(v);
v = new Variable();
v.setKey(SysGlobals.CHILDVM_SYSPROP_JVM_ID);
v.setValue(Integer.toString(slaveInfo.id));
commandline.addSysproperty(v);
v = new Variable();
v.setKey(SysGlobals.CHILDVM_SYSPROP_JVM_COUNT);
v.setValue(Integer.toString(slaveInfo.slaves));
commandline.addSysproperty(v);
// Emit command line before -stdin to avoid confusion.
slaveInfo.slaveCommandLine = escapeAndJoin(commandline.getCommandline());
log("Forked child JVM at '" + cwd.toAbsolutePath().normalize() +
"', command (may need escape sequences for your shell):\n" +
slaveInfo.slaveCommandLine, Project.MSG_VERBOSE);
final Execute execute = new Execute();
execute.setCommandline(commandline.getCommandline());
execute.setVMLauncher(true);
execute.setWorkingDirectory(cwd.toFile());
execute.setStreamHandler(streamHandler);
execute.setNewenvironment(newEnvironment);
if (env.getVariables() != null)
execute.setEnvironment(env.getVariables());
log("Starting JVM J" + slaveInfo.id, Project.MSG_DEBUG);
execute.execute();
return execute;
} catch (IOException e) {
throw new BuildException("Could not start the child process. Run ant with -verbose to get" +
" the execution details.", e);
}
} | java | @SuppressForbidden("legitimate sysstreams.")
private Execute forkProcess(ForkedJvmInfo slaveInfo, EventBus eventBus,
CommandlineJava commandline,
TailInputStream eventStream, OutputStream sysout, OutputStream syserr, RandomAccessFile streamsBuffer) {
try {
String tempDir = commandline.getSystemProperties().getVariablesVector().stream()
.filter(v -> v.getKey().equals("java.io.tmpdir"))
.map(v -> v.getValue())
.findAny()
.orElse(null);
final LocalSlaveStreamHandler streamHandler =
new LocalSlaveStreamHandler(
eventBus, testsClassLoader, System.err, eventStream,
sysout, syserr, heartbeat, streamsBuffer);
// Add certain properties to allow identification of the forked JVM from within
// the subprocess. This can be used for policy files etc.
final Path cwd = getWorkingDirectory(slaveInfo, tempDir);
Variable v = new Variable();
v.setKey(CHILDVM_SYSPROP_CWD);
v.setFile(cwd.toAbsolutePath().normalize().toFile());
commandline.addSysproperty(v);
v = new Variable();
v.setKey(SYSPROP_TEMPDIR);
v.setFile(getTempDir().toAbsolutePath().normalize().toFile());
commandline.addSysproperty(v);
v = new Variable();
v.setKey(SysGlobals.CHILDVM_SYSPROP_JVM_ID);
v.setValue(Integer.toString(slaveInfo.id));
commandline.addSysproperty(v);
v = new Variable();
v.setKey(SysGlobals.CHILDVM_SYSPROP_JVM_COUNT);
v.setValue(Integer.toString(slaveInfo.slaves));
commandline.addSysproperty(v);
// Emit command line before -stdin to avoid confusion.
slaveInfo.slaveCommandLine = escapeAndJoin(commandline.getCommandline());
log("Forked child JVM at '" + cwd.toAbsolutePath().normalize() +
"', command (may need escape sequences for your shell):\n" +
slaveInfo.slaveCommandLine, Project.MSG_VERBOSE);
final Execute execute = new Execute();
execute.setCommandline(commandline.getCommandline());
execute.setVMLauncher(true);
execute.setWorkingDirectory(cwd.toFile());
execute.setStreamHandler(streamHandler);
execute.setNewenvironment(newEnvironment);
if (env.getVariables() != null)
execute.setEnvironment(env.getVariables());
log("Starting JVM J" + slaveInfo.id, Project.MSG_DEBUG);
execute.execute();
return execute;
} catch (IOException e) {
throw new BuildException("Could not start the child process. Run ant with -verbose to get" +
" the execution details.", e);
}
} | [
"@",
"SuppressForbidden",
"(",
"\"legitimate sysstreams.\"",
")",
"private",
"Execute",
"forkProcess",
"(",
"ForkedJvmInfo",
"slaveInfo",
",",
"EventBus",
"eventBus",
",",
"CommandlineJava",
"commandline",
",",
"TailInputStream",
"eventStream",
",",
"OutputStream",
"sysout",
",",
"OutputStream",
"syserr",
",",
"RandomAccessFile",
"streamsBuffer",
")",
"{",
"try",
"{",
"String",
"tempDir",
"=",
"commandline",
".",
"getSystemProperties",
"(",
")",
".",
"getVariablesVector",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"v",
"->",
"v",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"\"java.io.tmpdir\"",
")",
")",
".",
"map",
"(",
"v",
"->",
"v",
".",
"getValue",
"(",
")",
")",
".",
"findAny",
"(",
")",
".",
"orElse",
"(",
"null",
")",
";",
"final",
"LocalSlaveStreamHandler",
"streamHandler",
"=",
"new",
"LocalSlaveStreamHandler",
"(",
"eventBus",
",",
"testsClassLoader",
",",
"System",
".",
"err",
",",
"eventStream",
",",
"sysout",
",",
"syserr",
",",
"heartbeat",
",",
"streamsBuffer",
")",
";",
"// Add certain properties to allow identification of the forked JVM from within",
"// the subprocess. This can be used for policy files etc.",
"final",
"Path",
"cwd",
"=",
"getWorkingDirectory",
"(",
"slaveInfo",
",",
"tempDir",
")",
";",
"Variable",
"v",
"=",
"new",
"Variable",
"(",
")",
";",
"v",
".",
"setKey",
"(",
"CHILDVM_SYSPROP_CWD",
")",
";",
"v",
".",
"setFile",
"(",
"cwd",
".",
"toAbsolutePath",
"(",
")",
".",
"normalize",
"(",
")",
".",
"toFile",
"(",
")",
")",
";",
"commandline",
".",
"addSysproperty",
"(",
"v",
")",
";",
"v",
"=",
"new",
"Variable",
"(",
")",
";",
"v",
".",
"setKey",
"(",
"SYSPROP_TEMPDIR",
")",
";",
"v",
".",
"setFile",
"(",
"getTempDir",
"(",
")",
".",
"toAbsolutePath",
"(",
")",
".",
"normalize",
"(",
")",
".",
"toFile",
"(",
")",
")",
";",
"commandline",
".",
"addSysproperty",
"(",
"v",
")",
";",
"v",
"=",
"new",
"Variable",
"(",
")",
";",
"v",
".",
"setKey",
"(",
"SysGlobals",
".",
"CHILDVM_SYSPROP_JVM_ID",
")",
";",
"v",
".",
"setValue",
"(",
"Integer",
".",
"toString",
"(",
"slaveInfo",
".",
"id",
")",
")",
";",
"commandline",
".",
"addSysproperty",
"(",
"v",
")",
";",
"v",
"=",
"new",
"Variable",
"(",
")",
";",
"v",
".",
"setKey",
"(",
"SysGlobals",
".",
"CHILDVM_SYSPROP_JVM_COUNT",
")",
";",
"v",
".",
"setValue",
"(",
"Integer",
".",
"toString",
"(",
"slaveInfo",
".",
"slaves",
")",
")",
";",
"commandline",
".",
"addSysproperty",
"(",
"v",
")",
";",
"// Emit command line before -stdin to avoid confusion.",
"slaveInfo",
".",
"slaveCommandLine",
"=",
"escapeAndJoin",
"(",
"commandline",
".",
"getCommandline",
"(",
")",
")",
";",
"log",
"(",
"\"Forked child JVM at '\"",
"+",
"cwd",
".",
"toAbsolutePath",
"(",
")",
".",
"normalize",
"(",
")",
"+",
"\"', command (may need escape sequences for your shell):\\n\"",
"+",
"slaveInfo",
".",
"slaveCommandLine",
",",
"Project",
".",
"MSG_VERBOSE",
")",
";",
"final",
"Execute",
"execute",
"=",
"new",
"Execute",
"(",
")",
";",
"execute",
".",
"setCommandline",
"(",
"commandline",
".",
"getCommandline",
"(",
")",
")",
";",
"execute",
".",
"setVMLauncher",
"(",
"true",
")",
";",
"execute",
".",
"setWorkingDirectory",
"(",
"cwd",
".",
"toFile",
"(",
")",
")",
";",
"execute",
".",
"setStreamHandler",
"(",
"streamHandler",
")",
";",
"execute",
".",
"setNewenvironment",
"(",
"newEnvironment",
")",
";",
"if",
"(",
"env",
".",
"getVariables",
"(",
")",
"!=",
"null",
")",
"execute",
".",
"setEnvironment",
"(",
"env",
".",
"getVariables",
"(",
")",
")",
";",
"log",
"(",
"\"Starting JVM J\"",
"+",
"slaveInfo",
".",
"id",
",",
"Project",
".",
"MSG_DEBUG",
")",
";",
"execute",
".",
"execute",
"(",
")",
";",
"return",
"execute",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Could not start the child process. Run ant with -verbose to get\"",
"+",
"\" the execution details.\"",
",",
"e",
")",
";",
"}",
"}"
] | Execute a slave process. Pump events to the given event bus. | [
"Execute",
"a",
"slave",
"process",
".",
"Pump",
"events",
"to",
"the",
"given",
"event",
"bus",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L1638-L1699 |
164,391 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.getTempDir | private Path getTempDir() {
if (this.tempDir == null) {
if (this.dir != null) {
this.tempDir = dir;
} else {
this.tempDir = getProject().getBaseDir().toPath();
}
}
return tempDir;
} | java | private Path getTempDir() {
if (this.tempDir == null) {
if (this.dir != null) {
this.tempDir = dir;
} else {
this.tempDir = getProject().getBaseDir().toPath();
}
}
return tempDir;
} | [
"private",
"Path",
"getTempDir",
"(",
")",
"{",
"if",
"(",
"this",
".",
"tempDir",
"==",
"null",
")",
"{",
"if",
"(",
"this",
".",
"dir",
"!=",
"null",
")",
"{",
"this",
".",
"tempDir",
"=",
"dir",
";",
"}",
"else",
"{",
"this",
".",
"tempDir",
"=",
"getProject",
"(",
")",
".",
"getBaseDir",
"(",
")",
".",
"toPath",
"(",
")",
";",
"}",
"}",
"return",
"tempDir",
";",
"}"
] | Resolve temporary folder. | [
"Resolve",
"temporary",
"folder",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L1774-L1783 |
164,392 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java | JUnit4.addSlaveClasspath | private org.apache.tools.ant.types.Path addSlaveClasspath() {
org.apache.tools.ant.types.Path path = new org.apache.tools.ant.types.Path(getProject());
String [] REQUIRED_SLAVE_CLASSES = {
SlaveMain.class.getName(),
Strings.class.getName(),
MethodGlobFilter.class.getName(),
TeeOutputStream.class.getName()
};
for (String clazz : Arrays.asList(REQUIRED_SLAVE_CLASSES)) {
String resource = clazz.replace(".", "/") + ".class";
File f = LoaderUtils.getResourceSource(getClass().getClassLoader(), resource);
if (f != null) {
path.createPath().setLocation(f);
} else {
throw new BuildException("Could not locate classpath for resource: " + resource);
}
}
return path;
} | java | private org.apache.tools.ant.types.Path addSlaveClasspath() {
org.apache.tools.ant.types.Path path = new org.apache.tools.ant.types.Path(getProject());
String [] REQUIRED_SLAVE_CLASSES = {
SlaveMain.class.getName(),
Strings.class.getName(),
MethodGlobFilter.class.getName(),
TeeOutputStream.class.getName()
};
for (String clazz : Arrays.asList(REQUIRED_SLAVE_CLASSES)) {
String resource = clazz.replace(".", "/") + ".class";
File f = LoaderUtils.getResourceSource(getClass().getClassLoader(), resource);
if (f != null) {
path.createPath().setLocation(f);
} else {
throw new BuildException("Could not locate classpath for resource: " + resource);
}
}
return path;
} | [
"private",
"org",
".",
"apache",
".",
"tools",
".",
"ant",
".",
"types",
".",
"Path",
"addSlaveClasspath",
"(",
")",
"{",
"org",
".",
"apache",
".",
"tools",
".",
"ant",
".",
"types",
".",
"Path",
"path",
"=",
"new",
"org",
".",
"apache",
".",
"tools",
".",
"ant",
".",
"types",
".",
"Path",
"(",
"getProject",
"(",
")",
")",
";",
"String",
"[",
"]",
"REQUIRED_SLAVE_CLASSES",
"=",
"{",
"SlaveMain",
".",
"class",
".",
"getName",
"(",
")",
",",
"Strings",
".",
"class",
".",
"getName",
"(",
")",
",",
"MethodGlobFilter",
".",
"class",
".",
"getName",
"(",
")",
",",
"TeeOutputStream",
".",
"class",
".",
"getName",
"(",
")",
"}",
";",
"for",
"(",
"String",
"clazz",
":",
"Arrays",
".",
"asList",
"(",
"REQUIRED_SLAVE_CLASSES",
")",
")",
"{",
"String",
"resource",
"=",
"clazz",
".",
"replace",
"(",
"\".\"",
",",
"\"/\"",
")",
"+",
"\".class\"",
";",
"File",
"f",
"=",
"LoaderUtils",
".",
"getResourceSource",
"(",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
",",
"resource",
")",
";",
"if",
"(",
"f",
"!=",
"null",
")",
"{",
"path",
".",
"createPath",
"(",
")",
".",
"setLocation",
"(",
"f",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Could not locate classpath for resource: \"",
"+",
"resource",
")",
";",
"}",
"}",
"return",
"path",
";",
"}"
] | Adds a classpath source which contains the given resource.
TODO: [GH-213] this is extremely ugly; separate the code required to run on the
forked JVM into an isolated bundle and either create it on-demand (in temp.
files location?) or locate it in classpath somehow (in a portable way). | [
"Adds",
"a",
"classpath",
"source",
"which",
"contains",
"the",
"given",
"resource",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/JUnit4.java#L1891-L1911 |
164,393 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/PickFromListTask.java | PickFromListTask.validate | private void validate() {
if (Strings.emptyToNull(random) == null) {
random = Strings.emptyToNull(getProject().getProperty(SYSPROP_RANDOM_SEED()));
}
if (random == null) {
throw new BuildException("Required attribute 'seed' must not be empty. Look at <junit4:pickseed>.");
}
long[] seeds = SeedUtils.parseSeedChain(random);
if (seeds.length < 1) {
throw new BuildException("Random seed is required.");
}
if (values.isEmpty() && !allowUndefined) {
throw new BuildException("No values to pick from and allowUndefined=false.");
}
} | java | private void validate() {
if (Strings.emptyToNull(random) == null) {
random = Strings.emptyToNull(getProject().getProperty(SYSPROP_RANDOM_SEED()));
}
if (random == null) {
throw new BuildException("Required attribute 'seed' must not be empty. Look at <junit4:pickseed>.");
}
long[] seeds = SeedUtils.parseSeedChain(random);
if (seeds.length < 1) {
throw new BuildException("Random seed is required.");
}
if (values.isEmpty() && !allowUndefined) {
throw new BuildException("No values to pick from and allowUndefined=false.");
}
} | [
"private",
"void",
"validate",
"(",
")",
"{",
"if",
"(",
"Strings",
".",
"emptyToNull",
"(",
"random",
")",
"==",
"null",
")",
"{",
"random",
"=",
"Strings",
".",
"emptyToNull",
"(",
"getProject",
"(",
")",
".",
"getProperty",
"(",
"SYSPROP_RANDOM_SEED",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"random",
"==",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Required attribute 'seed' must not be empty. Look at <junit4:pickseed>.\"",
")",
";",
"}",
"long",
"[",
"]",
"seeds",
"=",
"SeedUtils",
".",
"parseSeedChain",
"(",
"random",
")",
";",
"if",
"(",
"seeds",
".",
"length",
"<",
"1",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Random seed is required.\"",
")",
";",
"}",
"if",
"(",
"values",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"allowUndefined",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"No values to pick from and allowUndefined=false.\"",
")",
";",
"}",
"}"
] | Validate arguments and state. | [
"Validate",
"arguments",
"and",
"state",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/PickFromListTask.java#L115-L132 |
164,394 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/balancers/TopHints.java | TopHints.add | public void add(ResourceCollection rc) {
if (rc instanceof FileSet) {
FileSet fs = (FileSet) rc;
fs.setProject(getProject());
}
resources.add(rc);
} | java | public void add(ResourceCollection rc) {
if (rc instanceof FileSet) {
FileSet fs = (FileSet) rc;
fs.setProject(getProject());
}
resources.add(rc);
} | [
"public",
"void",
"add",
"(",
"ResourceCollection",
"rc",
")",
"{",
"if",
"(",
"rc",
"instanceof",
"FileSet",
")",
"{",
"FileSet",
"fs",
"=",
"(",
"FileSet",
")",
"rc",
";",
"fs",
".",
"setProject",
"(",
"getProject",
"(",
")",
")",
";",
"}",
"resources",
".",
"add",
"(",
"rc",
")",
";",
"}"
] | Adds a resource collection with execution hints. | [
"Adds",
"a",
"resource",
"collection",
"with",
"execution",
"hints",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/balancers/TopHints.java#L61-L67 |
164,395 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/slave/SlaveMainSafe.java | SlaveMainSafe.verifyJUnit4Present | private static void verifyJUnit4Present() {
try {
Class<?> clazz = Class.forName("org.junit.runner.Description");
if (!Serializable.class.isAssignableFrom(clazz)) {
JvmExit.halt(SlaveMain.ERR_OLD_JUNIT);
}
} catch (ClassNotFoundException e) {
JvmExit.halt(SlaveMain.ERR_NO_JUNIT);
}
} | java | private static void verifyJUnit4Present() {
try {
Class<?> clazz = Class.forName("org.junit.runner.Description");
if (!Serializable.class.isAssignableFrom(clazz)) {
JvmExit.halt(SlaveMain.ERR_OLD_JUNIT);
}
} catch (ClassNotFoundException e) {
JvmExit.halt(SlaveMain.ERR_NO_JUNIT);
}
} | [
"private",
"static",
"void",
"verifyJUnit4Present",
"(",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"\"org.junit.runner.Description\"",
")",
";",
"if",
"(",
"!",
"Serializable",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
")",
"{",
"JvmExit",
".",
"halt",
"(",
"SlaveMain",
".",
"ERR_OLD_JUNIT",
")",
";",
"}",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"JvmExit",
".",
"halt",
"(",
"SlaveMain",
".",
"ERR_NO_JUNIT",
")",
";",
"}",
"}"
] | Verify JUnit presence and version. | [
"Verify",
"JUnit",
"presence",
"and",
"version",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/slave/SlaveMainSafe.java#L29-L38 |
164,396 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/TextReport.java | TextReport.setShowOutput | public void setShowOutput(String mode) {
try {
this.outputMode = OutputMode.valueOf(mode.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("showOutput accepts any of: "
+ Arrays.toString(OutputMode.values()) + ", value is not valid: " + mode);
}
} | java | public void setShowOutput(String mode) {
try {
this.outputMode = OutputMode.valueOf(mode.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("showOutput accepts any of: "
+ Arrays.toString(OutputMode.values()) + ", value is not valid: " + mode);
}
} | [
"public",
"void",
"setShowOutput",
"(",
"String",
"mode",
")",
"{",
"try",
"{",
"this",
".",
"outputMode",
"=",
"OutputMode",
".",
"valueOf",
"(",
"mode",
".",
"toUpperCase",
"(",
"Locale",
".",
"ROOT",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"showOutput accepts any of: \"",
"+",
"Arrays",
".",
"toString",
"(",
"OutputMode",
".",
"values",
"(",
")",
")",
"+",
"\", value is not valid: \"",
"+",
"mode",
")",
";",
"}",
"}"
] | Display mode for output streams. | [
"Display",
"mode",
"for",
"output",
"streams",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/TextReport.java#L271-L278 |
164,397 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/TextReport.java | TextReport.flushOutput | private void flushOutput() throws IOException {
outStream.flush();
outWriter.completeLine();
errStream.flush();
errWriter.completeLine();
} | java | private void flushOutput() throws IOException {
outStream.flush();
outWriter.completeLine();
errStream.flush();
errWriter.completeLine();
} | [
"private",
"void",
"flushOutput",
"(",
")",
"throws",
"IOException",
"{",
"outStream",
".",
"flush",
"(",
")",
";",
"outWriter",
".",
"completeLine",
"(",
")",
";",
"errStream",
".",
"flush",
"(",
")",
";",
"errWriter",
".",
"completeLine",
"(",
")",
";",
"}"
] | Flush output streams. | [
"Flush",
"output",
"streams",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/TextReport.java#L543-L548 |
164,398 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/TextReport.java | TextReport.emitSuiteStart | private void emitSuiteStart(Description description, long startTimestamp) throws IOException {
String suiteName = description.getDisplayName();
if (useSimpleNames) {
if (suiteName.lastIndexOf('.') >= 0) {
suiteName = suiteName.substring(suiteName.lastIndexOf('.') + 1);
}
}
logShort(shortTimestamp(startTimestamp) +
"Suite: " +
FormattingUtils.padTo(maxClassNameColumns, suiteName, "[...]"));
} | java | private void emitSuiteStart(Description description, long startTimestamp) throws IOException {
String suiteName = description.getDisplayName();
if (useSimpleNames) {
if (suiteName.lastIndexOf('.') >= 0) {
suiteName = suiteName.substring(suiteName.lastIndexOf('.') + 1);
}
}
logShort(shortTimestamp(startTimestamp) +
"Suite: " +
FormattingUtils.padTo(maxClassNameColumns, suiteName, "[...]"));
} | [
"private",
"void",
"emitSuiteStart",
"(",
"Description",
"description",
",",
"long",
"startTimestamp",
")",
"throws",
"IOException",
"{",
"String",
"suiteName",
"=",
"description",
".",
"getDisplayName",
"(",
")",
";",
"if",
"(",
"useSimpleNames",
")",
"{",
"if",
"(",
"suiteName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
">=",
"0",
")",
"{",
"suiteName",
"=",
"suiteName",
".",
"substring",
"(",
"suiteName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"}",
"}",
"logShort",
"(",
"shortTimestamp",
"(",
"startTimestamp",
")",
"+",
"\"Suite: \"",
"+",
"FormattingUtils",
".",
"padTo",
"(",
"maxClassNameColumns",
",",
"suiteName",
",",
"\"[...]\"",
")",
")",
";",
"}"
] | Suite prologue. | [
"Suite",
"prologue",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/TextReport.java#L553-L563 |
164,399 | randomizedtesting/randomizedtesting | junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/TextReport.java | TextReport.emitSuiteEnd | private void emitSuiteEnd(AggregatedSuiteResultEvent e, int suitesCompleted) throws IOException {
assert showSuiteSummary;
final StringBuilder b = new StringBuilder();
final int totalErrors = this.totalErrors.addAndGet(e.isSuccessful() ? 0 : 1);
b.append(String.format(Locale.ROOT, "%sCompleted [%d/%d%s]%s in %.2fs, ",
shortTimestamp(e.getStartTimestamp() + e.getExecutionTime()),
suitesCompleted,
totalSuites,
totalErrors == 0 ? "" : " (" + totalErrors + "!)",
e.getSlave().slaves > 1 ? " on J" + e.getSlave().id : "",
e.getExecutionTime() / 1000.0d));
b.append(e.getTests().size()).append(Pluralize.pluralize(e.getTests().size(), " test"));
int failures = e.getFailureCount();
if (failures > 0) {
b.append(", ").append(failures).append(Pluralize.pluralize(failures, " failure"));
}
int errors = e.getErrorCount();
if (errors > 0) {
b.append(", ").append(errors).append(Pluralize.pluralize(errors, " error"));
}
int ignored = e.getIgnoredCount();
if (ignored > 0) {
b.append(", ").append(ignored).append(" skipped");
}
if (!e.isSuccessful()) {
b.append(FAILURE_STRING);
}
b.append("\n");
logShort(b, false);
} | java | private void emitSuiteEnd(AggregatedSuiteResultEvent e, int suitesCompleted) throws IOException {
assert showSuiteSummary;
final StringBuilder b = new StringBuilder();
final int totalErrors = this.totalErrors.addAndGet(e.isSuccessful() ? 0 : 1);
b.append(String.format(Locale.ROOT, "%sCompleted [%d/%d%s]%s in %.2fs, ",
shortTimestamp(e.getStartTimestamp() + e.getExecutionTime()),
suitesCompleted,
totalSuites,
totalErrors == 0 ? "" : " (" + totalErrors + "!)",
e.getSlave().slaves > 1 ? " on J" + e.getSlave().id : "",
e.getExecutionTime() / 1000.0d));
b.append(e.getTests().size()).append(Pluralize.pluralize(e.getTests().size(), " test"));
int failures = e.getFailureCount();
if (failures > 0) {
b.append(", ").append(failures).append(Pluralize.pluralize(failures, " failure"));
}
int errors = e.getErrorCount();
if (errors > 0) {
b.append(", ").append(errors).append(Pluralize.pluralize(errors, " error"));
}
int ignored = e.getIgnoredCount();
if (ignored > 0) {
b.append(", ").append(ignored).append(" skipped");
}
if (!e.isSuccessful()) {
b.append(FAILURE_STRING);
}
b.append("\n");
logShort(b, false);
} | [
"private",
"void",
"emitSuiteEnd",
"(",
"AggregatedSuiteResultEvent",
"e",
",",
"int",
"suitesCompleted",
")",
"throws",
"IOException",
"{",
"assert",
"showSuiteSummary",
";",
"final",
"StringBuilder",
"b",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"int",
"totalErrors",
"=",
"this",
".",
"totalErrors",
".",
"addAndGet",
"(",
"e",
".",
"isSuccessful",
"(",
")",
"?",
"0",
":",
"1",
")",
";",
"b",
".",
"append",
"(",
"String",
".",
"format",
"(",
"Locale",
".",
"ROOT",
",",
"\"%sCompleted [%d/%d%s]%s in %.2fs, \"",
",",
"shortTimestamp",
"(",
"e",
".",
"getStartTimestamp",
"(",
")",
"+",
"e",
".",
"getExecutionTime",
"(",
")",
")",
",",
"suitesCompleted",
",",
"totalSuites",
",",
"totalErrors",
"==",
"0",
"?",
"\"\"",
":",
"\" (\"",
"+",
"totalErrors",
"+",
"\"!)\"",
",",
"e",
".",
"getSlave",
"(",
")",
".",
"slaves",
">",
"1",
"?",
"\" on J\"",
"+",
"e",
".",
"getSlave",
"(",
")",
".",
"id",
":",
"\"\"",
",",
"e",
".",
"getExecutionTime",
"(",
")",
"/",
"1000.0d",
")",
")",
";",
"b",
".",
"append",
"(",
"e",
".",
"getTests",
"(",
")",
".",
"size",
"(",
")",
")",
".",
"append",
"(",
"Pluralize",
".",
"pluralize",
"(",
"e",
".",
"getTests",
"(",
")",
".",
"size",
"(",
")",
",",
"\" test\"",
")",
")",
";",
"int",
"failures",
"=",
"e",
".",
"getFailureCount",
"(",
")",
";",
"if",
"(",
"failures",
">",
"0",
")",
"{",
"b",
".",
"append",
"(",
"\", \"",
")",
".",
"append",
"(",
"failures",
")",
".",
"append",
"(",
"Pluralize",
".",
"pluralize",
"(",
"failures",
",",
"\" failure\"",
")",
")",
";",
"}",
"int",
"errors",
"=",
"e",
".",
"getErrorCount",
"(",
")",
";",
"if",
"(",
"errors",
">",
"0",
")",
"{",
"b",
".",
"append",
"(",
"\", \"",
")",
".",
"append",
"(",
"errors",
")",
".",
"append",
"(",
"Pluralize",
".",
"pluralize",
"(",
"errors",
",",
"\" error\"",
")",
")",
";",
"}",
"int",
"ignored",
"=",
"e",
".",
"getIgnoredCount",
"(",
")",
";",
"if",
"(",
"ignored",
">",
"0",
")",
"{",
"b",
".",
"append",
"(",
"\", \"",
")",
".",
"append",
"(",
"ignored",
")",
".",
"append",
"(",
"\" skipped\"",
")",
";",
"}",
"if",
"(",
"!",
"e",
".",
"isSuccessful",
"(",
")",
")",
"{",
"b",
".",
"append",
"(",
"FAILURE_STRING",
")",
";",
"}",
"b",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"logShort",
"(",
"b",
",",
"false",
")",
";",
"}"
] | Suite end. | [
"Suite",
"end",
"."
] | 85a0c7eff5d03d98da4d1f9502a11af74d26478a | https://github.com/randomizedtesting/randomizedtesting/blob/85a0c7eff5d03d98da4d1f9502a11af74d26478a/junit4-ant/src/main/java/com/carrotsearch/ant/tasks/junit4/listeners/TextReport.java#L568-L603 |
Subsets and Splits