id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
4,000 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.open
|
public boolean open(boolean anim) {
if (!mEnabled) {
return false;
}
if (mOpened) {
return true;
}
if (!mShowing) {
show();
}
if (anim) {
animateOpen();
} else {
onEndOpen();
}
return true;
}
|
java
|
public boolean open(boolean anim) {
if (!mEnabled) {
return false;
}
if (mOpened) {
return true;
}
if (!mShowing) {
show();
}
if (anim) {
animateOpen();
} else {
onEndOpen();
}
return true;
}
|
[
"public",
"boolean",
"open",
"(",
"boolean",
"anim",
")",
"{",
"if",
"(",
"!",
"mEnabled",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"mOpened",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"mShowing",
")",
"{",
"show",
"(",
")",
";",
"}",
"if",
"(",
"anim",
")",
"{",
"animateOpen",
"(",
")",
";",
"}",
"else",
"{",
"onEndOpen",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Open the board.
@param anim pull-down animation.
@return boolean false, if the board is disabled.
|
[
"Open",
"the",
"board",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L385-L404
|
4,001 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setInitialTouchArea
|
public void setInitialTouchArea(int l, int t, int r, int b) {
mContentView.setTouchToOpen(l, t, r, b);
}
|
java
|
public void setInitialTouchArea(int l, int t, int r, int b) {
mContentView.setTouchToOpen(l, t, r, b);
}
|
[
"public",
"void",
"setInitialTouchArea",
"(",
"int",
"l",
",",
"int",
"t",
",",
"int",
"r",
",",
"int",
"b",
")",
"{",
"mContentView",
".",
"setTouchToOpen",
"(",
"l",
",",
"t",
",",
"r",
",",
"b",
")",
";",
"}"
] |
Set the touch area where the user can touch to pull the board down.
@param l
@param t
@param r
@param b
|
[
"Set",
"the",
"touch",
"area",
"where",
"the",
"user",
"can",
"touch",
"to",
"pull",
"the",
"board",
"down",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L544-L546
|
4,002 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setHeaderMargin
|
public void setHeaderMargin(int l, int t, int r, int b) {
mHeader.setMargin(l, t, r, b);
}
|
java
|
public void setHeaderMargin(int l, int t, int r, int b) {
mHeader.setMargin(l, t, r, b);
}
|
[
"public",
"void",
"setHeaderMargin",
"(",
"int",
"l",
",",
"int",
"t",
",",
"int",
"r",
",",
"int",
"b",
")",
"{",
"mHeader",
".",
"setMargin",
"(",
"l",
",",
"t",
",",
"r",
",",
"b",
")",
";",
"}"
] |
Set the margin of the header.
@param l
@param t
@param r
@param b
|
[
"Set",
"the",
"margin",
"of",
"the",
"header",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L556-L558
|
4,003 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setFooterMargin
|
public void setFooterMargin(int l, int t, int r, int b) {
mFooter.setMargin(l, t, r, b);
}
|
java
|
public void setFooterMargin(int l, int t, int r, int b) {
mFooter.setMargin(l, t, r, b);
}
|
[
"public",
"void",
"setFooterMargin",
"(",
"int",
"l",
",",
"int",
"t",
",",
"int",
"r",
",",
"int",
"b",
")",
"{",
"mFooter",
".",
"setMargin",
"(",
"l",
",",
"t",
",",
"r",
",",
"b",
")",
";",
"}"
] |
Set the margin of the footer.
@param l
@param t
@param r
@param b
|
[
"Set",
"the",
"margin",
"of",
"the",
"footer",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L568-L570
|
4,004 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setBodyMargin
|
public void setBodyMargin(int l, int t, int r, int b) {
mBody.setMargin(l, t, r, b);
}
|
java
|
public void setBodyMargin(int l, int t, int r, int b) {
mBody.setMargin(l, t, r, b);
}
|
[
"public",
"void",
"setBodyMargin",
"(",
"int",
"l",
",",
"int",
"t",
",",
"int",
"r",
",",
"int",
"b",
")",
"{",
"mBody",
".",
"setMargin",
"(",
"l",
",",
"t",
",",
"r",
",",
"b",
")",
";",
"}"
] |
Set the margin of the body.
@param l
@param t
@param r
@param b
|
[
"Set",
"the",
"margin",
"of",
"the",
"body",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L580-L582
|
4,005 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setRowMargin
|
public void setRowMargin(int l, int t, int r, int b) {
mRowMargin[0] = l; mRowMargin[1] = t; mRowMargin[2] = r; mRowMargin[3] = b;
}
|
java
|
public void setRowMargin(int l, int t, int r, int b) {
mRowMargin[0] = l; mRowMargin[1] = t; mRowMargin[2] = r; mRowMargin[3] = b;
}
|
[
"public",
"void",
"setRowMargin",
"(",
"int",
"l",
",",
"int",
"t",
",",
"int",
"r",
",",
"int",
"b",
")",
"{",
"mRowMargin",
"[",
"0",
"]",
"=",
"l",
";",
"mRowMargin",
"[",
"1",
"]",
"=",
"t",
";",
"mRowMargin",
"[",
"2",
"]",
"=",
"r",
";",
"mRowMargin",
"[",
"3",
"]",
"=",
"b",
";",
"}"
] |
Set the margin of each row.
@param l
@param t
@param r
@param b
|
[
"Set",
"the",
"margin",
"of",
"each",
"row",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L592-L594
|
4,006 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.addHeaderView
|
public void addHeaderView(View view, int index, ViewGroup.LayoutParams lp) {
mHeader.addView(view, index, lp);
}
|
java
|
public void addHeaderView(View view, int index, ViewGroup.LayoutParams lp) {
mHeader.addView(view, index, lp);
}
|
[
"public",
"void",
"addHeaderView",
"(",
"View",
"view",
",",
"int",
"index",
",",
"ViewGroup",
".",
"LayoutParams",
"lp",
")",
"{",
"mHeader",
".",
"addView",
"(",
"view",
",",
"index",
",",
"lp",
")",
";",
"}"
] |
Add header view.
@param view
@param index
@param lp
|
[
"Add",
"header",
"view",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L666-L668
|
4,007 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.addFooterView
|
public void addFooterView(View view, int index, ViewGroup.LayoutParams lp) {
mFooter.addView(view, index, lp);
}
|
java
|
public void addFooterView(View view, int index, ViewGroup.LayoutParams lp) {
mFooter.addView(view, index, lp);
}
|
[
"public",
"void",
"addFooterView",
"(",
"View",
"view",
",",
"int",
"index",
",",
"ViewGroup",
".",
"LayoutParams",
"lp",
")",
"{",
"mFooter",
".",
"addView",
"(",
"view",
",",
"index",
",",
"lp",
")",
";",
"}"
] |
Add footer view.
@param view
@param index
@param lp
|
[
"Add",
"footer",
"view",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L714-L716
|
4,008 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.addBodyView
|
public void addBodyView(View view, int index, ViewGroup.LayoutParams lp) {
mBody.addView(view, index, lp);
}
|
java
|
public void addBodyView(View view, int index, ViewGroup.LayoutParams lp) {
mBody.addView(view, index, lp);
}
|
[
"public",
"void",
"addBodyView",
"(",
"View",
"view",
",",
"int",
"index",
",",
"ViewGroup",
".",
"LayoutParams",
"lp",
")",
"{",
"mBody",
".",
"addView",
"(",
"view",
",",
"index",
",",
"lp",
")",
";",
"}"
] |
Add body view.
@param view
@param index
@param lp
|
[
"Add",
"body",
"view",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L762-L764
|
4,009 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setHeaderDivider
|
public void setHeaderDivider(Drawable drawable) {
mHeaderDivider = drawable;
if (drawable != null) {
mHeaderDividerHeight = drawable.getIntrinsicHeight();
} else {
mHeaderDividerHeight = 0;
}
mContentView.setWillNotDraw(drawable == null);
mContentView.invalidate();
}
|
java
|
public void setHeaderDivider(Drawable drawable) {
mHeaderDivider = drawable;
if (drawable != null) {
mHeaderDividerHeight = drawable.getIntrinsicHeight();
} else {
mHeaderDividerHeight = 0;
}
mContentView.setWillNotDraw(drawable == null);
mContentView.invalidate();
}
|
[
"public",
"void",
"setHeaderDivider",
"(",
"Drawable",
"drawable",
")",
"{",
"mHeaderDivider",
"=",
"drawable",
";",
"if",
"(",
"drawable",
"!=",
"null",
")",
"{",
"mHeaderDividerHeight",
"=",
"drawable",
".",
"getIntrinsicHeight",
"(",
")",
";",
"}",
"else",
"{",
"mHeaderDividerHeight",
"=",
"0",
";",
"}",
"mContentView",
".",
"setWillNotDraw",
"(",
"drawable",
"==",
"null",
")",
";",
"mContentView",
".",
"invalidate",
"(",
")",
";",
"}"
] |
Set header divider.
@param drawable
|
[
"Set",
"header",
"divider",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L808-L817
|
4,010 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setFooterDivider
|
public void setFooterDivider(Drawable drawable) {
mFooterDivider = drawable;
if (drawable != null) {
mFooterDividerHeight = drawable.getIntrinsicHeight();
} else {
mFooterDividerHeight = 0;
}
mContentView.setWillNotDraw(drawable == null);
mContentView.invalidate();
}
|
java
|
public void setFooterDivider(Drawable drawable) {
mFooterDivider = drawable;
if (drawable != null) {
mFooterDividerHeight = drawable.getIntrinsicHeight();
} else {
mFooterDividerHeight = 0;
}
mContentView.setWillNotDraw(drawable == null);
mContentView.invalidate();
}
|
[
"public",
"void",
"setFooterDivider",
"(",
"Drawable",
"drawable",
")",
"{",
"mFooterDivider",
"=",
"drawable",
";",
"if",
"(",
"drawable",
"!=",
"null",
")",
"{",
"mFooterDividerHeight",
"=",
"drawable",
".",
"getIntrinsicHeight",
"(",
")",
";",
"}",
"else",
"{",
"mFooterDividerHeight",
"=",
"0",
";",
"}",
"mContentView",
".",
"setWillNotDraw",
"(",
"drawable",
"==",
"null",
")",
";",
"mContentView",
".",
"invalidate",
"(",
")",
";",
"}"
] |
Set footer divider.
@param drawable
|
[
"Set",
"footer",
"divider",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L860-L869
|
4,011 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setClearView
|
public void setClearView(View view) {
mClearView = view;
if (view != null) {
view.setVisibility(mOpened ? VISIBLE : INVISIBLE);
view.setOnClickListener(mOnClickListenerClearView);
}
}
|
java
|
public void setClearView(View view) {
mClearView = view;
if (view != null) {
view.setVisibility(mOpened ? VISIBLE : INVISIBLE);
view.setOnClickListener(mOnClickListenerClearView);
}
}
|
[
"public",
"void",
"setClearView",
"(",
"View",
"view",
")",
"{",
"mClearView",
"=",
"view",
";",
"if",
"(",
"view",
"!=",
"null",
")",
"{",
"view",
".",
"setVisibility",
"(",
"mOpened",
"?",
"VISIBLE",
":",
"INVISIBLE",
")",
";",
"view",
".",
"setOnClickListener",
"(",
"mOnClickListenerClearView",
")",
";",
"}",
"}"
] |
Set clear view. If clicked, all notifications will be canceled.
@param view
|
[
"Set",
"clear",
"view",
".",
"If",
"clicked",
"all",
"notifications",
"will",
"be",
"canceled",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1023-L1029
|
4,012 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setBoardPadding
|
public void setBoardPadding(int l, int t, int r, int b) {
mContentView.setPadding(l, t, r, b);
}
|
java
|
public void setBoardPadding(int l, int t, int r, int b) {
mContentView.setPadding(l, t, r, b);
}
|
[
"public",
"void",
"setBoardPadding",
"(",
"int",
"l",
",",
"int",
"t",
",",
"int",
"r",
",",
"int",
"b",
")",
"{",
"mContentView",
".",
"setPadding",
"(",
"l",
",",
"t",
",",
"r",
",",
"b",
")",
";",
"}"
] |
Set the margin of the entire board.
@param l
@param t
@param r
@param b
|
[
"Set",
"the",
"margin",
"of",
"the",
"entire",
"board",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1087-L1089
|
4,013 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setBoardTranslationX
|
public void setBoardTranslationX(float x) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardTranslationX(this, x);
}
}
mContentView.setTranslationX(x);
}
|
java
|
public void setBoardTranslationX(float x) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardTranslationX(this, x);
}
}
mContentView.setTranslationX(x);
}
|
[
"public",
"void",
"setBoardTranslationX",
"(",
"float",
"x",
")",
"{",
"if",
"(",
"mListeners",
"!=",
"null",
")",
"{",
"for",
"(",
"StateListener",
"l",
":",
"mListeners",
")",
"{",
"l",
".",
"onBoardTranslationX",
"(",
"this",
",",
"x",
")",
";",
"}",
"}",
"mContentView",
".",
"setTranslationX",
"(",
"x",
")",
";",
"}"
] |
Set the x translation of this board.
@param x
|
[
"Set",
"the",
"x",
"translation",
"of",
"this",
"board",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1126-L1133
|
4,014 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setBoardTranslationY
|
public void setBoardTranslationY(float y) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardTranslationY(this, y);
}
}
mContentView.setTranslationY(y);
}
|
java
|
public void setBoardTranslationY(float y) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardTranslationY(this, y);
}
}
mContentView.setTranslationY(y);
}
|
[
"public",
"void",
"setBoardTranslationY",
"(",
"float",
"y",
")",
"{",
"if",
"(",
"mListeners",
"!=",
"null",
")",
"{",
"for",
"(",
"StateListener",
"l",
":",
"mListeners",
")",
"{",
"l",
".",
"onBoardTranslationY",
"(",
"this",
",",
"y",
")",
";",
"}",
"}",
"mContentView",
".",
"setTranslationY",
"(",
"y",
")",
";",
"}"
] |
Set the y translation of this board.
@param y
|
[
"Set",
"the",
"y",
"translation",
"of",
"this",
"board",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1149-L1156
|
4,015 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setBoardPivotX
|
public void setBoardPivotX(float x) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardPivotX(this, x);
}
}
mContentView.setPivotX(x);
}
|
java
|
public void setBoardPivotX(float x) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardPivotX(this, x);
}
}
mContentView.setPivotX(x);
}
|
[
"public",
"void",
"setBoardPivotX",
"(",
"float",
"x",
")",
"{",
"if",
"(",
"mListeners",
"!=",
"null",
")",
"{",
"for",
"(",
"StateListener",
"l",
":",
"mListeners",
")",
"{",
"l",
".",
"onBoardPivotX",
"(",
"this",
",",
"x",
")",
";",
"}",
"}",
"mContentView",
".",
"setPivotX",
"(",
"x",
")",
";",
"}"
] |
Set the x location of pivot point around which this board is rotated.
@param x
|
[
"Set",
"the",
"x",
"location",
"of",
"pivot",
"point",
"around",
"which",
"this",
"board",
"is",
"rotated",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1172-L1179
|
4,016 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setBoardPivotY
|
public void setBoardPivotY(float y) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardPivotY(this, y);
}
}
mContentView.setPivotY(y);
}
|
java
|
public void setBoardPivotY(float y) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardPivotY(this, y);
}
}
mContentView.setPivotY(y);
}
|
[
"public",
"void",
"setBoardPivotY",
"(",
"float",
"y",
")",
"{",
"if",
"(",
"mListeners",
"!=",
"null",
")",
"{",
"for",
"(",
"StateListener",
"l",
":",
"mListeners",
")",
"{",
"l",
".",
"onBoardPivotY",
"(",
"this",
",",
"y",
")",
";",
"}",
"}",
"mContentView",
".",
"setPivotY",
"(",
"y",
")",
";",
"}"
] |
Set the y location of pivot point around which this board is rotated.
@param y
|
[
"Set",
"the",
"y",
"location",
"of",
"pivot",
"point",
"around",
"which",
"this",
"board",
"is",
"rotated",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1195-L1202
|
4,017 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setBoardRotationX
|
public void setBoardRotationX(float x) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardRotationX(this, x);
}
}
mContentView.setRotationX(x);
}
|
java
|
public void setBoardRotationX(float x) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardRotationX(this, x);
}
}
mContentView.setRotationX(x);
}
|
[
"public",
"void",
"setBoardRotationX",
"(",
"float",
"x",
")",
"{",
"if",
"(",
"mListeners",
"!=",
"null",
")",
"{",
"for",
"(",
"StateListener",
"l",
":",
"mListeners",
")",
"{",
"l",
".",
"onBoardRotationX",
"(",
"this",
",",
"x",
")",
";",
"}",
"}",
"mContentView",
".",
"setRotationX",
"(",
"x",
")",
";",
"}"
] |
Set the x degree that this board is rotated.
@param x
|
[
"Set",
"the",
"x",
"degree",
"that",
"this",
"board",
"is",
"rotated",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1218-L1225
|
4,018 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setBoardRotationY
|
public void setBoardRotationY(float y) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardRotationY(this, y);
}
}
mContentView.setRotationY(y);
}
|
java
|
public void setBoardRotationY(float y) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardRotationY(this, y);
}
}
mContentView.setRotationY(y);
}
|
[
"public",
"void",
"setBoardRotationY",
"(",
"float",
"y",
")",
"{",
"if",
"(",
"mListeners",
"!=",
"null",
")",
"{",
"for",
"(",
"StateListener",
"l",
":",
"mListeners",
")",
"{",
"l",
".",
"onBoardRotationY",
"(",
"this",
",",
"y",
")",
";",
"}",
"}",
"mContentView",
".",
"setRotationY",
"(",
"y",
")",
";",
"}"
] |
Set the y degree that this board is rotated.
@param y
|
[
"Set",
"the",
"y",
"degree",
"that",
"this",
"board",
"is",
"rotated",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1241-L1248
|
4,019 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.setBoardAlpha
|
public void setBoardAlpha(float alpha) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardAlpha(this, alpha);
}
}
mContentView.setAlpha(alpha);
}
|
java
|
public void setBoardAlpha(float alpha) {
if (mListeners != null) {
for (StateListener l : mListeners) {
l.onBoardAlpha(this, alpha);
}
}
mContentView.setAlpha(alpha);
}
|
[
"public",
"void",
"setBoardAlpha",
"(",
"float",
"alpha",
")",
"{",
"if",
"(",
"mListeners",
"!=",
"null",
")",
"{",
"for",
"(",
"StateListener",
"l",
":",
"mListeners",
")",
"{",
"l",
".",
"onBoardAlpha",
"(",
"this",
",",
"alpha",
")",
";",
"}",
"}",
"mContentView",
".",
"setAlpha",
"(",
"alpha",
")",
";",
"}"
] |
Set the opacity of this board.
@param alpha
|
[
"Set",
"the",
"opacity",
"of",
"this",
"board",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1264-L1271
|
4,020 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.dimAt
|
public void dimAt(float alpha) {
if (!mDimEnabled) {
return;
}
if (mDimView == null) {
mDimView = makeDimView();
}
if (!mDimView.isShown()) {
mDimView.setVisibility(VISIBLE);
mDimView.setBackgroundColor(mDimColor);
}
mDimView.setAlpha(alpha);
}
|
java
|
public void dimAt(float alpha) {
if (!mDimEnabled) {
return;
}
if (mDimView == null) {
mDimView = makeDimView();
}
if (!mDimView.isShown()) {
mDimView.setVisibility(VISIBLE);
mDimView.setBackgroundColor(mDimColor);
}
mDimView.setAlpha(alpha);
}
|
[
"public",
"void",
"dimAt",
"(",
"float",
"alpha",
")",
"{",
"if",
"(",
"!",
"mDimEnabled",
")",
"{",
"return",
";",
"}",
"if",
"(",
"mDimView",
"==",
"null",
")",
"{",
"mDimView",
"=",
"makeDimView",
"(",
")",
";",
"}",
"if",
"(",
"!",
"mDimView",
".",
"isShown",
"(",
")",
")",
"{",
"mDimView",
".",
"setVisibility",
"(",
"VISIBLE",
")",
";",
"mDimView",
".",
"setBackgroundColor",
"(",
"mDimColor",
")",
";",
"}",
"mDimView",
".",
"setAlpha",
"(",
"alpha",
")",
";",
"}"
] |
Set the dim-behind layer a specific opacity.
@param alpha
|
[
"Set",
"the",
"dim",
"-",
"behind",
"layer",
"a",
"specific",
"opacity",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1339-L1351
|
4,021 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.dim
|
public void dim(int duration) {
if (!mDimEnabled) {
return;
}
if (mDimView == null) {
mDimView = makeDimView();
}
if (!mDimView.isShown()) {
mDimView.setVisibility(VISIBLE);
mDimView.setBackgroundColor(mDimColor);
}
mDimView.animate().cancel();
mDimView.animate().alpha(mDimAlpha)
.setListener(null)
.setDuration(duration)
.start();
}
|
java
|
public void dim(int duration) {
if (!mDimEnabled) {
return;
}
if (mDimView == null) {
mDimView = makeDimView();
}
if (!mDimView.isShown()) {
mDimView.setVisibility(VISIBLE);
mDimView.setBackgroundColor(mDimColor);
}
mDimView.animate().cancel();
mDimView.animate().alpha(mDimAlpha)
.setListener(null)
.setDuration(duration)
.start();
}
|
[
"public",
"void",
"dim",
"(",
"int",
"duration",
")",
"{",
"if",
"(",
"!",
"mDimEnabled",
")",
"{",
"return",
";",
"}",
"if",
"(",
"mDimView",
"==",
"null",
")",
"{",
"mDimView",
"=",
"makeDimView",
"(",
")",
";",
"}",
"if",
"(",
"!",
"mDimView",
".",
"isShown",
"(",
")",
")",
"{",
"mDimView",
".",
"setVisibility",
"(",
"VISIBLE",
")",
";",
"mDimView",
".",
"setBackgroundColor",
"(",
"mDimColor",
")",
";",
"}",
"mDimView",
".",
"animate",
"(",
")",
".",
"cancel",
"(",
")",
";",
"mDimView",
".",
"animate",
"(",
")",
".",
"alpha",
"(",
"mDimAlpha",
")",
".",
"setListener",
"(",
"null",
")",
".",
"setDuration",
"(",
"duration",
")",
".",
"start",
"(",
")",
";",
"}"
] |
Start the dim animation.
@param duration
|
[
"Start",
"the",
"dim",
"animation",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1358-L1374
|
4,022 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationBoard.java
|
NotificationBoard.undim
|
public void undim(int duration) {
if (mDimView != null && mDimView.isShown() && mDimView.getAlpha() != 0) {
mDimView.animate().cancel();
mDimView.animate().alpha(0.0f)
.setListener(mDimAnimatorListener)
.setDuration(duration)
.start();
}
}
|
java
|
public void undim(int duration) {
if (mDimView != null && mDimView.isShown() && mDimView.getAlpha() != 0) {
mDimView.animate().cancel();
mDimView.animate().alpha(0.0f)
.setListener(mDimAnimatorListener)
.setDuration(duration)
.start();
}
}
|
[
"public",
"void",
"undim",
"(",
"int",
"duration",
")",
"{",
"if",
"(",
"mDimView",
"!=",
"null",
"&&",
"mDimView",
".",
"isShown",
"(",
")",
"&&",
"mDimView",
".",
"getAlpha",
"(",
")",
"!=",
"0",
")",
"{",
"mDimView",
".",
"animate",
"(",
")",
".",
"cancel",
"(",
")",
";",
"mDimView",
".",
"animate",
"(",
")",
".",
"alpha",
"(",
"0.0f",
")",
".",
"setListener",
"(",
"mDimAnimatorListener",
")",
".",
"setDuration",
"(",
"duration",
")",
".",
"start",
"(",
")",
";",
"}",
"}"
] |
Start the undim animation.
@param duration
|
[
"Start",
"the",
"undim",
"animation",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationBoard.java#L1381-L1389
|
4,023 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/npm/YarnDependencyCollector.java
|
YarnDependencyCollector.isDescendant
|
private boolean isDescendant(DependencyInfo ancestor, DependencyInfo descendant){
for (DependencyInfo child : ancestor.getChildren()){
if (child.equals(descendant)){
return true;
}
if (isDescendant(child, descendant)){
return true;
}
}
return false;
}
|
java
|
private boolean isDescendant(DependencyInfo ancestor, DependencyInfo descendant){
for (DependencyInfo child : ancestor.getChildren()){
if (child.equals(descendant)){
return true;
}
if (isDescendant(child, descendant)){
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"isDescendant",
"(",
"DependencyInfo",
"ancestor",
",",
"DependencyInfo",
"descendant",
")",
"{",
"for",
"(",
"DependencyInfo",
"child",
":",
"ancestor",
".",
"getChildren",
"(",
")",
")",
"{",
"if",
"(",
"child",
".",
"equals",
"(",
"descendant",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isDescendant",
"(",
"child",
",",
"descendant",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
preventing circular dependencies by making sure the dependency is not a descendant of its own
|
[
"preventing",
"circular",
"dependencies",
"by",
"making",
"sure",
"the",
"dependency",
"is",
"not",
"a",
"descendant",
"of",
"its",
"own"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/npm/YarnDependencyCollector.java#L163-L173
|
4,024 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleDependencyResolver.java
|
GradleDependencyResolver.copyProjectFolder
|
private boolean copyProjectFolder(String projectFolder, File buildGradleTempDirectory) {
try {
FileUtils.copyDirectory(new File(projectFolder), buildGradleTempDirectory);
} catch (IOException e) {
logger.error("Could not copy the folder {} to {} , the cause {}", projectFolder, buildGradleTempDirectory.getPath(), e.getMessage());
return false;
}
logger.debug("copied folder {} to temp folder successfully", projectFolder);
return true;
}
|
java
|
private boolean copyProjectFolder(String projectFolder, File buildGradleTempDirectory) {
try {
FileUtils.copyDirectory(new File(projectFolder), buildGradleTempDirectory);
} catch (IOException e) {
logger.error("Could not copy the folder {} to {} , the cause {}", projectFolder, buildGradleTempDirectory.getPath(), e.getMessage());
return false;
}
logger.debug("copied folder {} to temp folder successfully", projectFolder);
return true;
}
|
[
"private",
"boolean",
"copyProjectFolder",
"(",
"String",
"projectFolder",
",",
"File",
"buildGradleTempDirectory",
")",
"{",
"try",
"{",
"FileUtils",
".",
"copyDirectory",
"(",
"new",
"File",
"(",
"projectFolder",
")",
",",
"buildGradleTempDirectory",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Could not copy the folder {} to {} , the cause {}\"",
",",
"projectFolder",
",",
"buildGradleTempDirectory",
".",
"getPath",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"logger",
".",
"debug",
"(",
"\"copied folder {} to temp folder successfully\"",
",",
"projectFolder",
")",
";",
"return",
"true",
";",
"}"
] |
copy project to local temp directory
|
[
"copy",
"project",
"to",
"local",
"temp",
"directory"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleDependencyResolver.java#L276-L285
|
4,025 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleDependencyResolver.java
|
GradleDependencyResolver.appendTaskToBomFile
|
private boolean appendTaskToBomFile(File buildGradleTmp) {
FileReader fileReader;
BufferedReader bufferedReader = null;
InputStream inputStream = null;
boolean hasDependencies = false;
try {
// appending the task only if the build.gradle file has 'dependencies {' node (only at the beginning of the line)
// otherwise, later when the task is ran it'll fail
fileReader = new FileReader(buildGradleTmp);
bufferedReader = new BufferedReader(fileReader);
String currLine;
while ((currLine = bufferedReader.readLine()) != null) {
if (currLine.indexOf(DEPENDENCIES + Constants.WHITESPACE + CURLY_BRACKETS_OPEN) == 0 || currLine.indexOf(DEPENDENCIES + CURLY_BRACKETS_OPEN) == 0) {
hasDependencies = true;
break;
}
}
if (hasDependencies) {
byte[] bytes;
List<String> lines = getDependenciesTree(buildGradleTmp.getParent(), buildGradleTmp.getParentFile().getName());
if (lines != null) {
List<String> scopes = getScopes(lines);
String copyDependenciesTask = Constants.NEW_LINE + TASK_COPY_DEPENDENCIES_HEADER + Constants.NEW_LINE;
for (String scope : scopes) {
copyDependenciesTask = copyDependenciesTask.concat(" from configurations." + scope + Constants.NEW_LINE);
}
copyDependenciesTask = copyDependenciesTask.concat(TASK_COPY_DEPENDENCIES_FOOTER + Constants.NEW_LINE + CURLY_BRACKTES_CLOSE);
bytes = copyDependenciesTask.getBytes();
} else {
ClassLoader classLoader = Main.class.getClassLoader();
inputStream = classLoader.getResourceAsStream(COPY_DEPENDENCIES_TASK_TXT);
bytes = IOUtils.toByteArray(inputStream);
}
if (bytes.length > 0) {
Files.write(Paths.get(buildGradleTmp.getPath()), bytes, StandardOpenOption.APPEND);
} else if (lines == null) {
logger.warn("Could not read {}", COPY_DEPENDENCIES_TASK_TXT);
} else {
logger.warn("Could not read dependencies' tree");
}
}
} catch (IOException e) {
logger.error("Could not write into the file {}, the cause {}", buildGradleTmp.getPath(), e.getMessage());
hasDependencies = false;
}
try {
if (inputStream != null) {
inputStream.close();
}
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e) {
logger.error("Could close the file, cause", e.getMessage());
}
return hasDependencies;
}
|
java
|
private boolean appendTaskToBomFile(File buildGradleTmp) {
FileReader fileReader;
BufferedReader bufferedReader = null;
InputStream inputStream = null;
boolean hasDependencies = false;
try {
// appending the task only if the build.gradle file has 'dependencies {' node (only at the beginning of the line)
// otherwise, later when the task is ran it'll fail
fileReader = new FileReader(buildGradleTmp);
bufferedReader = new BufferedReader(fileReader);
String currLine;
while ((currLine = bufferedReader.readLine()) != null) {
if (currLine.indexOf(DEPENDENCIES + Constants.WHITESPACE + CURLY_BRACKETS_OPEN) == 0 || currLine.indexOf(DEPENDENCIES + CURLY_BRACKETS_OPEN) == 0) {
hasDependencies = true;
break;
}
}
if (hasDependencies) {
byte[] bytes;
List<String> lines = getDependenciesTree(buildGradleTmp.getParent(), buildGradleTmp.getParentFile().getName());
if (lines != null) {
List<String> scopes = getScopes(lines);
String copyDependenciesTask = Constants.NEW_LINE + TASK_COPY_DEPENDENCIES_HEADER + Constants.NEW_LINE;
for (String scope : scopes) {
copyDependenciesTask = copyDependenciesTask.concat(" from configurations." + scope + Constants.NEW_LINE);
}
copyDependenciesTask = copyDependenciesTask.concat(TASK_COPY_DEPENDENCIES_FOOTER + Constants.NEW_LINE + CURLY_BRACKTES_CLOSE);
bytes = copyDependenciesTask.getBytes();
} else {
ClassLoader classLoader = Main.class.getClassLoader();
inputStream = classLoader.getResourceAsStream(COPY_DEPENDENCIES_TASK_TXT);
bytes = IOUtils.toByteArray(inputStream);
}
if (bytes.length > 0) {
Files.write(Paths.get(buildGradleTmp.getPath()), bytes, StandardOpenOption.APPEND);
} else if (lines == null) {
logger.warn("Could not read {}", COPY_DEPENDENCIES_TASK_TXT);
} else {
logger.warn("Could not read dependencies' tree");
}
}
} catch (IOException e) {
logger.error("Could not write into the file {}, the cause {}", buildGradleTmp.getPath(), e.getMessage());
hasDependencies = false;
}
try {
if (inputStream != null) {
inputStream.close();
}
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e) {
logger.error("Could close the file, cause", e.getMessage());
}
return hasDependencies;
}
|
[
"private",
"boolean",
"appendTaskToBomFile",
"(",
"File",
"buildGradleTmp",
")",
"{",
"FileReader",
"fileReader",
";",
"BufferedReader",
"bufferedReader",
"=",
"null",
";",
"InputStream",
"inputStream",
"=",
"null",
";",
"boolean",
"hasDependencies",
"=",
"false",
";",
"try",
"{",
"// appending the task only if the build.gradle file has 'dependencies {' node (only at the beginning of the line)",
"// otherwise, later when the task is ran it'll fail",
"fileReader",
"=",
"new",
"FileReader",
"(",
"buildGradleTmp",
")",
";",
"bufferedReader",
"=",
"new",
"BufferedReader",
"(",
"fileReader",
")",
";",
"String",
"currLine",
";",
"while",
"(",
"(",
"currLine",
"=",
"bufferedReader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"currLine",
".",
"indexOf",
"(",
"DEPENDENCIES",
"+",
"Constants",
".",
"WHITESPACE",
"+",
"CURLY_BRACKETS_OPEN",
")",
"==",
"0",
"||",
"currLine",
".",
"indexOf",
"(",
"DEPENDENCIES",
"+",
"CURLY_BRACKETS_OPEN",
")",
"==",
"0",
")",
"{",
"hasDependencies",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"hasDependencies",
")",
"{",
"byte",
"[",
"]",
"bytes",
";",
"List",
"<",
"String",
">",
"lines",
"=",
"getDependenciesTree",
"(",
"buildGradleTmp",
".",
"getParent",
"(",
")",
",",
"buildGradleTmp",
".",
"getParentFile",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"lines",
"!=",
"null",
")",
"{",
"List",
"<",
"String",
">",
"scopes",
"=",
"getScopes",
"(",
"lines",
")",
";",
"String",
"copyDependenciesTask",
"=",
"Constants",
".",
"NEW_LINE",
"+",
"TASK_COPY_DEPENDENCIES_HEADER",
"+",
"Constants",
".",
"NEW_LINE",
";",
"for",
"(",
"String",
"scope",
":",
"scopes",
")",
"{",
"copyDependenciesTask",
"=",
"copyDependenciesTask",
".",
"concat",
"(",
"\" from configurations.\"",
"+",
"scope",
"+",
"Constants",
".",
"NEW_LINE",
")",
";",
"}",
"copyDependenciesTask",
"=",
"copyDependenciesTask",
".",
"concat",
"(",
"TASK_COPY_DEPENDENCIES_FOOTER",
"+",
"Constants",
".",
"NEW_LINE",
"+",
"CURLY_BRACKTES_CLOSE",
")",
";",
"bytes",
"=",
"copyDependenciesTask",
".",
"getBytes",
"(",
")",
";",
"}",
"else",
"{",
"ClassLoader",
"classLoader",
"=",
"Main",
".",
"class",
".",
"getClassLoader",
"(",
")",
";",
"inputStream",
"=",
"classLoader",
".",
"getResourceAsStream",
"(",
"COPY_DEPENDENCIES_TASK_TXT",
")",
";",
"bytes",
"=",
"IOUtils",
".",
"toByteArray",
"(",
"inputStream",
")",
";",
"}",
"if",
"(",
"bytes",
".",
"length",
">",
"0",
")",
"{",
"Files",
".",
"write",
"(",
"Paths",
".",
"get",
"(",
"buildGradleTmp",
".",
"getPath",
"(",
")",
")",
",",
"bytes",
",",
"StandardOpenOption",
".",
"APPEND",
")",
";",
"}",
"else",
"if",
"(",
"lines",
"==",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Could not read {}\"",
",",
"COPY_DEPENDENCIES_TASK_TXT",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"Could not read dependencies' tree\"",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Could not write into the file {}, the cause {}\"",
",",
"buildGradleTmp",
".",
"getPath",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"hasDependencies",
"=",
"false",
";",
"}",
"try",
"{",
"if",
"(",
"inputStream",
"!=",
"null",
")",
"{",
"inputStream",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"bufferedReader",
"!=",
"null",
")",
"{",
"bufferedReader",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Could close the file, cause\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"hasDependencies",
";",
"}"
] |
append new task to bom file
|
[
"append",
"new",
"task",
"to",
"bom",
"file"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleDependencyResolver.java#L288-L344
|
4,026 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleDependencyResolver.java
|
GradleDependencyResolver.runPreStepCommand
|
private void runPreStepCommand(File bomFile) {
String directory = bomFile.getParent();
String[] gradleCommandParams = gradleCli.getGradleCommandParams(GradleMvnCommand.COPY_DEPENDENCIES);
if (StringUtils.isNotEmpty(directory) && gradleCommandParams.length > 0) {
gradleCli.runGradleCmd(directory, gradleCommandParams, true);
} else {
logger.warn("Could not run gradle command");
}
}
|
java
|
private void runPreStepCommand(File bomFile) {
String directory = bomFile.getParent();
String[] gradleCommandParams = gradleCli.getGradleCommandParams(GradleMvnCommand.COPY_DEPENDENCIES);
if (StringUtils.isNotEmpty(directory) && gradleCommandParams.length > 0) {
gradleCli.runGradleCmd(directory, gradleCommandParams, true);
} else {
logger.warn("Could not run gradle command");
}
}
|
[
"private",
"void",
"runPreStepCommand",
"(",
"File",
"bomFile",
")",
"{",
"String",
"directory",
"=",
"bomFile",
".",
"getParent",
"(",
")",
";",
"String",
"[",
"]",
"gradleCommandParams",
"=",
"gradleCli",
".",
"getGradleCommandParams",
"(",
"GradleMvnCommand",
".",
"COPY_DEPENDENCIES",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"directory",
")",
"&&",
"gradleCommandParams",
".",
"length",
">",
"0",
")",
"{",
"gradleCli",
".",
"runGradleCmd",
"(",
"directory",
",",
"gradleCommandParams",
",",
"true",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"Could not run gradle command\"",
")",
";",
"}",
"}"
] |
run pre step command gradle copyDependencies
|
[
"run",
"pre",
"step",
"command",
"gradle",
"copyDependencies"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleDependencyResolver.java#L361-L369
|
4,027 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleDependencyResolver.java
|
GradleDependencyResolver.removeTaskFromBomFile
|
private void removeTaskFromBomFile(File buildGradleTmp) {
FileReader fileReader;
BufferedReader bufferedReader = null;
try {
fileReader = new FileReader(buildGradleTmp);
bufferedReader = new BufferedReader(fileReader);
String currLine;
String originalLines = "";
while ((currLine = bufferedReader.readLine()) != null) {
if (currLine.equals(TASK_COPY_DEPENDENCIES_HEADER)) {
break;
} else {
originalLines = originalLines.concat(currLine + Constants.NEW_LINE);
}
}
if (!originalLines.isEmpty()) {
byte[] bytes = originalLines.getBytes();
Files.write(Paths.get(buildGradleTmp.getPath()), bytes, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
}
} catch (IOException e) {
logger.warn("Couldn't remove 'copyDependencies' task from {}, error: {}", buildGradleTmp.getPath(), e.getMessage());
logger.debug("Error: {}", e.getStackTrace());
} finally {
try {
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e) {
logger.error("Could close the file, cause", e.getMessage());
}
}
}
|
java
|
private void removeTaskFromBomFile(File buildGradleTmp) {
FileReader fileReader;
BufferedReader bufferedReader = null;
try {
fileReader = new FileReader(buildGradleTmp);
bufferedReader = new BufferedReader(fileReader);
String currLine;
String originalLines = "";
while ((currLine = bufferedReader.readLine()) != null) {
if (currLine.equals(TASK_COPY_DEPENDENCIES_HEADER)) {
break;
} else {
originalLines = originalLines.concat(currLine + Constants.NEW_LINE);
}
}
if (!originalLines.isEmpty()) {
byte[] bytes = originalLines.getBytes();
Files.write(Paths.get(buildGradleTmp.getPath()), bytes, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
}
} catch (IOException e) {
logger.warn("Couldn't remove 'copyDependencies' task from {}, error: {}", buildGradleTmp.getPath(), e.getMessage());
logger.debug("Error: {}", e.getStackTrace());
} finally {
try {
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e) {
logger.error("Could close the file, cause", e.getMessage());
}
}
}
|
[
"private",
"void",
"removeTaskFromBomFile",
"(",
"File",
"buildGradleTmp",
")",
"{",
"FileReader",
"fileReader",
";",
"BufferedReader",
"bufferedReader",
"=",
"null",
";",
"try",
"{",
"fileReader",
"=",
"new",
"FileReader",
"(",
"buildGradleTmp",
")",
";",
"bufferedReader",
"=",
"new",
"BufferedReader",
"(",
"fileReader",
")",
";",
"String",
"currLine",
";",
"String",
"originalLines",
"=",
"\"\"",
";",
"while",
"(",
"(",
"currLine",
"=",
"bufferedReader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"currLine",
".",
"equals",
"(",
"TASK_COPY_DEPENDENCIES_HEADER",
")",
")",
"{",
"break",
";",
"}",
"else",
"{",
"originalLines",
"=",
"originalLines",
".",
"concat",
"(",
"currLine",
"+",
"Constants",
".",
"NEW_LINE",
")",
";",
"}",
"}",
"if",
"(",
"!",
"originalLines",
".",
"isEmpty",
"(",
")",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"originalLines",
".",
"getBytes",
"(",
")",
";",
"Files",
".",
"write",
"(",
"Paths",
".",
"get",
"(",
"buildGradleTmp",
".",
"getPath",
"(",
")",
")",
",",
"bytes",
",",
"StandardOpenOption",
".",
"WRITE",
",",
"StandardOpenOption",
".",
"TRUNCATE_EXISTING",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Couldn't remove 'copyDependencies' task from {}, error: {}\"",
",",
"buildGradleTmp",
".",
"getPath",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Error: {}\"",
",",
"e",
".",
"getStackTrace",
"(",
")",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"bufferedReader",
"!=",
"null",
")",
"{",
"bufferedReader",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Could close the file, cause\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
therefore, after running the copy-dependencies task removing it from the build.gradle file
|
[
"therefore",
"after",
"running",
"the",
"copy",
"-",
"dependencies",
"task",
"removing",
"it",
"from",
"the",
"build",
".",
"gradle",
"file"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/gradle/GradleDependencyResolver.java#L373-L404
|
4,028 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/hex/HexDependencyResolver.java
|
HexDependencyResolver.getSha1
|
private String getSha1(String name, String version) {
if (dotHexCachePath == null || name == null || version == null){
logger.warn("Can't calculate SHA1, missing information: .hex-cache = {}, name = {}, version = {}", dotHexCachePath, name, version);
return null;
}
File tarFile = new File(dotHexCachePath + fileSeparator + name + Constants.DASH + version + TAR_EXTENSION);
try {
return ChecksumUtils.calculateSHA1(tarFile);
} catch (IOException e) {
logger.warn("Failed calculating SHA1 of {}. Make sure HEX is installed", tarFile.getPath());
logger.debug("Error: {}", e.getStackTrace());
return null;
}
}
|
java
|
private String getSha1(String name, String version) {
if (dotHexCachePath == null || name == null || version == null){
logger.warn("Can't calculate SHA1, missing information: .hex-cache = {}, name = {}, version = {}", dotHexCachePath, name, version);
return null;
}
File tarFile = new File(dotHexCachePath + fileSeparator + name + Constants.DASH + version + TAR_EXTENSION);
try {
return ChecksumUtils.calculateSHA1(tarFile);
} catch (IOException e) {
logger.warn("Failed calculating SHA1 of {}. Make sure HEX is installed", tarFile.getPath());
logger.debug("Error: {}", e.getStackTrace());
return null;
}
}
|
[
"private",
"String",
"getSha1",
"(",
"String",
"name",
",",
"String",
"version",
")",
"{",
"if",
"(",
"dotHexCachePath",
"==",
"null",
"||",
"name",
"==",
"null",
"||",
"version",
"==",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Can't calculate SHA1, missing information: .hex-cache = {}, name = {}, version = {}\"",
",",
"dotHexCachePath",
",",
"name",
",",
"version",
")",
";",
"return",
"null",
";",
"}",
"File",
"tarFile",
"=",
"new",
"File",
"(",
"dotHexCachePath",
"+",
"fileSeparator",
"+",
"name",
"+",
"Constants",
".",
"DASH",
"+",
"version",
"+",
"TAR_EXTENSION",
")",
";",
"try",
"{",
"return",
"ChecksumUtils",
".",
"calculateSHA1",
"(",
"tarFile",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Failed calculating SHA1 of {}. Make sure HEX is installed\"",
",",
"tarFile",
".",
"getPath",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Error: {}\"",
",",
"e",
".",
"getStackTrace",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
this method is used when there's a known version
|
[
"this",
"method",
"is",
"used",
"when",
"there",
"s",
"a",
"known",
"version"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/hex/HexDependencyResolver.java#L348-L361
|
4,029 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/hex/HexDependencyResolver.java
|
HexDependencyResolver.isDescendant
|
private boolean isDescendant(DependencyInfo parentDependency, DependencyInfo childDependency){
for (DependencyInfo dependencyInfo : childDependency.getChildren()){
if (dependencyInfo.equals(parentDependency))
return true;
return isDescendant(dependencyInfo, childDependency);
}
return false;
}
|
java
|
private boolean isDescendant(DependencyInfo parentDependency, DependencyInfo childDependency){
for (DependencyInfo dependencyInfo : childDependency.getChildren()){
if (dependencyInfo.equals(parentDependency))
return true;
return isDescendant(dependencyInfo, childDependency);
}
return false;
}
|
[
"private",
"boolean",
"isDescendant",
"(",
"DependencyInfo",
"parentDependency",
",",
"DependencyInfo",
"childDependency",
")",
"{",
"for",
"(",
"DependencyInfo",
"dependencyInfo",
":",
"childDependency",
".",
"getChildren",
"(",
")",
")",
"{",
"if",
"(",
"dependencyInfo",
".",
"equals",
"(",
"parentDependency",
")",
")",
"return",
"true",
";",
"return",
"isDescendant",
"(",
"dependencyInfo",
",",
"childDependency",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
avoiding circular-dependencies
|
[
"avoiding",
"circular",
"-",
"dependencies"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/hex/HexDependencyResolver.java#L386-L393
|
4,030 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.pause
|
public void pause() {
if (hasState(TICKING) && !hasState(PAUSED)) {
if (DBG) Log.v(TAG, "pause. " + mEntries.size());
mContentView.animate().cancel();
addState(PAUSED);
cancel(-1);
}
}
|
java
|
public void pause() {
if (hasState(TICKING) && !hasState(PAUSED)) {
if (DBG) Log.v(TAG, "pause. " + mEntries.size());
mContentView.animate().cancel();
addState(PAUSED);
cancel(-1);
}
}
|
[
"public",
"void",
"pause",
"(",
")",
"{",
"if",
"(",
"hasState",
"(",
"TICKING",
")",
"&&",
"!",
"hasState",
"(",
"PAUSED",
")",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"pause. \"",
"+",
"mEntries",
".",
"size",
"(",
")",
")",
";",
"mContentView",
".",
"animate",
"(",
")",
".",
"cancel",
"(",
")",
";",
"addState",
"(",
"PAUSED",
")",
";",
"cancel",
"(",
"-",
"1",
")",
";",
"}",
"}"
] |
Pause. Any notification delivered here will be suspended.
|
[
"Pause",
".",
"Any",
"notification",
"delivered",
"here",
"will",
"be",
"suspended",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L336-L343
|
4,031 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.setContentPadding
|
public void setContentPadding(int l, int t, int r, int b) {
mContentPadding[0] = l;
mContentPadding[1] = t;
mContentPadding[2] = r;
mContentPadding[3] = b;
}
|
java
|
public void setContentPadding(int l, int t, int r, int b) {
mContentPadding[0] = l;
mContentPadding[1] = t;
mContentPadding[2] = r;
mContentPadding[3] = b;
}
|
[
"public",
"void",
"setContentPadding",
"(",
"int",
"l",
",",
"int",
"t",
",",
"int",
"r",
",",
"int",
"b",
")",
"{",
"mContentPadding",
"[",
"0",
"]",
"=",
"l",
";",
"mContentPadding",
"[",
"1",
"]",
"=",
"t",
";",
"mContentPadding",
"[",
"2",
"]",
"=",
"r",
";",
"mContentPadding",
"[",
"3",
"]",
"=",
"b",
";",
"}"
] |
Set padding.
@param l
@param t
@param r
@param b
|
[
"Set",
"padding",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L476-L481
|
4,032 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.setContentMargin
|
public void setContentMargin(int l, int t, int r, int b) {
mContentMargin[0] = l;
mContentMargin[1] = t;
mContentMargin[2] = r;
mContentMargin[3] = b;
}
|
java
|
public void setContentMargin(int l, int t, int r, int b) {
mContentMargin[0] = l;
mContentMargin[1] = t;
mContentMargin[2] = r;
mContentMargin[3] = b;
}
|
[
"public",
"void",
"setContentMargin",
"(",
"int",
"l",
",",
"int",
"t",
",",
"int",
"r",
",",
"int",
"b",
")",
"{",
"mContentMargin",
"[",
"0",
"]",
"=",
"l",
";",
"mContentMargin",
"[",
"1",
"]",
"=",
"t",
";",
"mContentMargin",
"[",
"2",
"]",
"=",
"r",
";",
"mContentMargin",
"[",
"3",
"]",
"=",
"b",
";",
"}"
] |
Set margin.
@param l
@param t
@param r
@param b
|
[
"Set",
"margin",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L491-L496
|
4,033 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.setContentViewVisibility
|
public void setContentViewVisibility(int vis) {
if (DBG) Log.v(TAG, "setContentVisibility - vis=" + vis);
mContentView.setVisibility(vis);
}
|
java
|
public void setContentViewVisibility(int vis) {
if (DBG) Log.v(TAG, "setContentVisibility - vis=" + vis);
mContentView.setVisibility(vis);
}
|
[
"public",
"void",
"setContentViewVisibility",
"(",
"int",
"vis",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"setContentVisibility - vis=\"",
"+",
"vis",
")",
";",
"mContentView",
".",
"setVisibility",
"(",
"vis",
")",
";",
"}"
] |
Set visibility of the contentView.
@param vis
|
[
"Set",
"visibility",
"of",
"the",
"contentView",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L627-L630
|
4,034 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.setContentView
|
public void setContentView(int resId) {
if (mCurrentLayoutId != resId) {
View view = inflate(mContext, resId, null);
if (mDefaultContentView == null &&
resId == mCallback.getContentViewDefaultLayoutId(this)) {
mDefaultContentView = view;
mDefaultLayoutId = resId;
}
mCurrentLayoutId = resId;
setContentView(view);
}
}
|
java
|
public void setContentView(int resId) {
if (mCurrentLayoutId != resId) {
View view = inflate(mContext, resId, null);
if (mDefaultContentView == null &&
resId == mCallback.getContentViewDefaultLayoutId(this)) {
mDefaultContentView = view;
mDefaultLayoutId = resId;
}
mCurrentLayoutId = resId;
setContentView(view);
}
}
|
[
"public",
"void",
"setContentView",
"(",
"int",
"resId",
")",
"{",
"if",
"(",
"mCurrentLayoutId",
"!=",
"resId",
")",
"{",
"View",
"view",
"=",
"inflate",
"(",
"mContext",
",",
"resId",
",",
"null",
")",
";",
"if",
"(",
"mDefaultContentView",
"==",
"null",
"&&",
"resId",
"==",
"mCallback",
".",
"getContentViewDefaultLayoutId",
"(",
"this",
")",
")",
"{",
"mDefaultContentView",
"=",
"view",
";",
"mDefaultLayoutId",
"=",
"resId",
";",
"}",
"mCurrentLayoutId",
"=",
"resId",
";",
"setContentView",
"(",
"view",
")",
";",
"}",
"}"
] |
Set contentView.
@param resId
|
[
"Set",
"contentView",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L637-L648
|
4,035 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.setContentViewPivotX
|
public void setContentViewPivotX(float x) {
if (DBG) Log.v(TAG, "setContentViewPivotX - x=" + x);
mContentView.setPivotY(x);
}
|
java
|
public void setContentViewPivotX(float x) {
if (DBG) Log.v(TAG, "setContentViewPivotX - x=" + x);
mContentView.setPivotY(x);
}
|
[
"public",
"void",
"setContentViewPivotX",
"(",
"float",
"x",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"setContentViewPivotX - x=\"",
"+",
"x",
")",
";",
"mContentView",
".",
"setPivotY",
"(",
"x",
")",
";",
"}"
] |
Set the x location of pivot point around which the contentView is rotated.
@param x
|
[
"Set",
"the",
"x",
"location",
"of",
"pivot",
"point",
"around",
"which",
"the",
"contentView",
"is",
"rotated",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L898-L901
|
4,036 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.setContentViewPivotY
|
public void setContentViewPivotY(float y) {
if (DBG) Log.v(TAG, "setContentViewPivotY - y=" + y);
mContentView.setPivotY(y);
}
|
java
|
public void setContentViewPivotY(float y) {
if (DBG) Log.v(TAG, "setContentViewPivotY - y=" + y);
mContentView.setPivotY(y);
}
|
[
"public",
"void",
"setContentViewPivotY",
"(",
"float",
"y",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"setContentViewPivotY - y=\"",
"+",
"y",
")",
";",
"mContentView",
".",
"setPivotY",
"(",
"y",
")",
";",
"}"
] |
Set the y location of pivot point around which the contentView is rotated.
@param y
|
[
"Set",
"the",
"y",
"location",
"of",
"pivot",
"point",
"around",
"which",
"the",
"contentView",
"is",
"rotated",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L917-L920
|
4,037 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.animateContentViewRotationY
|
public void animateContentViewRotationY(float degree, float alpha,
Animator.AnimatorListener listener,
int duration) {
if (DBG) Log.v(TAG, "animateContentViewRotationY - " +
"degree=" + degree + ", alpha=" + alpha);
mContentView.animate().cancel();
mContentView.animate()
.alpha(alpha)
.rotationY(degree)
.setListener(listener)
.setDuration(duration)
.start();
}
|
java
|
public void animateContentViewRotationY(float degree, float alpha,
Animator.AnimatorListener listener,
int duration) {
if (DBG) Log.v(TAG, "animateContentViewRotationY - " +
"degree=" + degree + ", alpha=" + alpha);
mContentView.animate().cancel();
mContentView.animate()
.alpha(alpha)
.rotationY(degree)
.setListener(listener)
.setDuration(duration)
.start();
}
|
[
"public",
"void",
"animateContentViewRotationY",
"(",
"float",
"degree",
",",
"float",
"alpha",
",",
"Animator",
".",
"AnimatorListener",
"listener",
",",
"int",
"duration",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"animateContentViewRotationY - \"",
"+",
"\"degree=\"",
"+",
"degree",
"+",
"\", alpha=\"",
"+",
"alpha",
")",
";",
"mContentView",
".",
"animate",
"(",
")",
".",
"cancel",
"(",
")",
";",
"mContentView",
".",
"animate",
"(",
")",
".",
"alpha",
"(",
"alpha",
")",
".",
"rotationY",
"(",
"degree",
")",
".",
"setListener",
"(",
"listener",
")",
".",
"setDuration",
"(",
"duration",
")",
".",
"start",
"(",
")",
";",
"}"
] |
Rotate the contentView to y degree with animation.
@param degree
@param alpha
@param listener
@param duration
|
[
"Rotate",
"the",
"contentView",
"to",
"y",
"degree",
"with",
"animation",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L963-L977
|
4,038 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.animateContentViewTranslationX
|
public void animateContentViewTranslationX(float x, float alpha,
Animator.AnimatorListener listener,
int duration) {
if (DBG) Log.v(TAG, "animateContentViewTranslationX - " +
"x=" + x + ", alpha=" + alpha);
mContentView.animate().cancel();
mContentView.animate()
.alpha(alpha)
.translationX(x)
.setListener(listener)
.setDuration(duration)
.start();
}
|
java
|
public void animateContentViewTranslationX(float x, float alpha,
Animator.AnimatorListener listener,
int duration) {
if (DBG) Log.v(TAG, "animateContentViewTranslationX - " +
"x=" + x + ", alpha=" + alpha);
mContentView.animate().cancel();
mContentView.animate()
.alpha(alpha)
.translationX(x)
.setListener(listener)
.setDuration(duration)
.start();
}
|
[
"public",
"void",
"animateContentViewTranslationX",
"(",
"float",
"x",
",",
"float",
"alpha",
",",
"Animator",
".",
"AnimatorListener",
"listener",
",",
"int",
"duration",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"animateContentViewTranslationX - \"",
"+",
"\"x=\"",
"+",
"x",
"+",
"\", alpha=\"",
"+",
"alpha",
")",
";",
"mContentView",
".",
"animate",
"(",
")",
".",
"cancel",
"(",
")",
";",
"mContentView",
".",
"animate",
"(",
")",
".",
"alpha",
"(",
"alpha",
")",
".",
"translationX",
"(",
"x",
")",
".",
"setListener",
"(",
"listener",
")",
".",
"setDuration",
"(",
"duration",
")",
".",
"start",
"(",
")",
";",
"}"
] |
Move the contentView to x position with animation.
@param x
@param alpha
@param listener
@param duration
|
[
"Move",
"the",
"contentView",
"to",
"x",
"position",
"with",
"animation",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L987-L1001
|
4,039 |
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationView.java
|
NotificationView.animateContentViewTranslationY
|
public void animateContentViewTranslationY(float y, float alpha,
Animator.AnimatorListener listener,
int duration) {
if (DBG) Log.v(TAG, "animateContentViewTranslationY - " +
"y=" + y + ", alpha=" + alpha);
mContentView.animate().cancel();
mContentView.animate()
.alpha(alpha)
.translationY(y)
.setListener(listener)
.setDuration(duration)
.start();
}
|
java
|
public void animateContentViewTranslationY(float y, float alpha,
Animator.AnimatorListener listener,
int duration) {
if (DBG) Log.v(TAG, "animateContentViewTranslationY - " +
"y=" + y + ", alpha=" + alpha);
mContentView.animate().cancel();
mContentView.animate()
.alpha(alpha)
.translationY(y)
.setListener(listener)
.setDuration(duration)
.start();
}
|
[
"public",
"void",
"animateContentViewTranslationY",
"(",
"float",
"y",
",",
"float",
"alpha",
",",
"Animator",
".",
"AnimatorListener",
"listener",
",",
"int",
"duration",
")",
"{",
"if",
"(",
"DBG",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"animateContentViewTranslationY - \"",
"+",
"\"y=\"",
"+",
"y",
"+",
"\", alpha=\"",
"+",
"alpha",
")",
";",
"mContentView",
".",
"animate",
"(",
")",
".",
"cancel",
"(",
")",
";",
"mContentView",
".",
"animate",
"(",
")",
".",
"alpha",
"(",
"alpha",
")",
".",
"translationY",
"(",
"y",
")",
".",
"setListener",
"(",
"listener",
")",
".",
"setDuration",
"(",
"duration",
")",
".",
"start",
"(",
")",
";",
"}"
] |
Move the contentView to y position with animation.
@param y
@param alpha
@param listener
@param duration
|
[
"Move",
"the",
"contentView",
"to",
"y",
"position",
"with",
"animation",
"."
] |
6d6571d2862cb6edbacf9a78125418f7d621c3f8
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationView.java#L1011-L1025
|
4,040 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/sbt/SbtDependencyResolver.java
|
SbtDependencyResolver.runPreStep
|
private void runPreStep(String folderPath) {
Cli cli = new Cli();
boolean success = false;
List<String> compileOutput = cli.runCmd(folderPath, cli.getCommandParams(SBT, COMPILE));
if (!compileOutput.isEmpty()) {
if (compileOutput.get(compileOutput.size() - 1).contains(SUCCESS)) {
success = true;
}
}
if (!success) {
logger.warn("Can't run '{} {}'", SBT, COMPILE);
}
}
|
java
|
private void runPreStep(String folderPath) {
Cli cli = new Cli();
boolean success = false;
List<String> compileOutput = cli.runCmd(folderPath, cli.getCommandParams(SBT, COMPILE));
if (!compileOutput.isEmpty()) {
if (compileOutput.get(compileOutput.size() - 1).contains(SUCCESS)) {
success = true;
}
}
if (!success) {
logger.warn("Can't run '{} {}'", SBT, COMPILE);
}
}
|
[
"private",
"void",
"runPreStep",
"(",
"String",
"folderPath",
")",
"{",
"Cli",
"cli",
"=",
"new",
"Cli",
"(",
")",
";",
"boolean",
"success",
"=",
"false",
";",
"List",
"<",
"String",
">",
"compileOutput",
"=",
"cli",
".",
"runCmd",
"(",
"folderPath",
",",
"cli",
".",
"getCommandParams",
"(",
"SBT",
",",
"COMPILE",
")",
")",
";",
"if",
"(",
"!",
"compileOutput",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"compileOutput",
".",
"get",
"(",
"compileOutput",
".",
"size",
"(",
")",
"-",
"1",
")",
".",
"contains",
"(",
"SUCCESS",
")",
")",
"{",
"success",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"success",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Can't run '{} {}'\"",
",",
"SBT",
",",
"COMPILE",
")",
";",
"}",
"}"
] |
creating the xml report using 'sbt "compile"' command
|
[
"creating",
"the",
"xml",
"report",
"using",
"sbt",
"compile",
"command"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/sbt/SbtDependencyResolver.java#L199-L211
|
4,041 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/dependency/resolver/sbt/SbtDependencyResolver.java
|
SbtDependencyResolver.findTargetFolders
|
private Collection<String> findTargetFolders(String folderPath) {
logger.debug("Scanning target folder {}", folderPath);
Cli cli = new Cli();
List<String> lines;
List<String> targetFolders = new LinkedList<>();
lines = cli.runCmd(folderPath, cli.getCommandParams(SBT, TARGET));
if (lines != null && !lines.isEmpty()) {
for (String line : lines) {
if (DependencyCollector.isWindows()) {
if (line.endsWith(TARGET) && line.contains(fileSeparator)) {
String[] split = line.split(windowsPattern);
targetFolders.add(split[1]);
}
} else {
if (line.contains(TARGET) && line.contains(fileSeparator)) {
Matcher matcher = linuxPattern.matcher(line);
if (matcher.find()) {
targetFolders.add(matcher.group(0));
}
}
}
}
for (int i = 0; i < targetFolders.size(); i++) {
String targetFolder = targetFolders.get(i);
Path path = Paths.get(targetFolder);
if (!Files.exists(path)) {
targetFolders.remove(targetFolder);
logger.warn("The target folder {} path doesn't exist", sbtTargetFolder);
}
}
}
return targetFolders;
}
|
java
|
private Collection<String> findTargetFolders(String folderPath) {
logger.debug("Scanning target folder {}", folderPath);
Cli cli = new Cli();
List<String> lines;
List<String> targetFolders = new LinkedList<>();
lines = cli.runCmd(folderPath, cli.getCommandParams(SBT, TARGET));
if (lines != null && !lines.isEmpty()) {
for (String line : lines) {
if (DependencyCollector.isWindows()) {
if (line.endsWith(TARGET) && line.contains(fileSeparator)) {
String[] split = line.split(windowsPattern);
targetFolders.add(split[1]);
}
} else {
if (line.contains(TARGET) && line.contains(fileSeparator)) {
Matcher matcher = linuxPattern.matcher(line);
if (matcher.find()) {
targetFolders.add(matcher.group(0));
}
}
}
}
for (int i = 0; i < targetFolders.size(); i++) {
String targetFolder = targetFolders.get(i);
Path path = Paths.get(targetFolder);
if (!Files.exists(path)) {
targetFolders.remove(targetFolder);
logger.warn("The target folder {} path doesn't exist", sbtTargetFolder);
}
}
}
return targetFolders;
}
|
[
"private",
"Collection",
"<",
"String",
">",
"findTargetFolders",
"(",
"String",
"folderPath",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Scanning target folder {}\"",
",",
"folderPath",
")",
";",
"Cli",
"cli",
"=",
"new",
"Cli",
"(",
")",
";",
"List",
"<",
"String",
">",
"lines",
";",
"List",
"<",
"String",
">",
"targetFolders",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"lines",
"=",
"cli",
".",
"runCmd",
"(",
"folderPath",
",",
"cli",
".",
"getCommandParams",
"(",
"SBT",
",",
"TARGET",
")",
")",
";",
"if",
"(",
"lines",
"!=",
"null",
"&&",
"!",
"lines",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"String",
"line",
":",
"lines",
")",
"{",
"if",
"(",
"DependencyCollector",
".",
"isWindows",
"(",
")",
")",
"{",
"if",
"(",
"line",
".",
"endsWith",
"(",
"TARGET",
")",
"&&",
"line",
".",
"contains",
"(",
"fileSeparator",
")",
")",
"{",
"String",
"[",
"]",
"split",
"=",
"line",
".",
"split",
"(",
"windowsPattern",
")",
";",
"targetFolders",
".",
"add",
"(",
"split",
"[",
"1",
"]",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"line",
".",
"contains",
"(",
"TARGET",
")",
"&&",
"line",
".",
"contains",
"(",
"fileSeparator",
")",
")",
"{",
"Matcher",
"matcher",
"=",
"linuxPattern",
".",
"matcher",
"(",
"line",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"targetFolders",
".",
"add",
"(",
"matcher",
".",
"group",
"(",
"0",
")",
")",
";",
"}",
"}",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"targetFolders",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"targetFolder",
"=",
"targetFolders",
".",
"get",
"(",
"i",
")",
";",
"Path",
"path",
"=",
"Paths",
".",
"get",
"(",
"targetFolder",
")",
";",
"if",
"(",
"!",
"Files",
".",
"exists",
"(",
"path",
")",
")",
"{",
"targetFolders",
".",
"remove",
"(",
"targetFolder",
")",
";",
"logger",
".",
"warn",
"(",
"\"The target folder {} path doesn't exist\"",
",",
"sbtTargetFolder",
")",
";",
"}",
"}",
"}",
"return",
"targetFolders",
";",
"}"
] |
Trying to get all the paths of target folders
|
[
"Trying",
"to",
"get",
"all",
"the",
"paths",
"of",
"target",
"folders"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/sbt/SbtDependencyResolver.java#L214-L246
|
4,042 |
whitesource/fs-agent
|
src/main/java/org/whitesource/agent/utils/FilesScanner.java
|
FilesScanner.getDirectoryContent
|
public String[] getDirectoryContent(String scannerBaseDir, String[] includes, String[] excludes, boolean followSymlinks, boolean globCaseSensitive, boolean scanDirectories) {
File file = new File(scannerBaseDir);
String[] fileNames;
if (file.exists() && file.isDirectory()) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(scannerBaseDir);
scanner.setIncludes(includes);
scanner.setExcludes(excludes);
scanner.setFollowSymlinks(followSymlinks);
scanner.setCaseSensitive(globCaseSensitive);
scanner.scan();
if (!scanDirectories) {
fileNames = scanner.getIncludedFiles();
} else {
fileNames = scanner.getIncludedDirectories();
}
return fileNames;
} else {
logger.debug("{} is not a folder", scannerBaseDir);
return new String[0];
}
}
|
java
|
public String[] getDirectoryContent(String scannerBaseDir, String[] includes, String[] excludes, boolean followSymlinks, boolean globCaseSensitive, boolean scanDirectories) {
File file = new File(scannerBaseDir);
String[] fileNames;
if (file.exists() && file.isDirectory()) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(scannerBaseDir);
scanner.setIncludes(includes);
scanner.setExcludes(excludes);
scanner.setFollowSymlinks(followSymlinks);
scanner.setCaseSensitive(globCaseSensitive);
scanner.scan();
if (!scanDirectories) {
fileNames = scanner.getIncludedFiles();
} else {
fileNames = scanner.getIncludedDirectories();
}
return fileNames;
} else {
logger.debug("{} is not a folder", scannerBaseDir);
return new String[0];
}
}
|
[
"public",
"String",
"[",
"]",
"getDirectoryContent",
"(",
"String",
"scannerBaseDir",
",",
"String",
"[",
"]",
"includes",
",",
"String",
"[",
"]",
"excludes",
",",
"boolean",
"followSymlinks",
",",
"boolean",
"globCaseSensitive",
",",
"boolean",
"scanDirectories",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"scannerBaseDir",
")",
";",
"String",
"[",
"]",
"fileNames",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
"&&",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"DirectoryScanner",
"scanner",
"=",
"new",
"DirectoryScanner",
"(",
")",
";",
"scanner",
".",
"setBasedir",
"(",
"scannerBaseDir",
")",
";",
"scanner",
".",
"setIncludes",
"(",
"includes",
")",
";",
"scanner",
".",
"setExcludes",
"(",
"excludes",
")",
";",
"scanner",
".",
"setFollowSymlinks",
"(",
"followSymlinks",
")",
";",
"scanner",
".",
"setCaseSensitive",
"(",
"globCaseSensitive",
")",
";",
"scanner",
".",
"scan",
"(",
")",
";",
"if",
"(",
"!",
"scanDirectories",
")",
"{",
"fileNames",
"=",
"scanner",
".",
"getIncludedFiles",
"(",
")",
";",
"}",
"else",
"{",
"fileNames",
"=",
"scanner",
".",
"getIncludedDirectories",
"(",
")",
";",
"}",
"return",
"fileNames",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"{} is not a folder\"",
",",
"scannerBaseDir",
")",
";",
"return",
"new",
"String",
"[",
"0",
"]",
";",
"}",
"}"
] |
get the content of directory by includes, excludes, followSymlinks and globCaseSensitive, the scanDirectories property define if the scanner will scan to find directories
|
[
"get",
"the",
"content",
"of",
"directory",
"by",
"includes",
"excludes",
"followSymlinks",
"and",
"globCaseSensitive",
"the",
"scanDirectories",
"property",
"define",
"if",
"the",
"scanner",
"will",
"scan",
"to",
"find",
"directories"
] |
d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1
|
https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/utils/FilesScanner.java#L45-L66
|
4,043 |
nomis/slf4j-android
|
src/main/java/uk/uuid/slf4j/android/CategoryMap.java
|
CategoryMap.get
|
final LoggerConfig get(String name) {
final LoggerConfig config = new LoggerConfig();
if (categories.isEmpty()) {
config.merge(LoggerConfig.DEFAULT);
return config;
}
if (name == null) {
name = "";
}
while (true) {
final int index = name.lastIndexOf('.');
if (config.merge(categories.get(name)))
return config;
if (index != -1) {
name = name.substring(0, index);
} else {
if (!config.merge(categories.get(""))) {
config.merge(LoggerConfig.DEFAULT);
}
return config;
}
}
}
|
java
|
final LoggerConfig get(String name) {
final LoggerConfig config = new LoggerConfig();
if (categories.isEmpty()) {
config.merge(LoggerConfig.DEFAULT);
return config;
}
if (name == null) {
name = "";
}
while (true) {
final int index = name.lastIndexOf('.');
if (config.merge(categories.get(name)))
return config;
if (index != -1) {
name = name.substring(0, index);
} else {
if (!config.merge(categories.get(""))) {
config.merge(LoggerConfig.DEFAULT);
}
return config;
}
}
}
|
[
"final",
"LoggerConfig",
"get",
"(",
"String",
"name",
")",
"{",
"final",
"LoggerConfig",
"config",
"=",
"new",
"LoggerConfig",
"(",
")",
";",
"if",
"(",
"categories",
".",
"isEmpty",
"(",
")",
")",
"{",
"config",
".",
"merge",
"(",
"LoggerConfig",
".",
"DEFAULT",
")",
";",
"return",
"config",
";",
"}",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"name",
"=",
"\"\"",
";",
"}",
"while",
"(",
"true",
")",
"{",
"final",
"int",
"index",
"=",
"name",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"config",
".",
"merge",
"(",
"categories",
".",
"get",
"(",
"name",
")",
")",
")",
"return",
"config",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"name",
"=",
"name",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"config",
".",
"merge",
"(",
"categories",
".",
"get",
"(",
"\"\"",
")",
")",
")",
"{",
"config",
".",
"merge",
"(",
"LoggerConfig",
".",
"DEFAULT",
")",
";",
"}",
"return",
"config",
";",
"}",
"}",
"}"
] |
Returns the merged config of all matching category names for the given input, using the defaults if no categories match.
|
[
"Returns",
"the",
"merged",
"config",
"of",
"all",
"matching",
"category",
"names",
"for",
"the",
"given",
"input",
"using",
"the",
"defaults",
"if",
"no",
"categories",
"match",
"."
] |
e2b72adce8187663e95208e9be8f4647792fb4c1
|
https://github.com/nomis/slf4j-android/blob/e2b72adce8187663e95208e9be8f4647792fb4c1/src/main/java/uk/uuid/slf4j/android/CategoryMap.java#L42-L69
|
4,044 |
nomis/slf4j-android
|
src/main/java/uk/uuid/slf4j/android/CategoryMap.java
|
CategoryMap.put
|
final void put(final String name, final LoggerConfig value) {
LoggerConfig config = categories.get(name);
if (config != null) {
config.merge(value);
} else {
categories.put(name, value);
}
}
|
java
|
final void put(final String name, final LoggerConfig value) {
LoggerConfig config = categories.get(name);
if (config != null) {
config.merge(value);
} else {
categories.put(name, value);
}
}
|
[
"final",
"void",
"put",
"(",
"final",
"String",
"name",
",",
"final",
"LoggerConfig",
"value",
")",
"{",
"LoggerConfig",
"config",
"=",
"categories",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"config",
"!=",
"null",
")",
"{",
"config",
".",
"merge",
"(",
"value",
")",
";",
"}",
"else",
"{",
"categories",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}",
"}"
] |
Add a category to the config map.
|
[
"Add",
"a",
"category",
"to",
"the",
"config",
"map",
"."
] |
e2b72adce8187663e95208e9be8f4647792fb4c1
|
https://github.com/nomis/slf4j-android/blob/e2b72adce8187663e95208e9be8f4647792fb4c1/src/main/java/uk/uuid/slf4j/android/CategoryMap.java#L74-L81
|
4,045 |
nomis/slf4j-android
|
src/main/java/uk/uuid/slf4j/android/LoggerFactory.java
|
LoggerFactory.createTag
|
static final String createTag(final String name) {
if (name.length() <= MAX_TAG_LEN) {
return name;
}
final char[] tag = name.toCharArray();
final int arrayLen = tag.length;
int len = 0;
int mark = 0;
for (int i = 0; i < arrayLen; i++, len++) {
if (tag[i] == '.') {
len = mark;
if (tag[len] != '.') {
len++;
}
mark = len;
if (i + 1 < arrayLen && tag[i + 1] != '.') {
mark++;
}
}
tag[len] = tag[i];
}
if (len > MAX_TAG_LEN) {
int i = 0;
mark--;
for (int j = 0; j < len; j++) {
if (tag[j] == '.' && ((j != mark) || (i >= MAX_TAG_LEN - 1))) {
continue;
}
tag[i++] = tag[j];
}
len = i;
if (len > MAX_TAG_LEN) {
len = MAX_TAG_LEN;
}
}
return new String(tag, 0, len);
}
|
java
|
static final String createTag(final String name) {
if (name.length() <= MAX_TAG_LEN) {
return name;
}
final char[] tag = name.toCharArray();
final int arrayLen = tag.length;
int len = 0;
int mark = 0;
for (int i = 0; i < arrayLen; i++, len++) {
if (tag[i] == '.') {
len = mark;
if (tag[len] != '.') {
len++;
}
mark = len;
if (i + 1 < arrayLen && tag[i + 1] != '.') {
mark++;
}
}
tag[len] = tag[i];
}
if (len > MAX_TAG_LEN) {
int i = 0;
mark--;
for (int j = 0; j < len; j++) {
if (tag[j] == '.' && ((j != mark) || (i >= MAX_TAG_LEN - 1))) {
continue;
}
tag[i++] = tag[j];
}
len = i;
if (len > MAX_TAG_LEN) {
len = MAX_TAG_LEN;
}
}
return new String(tag, 0, len);
}
|
[
"static",
"final",
"String",
"createTag",
"(",
"final",
"String",
"name",
")",
"{",
"if",
"(",
"name",
".",
"length",
"(",
")",
"<=",
"MAX_TAG_LEN",
")",
"{",
"return",
"name",
";",
"}",
"final",
"char",
"[",
"]",
"tag",
"=",
"name",
".",
"toCharArray",
"(",
")",
";",
"final",
"int",
"arrayLen",
"=",
"tag",
".",
"length",
";",
"int",
"len",
"=",
"0",
";",
"int",
"mark",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arrayLen",
";",
"i",
"++",
",",
"len",
"++",
")",
"{",
"if",
"(",
"tag",
"[",
"i",
"]",
"==",
"'",
"'",
")",
"{",
"len",
"=",
"mark",
";",
"if",
"(",
"tag",
"[",
"len",
"]",
"!=",
"'",
"'",
")",
"{",
"len",
"++",
";",
"}",
"mark",
"=",
"len",
";",
"if",
"(",
"i",
"+",
"1",
"<",
"arrayLen",
"&&",
"tag",
"[",
"i",
"+",
"1",
"]",
"!=",
"'",
"'",
")",
"{",
"mark",
"++",
";",
"}",
"}",
"tag",
"[",
"len",
"]",
"=",
"tag",
"[",
"i",
"]",
";",
"}",
"if",
"(",
"len",
">",
"MAX_TAG_LEN",
")",
"{",
"int",
"i",
"=",
"0",
";",
"mark",
"--",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"len",
";",
"j",
"++",
")",
"{",
"if",
"(",
"tag",
"[",
"j",
"]",
"==",
"'",
"'",
"&&",
"(",
"(",
"j",
"!=",
"mark",
")",
"||",
"(",
"i",
">=",
"MAX_TAG_LEN",
"-",
"1",
")",
")",
")",
"{",
"continue",
";",
"}",
"tag",
"[",
"i",
"++",
"]",
"=",
"tag",
"[",
"j",
"]",
";",
"}",
"len",
"=",
"i",
";",
"if",
"(",
"len",
">",
"MAX_TAG_LEN",
")",
"{",
"len",
"=",
"MAX_TAG_LEN",
";",
"}",
"}",
"return",
"new",
"String",
"(",
"tag",
",",
"0",
",",
"len",
")",
";",
"}"
] |
Create a compatible logging tag for Android based on the logger name.
|
[
"Create",
"a",
"compatible",
"logging",
"tag",
"for",
"Android",
"based",
"on",
"the",
"logger",
"name",
"."
] |
e2b72adce8187663e95208e9be8f4647792fb4c1
|
https://github.com/nomis/slf4j-android/blob/e2b72adce8187663e95208e9be8f4647792fb4c1/src/main/java/uk/uuid/slf4j/android/LoggerFactory.java#L88-L137
|
4,046 |
goshippo/shippo-java-client
|
src/main/java/com/shippo/model/Batch.java
|
Batch.all
|
public static Batch[] all() throws AuthenticationException, InvalidRequestException, APIConnectionException,
APIException, UnsupportedEncodingException, MalformedURLException {
List<Batch> all_batches = new ArrayList<Batch>();
Map<String, String> params = new HashMap<String, String>();
while (true) {
Map<String, Object> reqParams = new HashMap<String, Object>(params);
BatchCollection coll = request(RequestMethod.GET, classURL(Batch.class), reqParams, BatchCollection.class,
null);
if (coll.array.length == 0) {
break;
}
all_batches.addAll(Arrays.asList(coll.array));
if (coll.next == null) {
break;
}
params = HttpUtil.queryToParams(new URL(coll.next).getQuery());
}
Batch[] array = new Batch[all_batches.size()];
all_batches.toArray(array);
return array;
}
|
java
|
public static Batch[] all() throws AuthenticationException, InvalidRequestException, APIConnectionException,
APIException, UnsupportedEncodingException, MalformedURLException {
List<Batch> all_batches = new ArrayList<Batch>();
Map<String, String> params = new HashMap<String, String>();
while (true) {
Map<String, Object> reqParams = new HashMap<String, Object>(params);
BatchCollection coll = request(RequestMethod.GET, classURL(Batch.class), reqParams, BatchCollection.class,
null);
if (coll.array.length == 0) {
break;
}
all_batches.addAll(Arrays.asList(coll.array));
if (coll.next == null) {
break;
}
params = HttpUtil.queryToParams(new URL(coll.next).getQuery());
}
Batch[] array = new Batch[all_batches.size()];
all_batches.toArray(array);
return array;
}
|
[
"public",
"static",
"Batch",
"[",
"]",
"all",
"(",
")",
"throws",
"AuthenticationException",
",",
"InvalidRequestException",
",",
"APIConnectionException",
",",
"APIException",
",",
"UnsupportedEncodingException",
",",
"MalformedURLException",
"{",
"List",
"<",
"Batch",
">",
"all_batches",
"=",
"new",
"ArrayList",
"<",
"Batch",
">",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"reqParams",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
"params",
")",
";",
"BatchCollection",
"coll",
"=",
"request",
"(",
"RequestMethod",
".",
"GET",
",",
"classURL",
"(",
"Batch",
".",
"class",
")",
",",
"reqParams",
",",
"BatchCollection",
".",
"class",
",",
"null",
")",
";",
"if",
"(",
"coll",
".",
"array",
".",
"length",
"==",
"0",
")",
"{",
"break",
";",
"}",
"all_batches",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"coll",
".",
"array",
")",
")",
";",
"if",
"(",
"coll",
".",
"next",
"==",
"null",
")",
"{",
"break",
";",
"}",
"params",
"=",
"HttpUtil",
".",
"queryToParams",
"(",
"new",
"URL",
"(",
"coll",
".",
"next",
")",
".",
"getQuery",
"(",
")",
")",
";",
"}",
"Batch",
"[",
"]",
"array",
"=",
"new",
"Batch",
"[",
"all_batches",
".",
"size",
"(",
")",
"]",
";",
"all_batches",
".",
"toArray",
"(",
"array",
")",
";",
"return",
"array",
";",
"}"
] |
Get all batches created in the account.
@return Array of Batch object
|
[
"Get",
"all",
"batches",
"created",
"in",
"the",
"account",
"."
] |
eecf801c7e07a627c3677a331c0cfcf36cb1678b
|
https://github.com/goshippo/shippo-java-client/blob/eecf801c7e07a627c3677a331c0cfcf36cb1678b/src/main/java/com/shippo/model/Batch.java#L154-L174
|
4,047 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.isSchemaValid
|
private boolean isSchemaValid() throws SQLException {
logger.entering(CLASSNAME, "isSchemaValid");
Connection conn = getConnectionToDefaultSchema();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getSchemas();
while(rs.next()) {
if (schema.equalsIgnoreCase(rs.getString("TABLE_SCHEM")) ) {
cleanupConnection(conn, rs, null);
logger.exiting(CLASSNAME, "isSchemaValid", true);
return true;
}
}
cleanupConnection(conn, rs, null);
logger.exiting(CLASSNAME, "isSchemaValid", false);
return false;
}
|
java
|
private boolean isSchemaValid() throws SQLException {
logger.entering(CLASSNAME, "isSchemaValid");
Connection conn = getConnectionToDefaultSchema();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getSchemas();
while(rs.next()) {
if (schema.equalsIgnoreCase(rs.getString("TABLE_SCHEM")) ) {
cleanupConnection(conn, rs, null);
logger.exiting(CLASSNAME, "isSchemaValid", true);
return true;
}
}
cleanupConnection(conn, rs, null);
logger.exiting(CLASSNAME, "isSchemaValid", false);
return false;
}
|
[
"private",
"boolean",
"isSchemaValid",
"(",
")",
"throws",
"SQLException",
"{",
"logger",
".",
"entering",
"(",
"CLASSNAME",
",",
"\"isSchemaValid\"",
")",
";",
"Connection",
"conn",
"=",
"getConnectionToDefaultSchema",
"(",
")",
";",
"DatabaseMetaData",
"dbmd",
"=",
"conn",
".",
"getMetaData",
"(",
")",
";",
"ResultSet",
"rs",
"=",
"dbmd",
".",
"getSchemas",
"(",
")",
";",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"if",
"(",
"schema",
".",
"equalsIgnoreCase",
"(",
"rs",
".",
"getString",
"(",
"\"TABLE_SCHEM\"",
")",
")",
")",
"{",
"cleanupConnection",
"(",
"conn",
",",
"rs",
",",
"null",
")",
";",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"isSchemaValid\"",
",",
"true",
")",
";",
"return",
"true",
";",
"}",
"}",
"cleanupConnection",
"(",
"conn",
",",
"rs",
",",
"null",
")",
";",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"isSchemaValid\"",
",",
"false",
")",
";",
"return",
"false",
";",
"}"
] |
Checks if the default schema JBATCH or the schema defined in batch-config exists.
@return true if the schema exists, false otherwise.
@throws SQLException
|
[
"Checks",
"if",
"the",
"default",
"schema",
"JBATCH",
"or",
"the",
"schema",
"defined",
"in",
"batch",
"-",
"config",
"exists",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L164-L179
|
4,048 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.createSchema
|
private void createSchema() throws SQLException {
logger.entering(CLASSNAME, "createSchema");
Connection conn = getConnectionToDefaultSchema();
logger.log(Level.INFO, schema + " schema does not exists. Trying to create it.");
PreparedStatement ps = null;
ps = conn.prepareStatement("CREATE SCHEMA " + schema);
ps.execute();
cleanupConnection(conn, null, ps);
logger.exiting(CLASSNAME, "createSchema");
}
|
java
|
private void createSchema() throws SQLException {
logger.entering(CLASSNAME, "createSchema");
Connection conn = getConnectionToDefaultSchema();
logger.log(Level.INFO, schema + " schema does not exists. Trying to create it.");
PreparedStatement ps = null;
ps = conn.prepareStatement("CREATE SCHEMA " + schema);
ps.execute();
cleanupConnection(conn, null, ps);
logger.exiting(CLASSNAME, "createSchema");
}
|
[
"private",
"void",
"createSchema",
"(",
")",
"throws",
"SQLException",
"{",
"logger",
".",
"entering",
"(",
"CLASSNAME",
",",
"\"createSchema\"",
")",
";",
"Connection",
"conn",
"=",
"getConnectionToDefaultSchema",
"(",
")",
";",
"logger",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"schema",
"+",
"\" schema does not exists. Trying to create it.\"",
")",
";",
"PreparedStatement",
"ps",
"=",
"null",
";",
"ps",
"=",
"conn",
".",
"prepareStatement",
"(",
"\"CREATE SCHEMA \"",
"+",
"schema",
")",
";",
"ps",
".",
"execute",
"(",
")",
";",
"cleanupConnection",
"(",
"conn",
",",
"null",
",",
"ps",
")",
";",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"createSchema\"",
")",
";",
"}"
] |
Creates the default schema JBATCH or the schema defined in batch-config.
@throws SQLException
|
[
"Creates",
"the",
"default",
"schema",
"JBATCH",
"or",
"the",
"schema",
"defined",
"in",
"batch",
"-",
"config",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L195-L206
|
4,049 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.checkAllTables
|
private void checkAllTables() throws SQLException {
logger.entering(CLASSNAME, "checkAllTables");
createIfNotExists(CHECKPOINTDATA_TABLE, CREATE_TAB_CHECKPOINTDATA);
executeStatement(CREATE_CHECKPOINTDATA_INDEX);
createIfNotExists(JOBINSTANCEDATA_TABLE, CREATE_TAB_JOBINSTANCEDATA);
createIfNotExists(EXECUTIONINSTANCEDATA_TABLE,
CREATE_TAB_EXECUTIONINSTANCEDATA);
createIfNotExists(STEPEXECUTIONINSTANCEDATA_TABLE,
CREATE_TAB_STEPEXECUTIONINSTANCEDATA);
createIfNotExists(JOBSTATUS_TABLE, CREATE_TAB_JOBSTATUS);
createIfNotExists(STEPSTATUS_TABLE, CREATE_TAB_STEPSTATUS);
logger.exiting(CLASSNAME, "checkAllTables");
}
|
java
|
private void checkAllTables() throws SQLException {
logger.entering(CLASSNAME, "checkAllTables");
createIfNotExists(CHECKPOINTDATA_TABLE, CREATE_TAB_CHECKPOINTDATA);
executeStatement(CREATE_CHECKPOINTDATA_INDEX);
createIfNotExists(JOBINSTANCEDATA_TABLE, CREATE_TAB_JOBINSTANCEDATA);
createIfNotExists(EXECUTIONINSTANCEDATA_TABLE,
CREATE_TAB_EXECUTIONINSTANCEDATA);
createIfNotExists(STEPEXECUTIONINSTANCEDATA_TABLE,
CREATE_TAB_STEPEXECUTIONINSTANCEDATA);
createIfNotExists(JOBSTATUS_TABLE, CREATE_TAB_JOBSTATUS);
createIfNotExists(STEPSTATUS_TABLE, CREATE_TAB_STEPSTATUS);
logger.exiting(CLASSNAME, "checkAllTables");
}
|
[
"private",
"void",
"checkAllTables",
"(",
")",
"throws",
"SQLException",
"{",
"logger",
".",
"entering",
"(",
"CLASSNAME",
",",
"\"checkAllTables\"",
")",
";",
"createIfNotExists",
"(",
"CHECKPOINTDATA_TABLE",
",",
"CREATE_TAB_CHECKPOINTDATA",
")",
";",
"executeStatement",
"(",
"CREATE_CHECKPOINTDATA_INDEX",
")",
";",
"createIfNotExists",
"(",
"JOBINSTANCEDATA_TABLE",
",",
"CREATE_TAB_JOBINSTANCEDATA",
")",
";",
"createIfNotExists",
"(",
"EXECUTIONINSTANCEDATA_TABLE",
",",
"CREATE_TAB_EXECUTIONINSTANCEDATA",
")",
";",
"createIfNotExists",
"(",
"STEPEXECUTIONINSTANCEDATA_TABLE",
",",
"CREATE_TAB_STEPEXECUTIONINSTANCEDATA",
")",
";",
"createIfNotExists",
"(",
"JOBSTATUS_TABLE",
",",
"CREATE_TAB_JOBSTATUS",
")",
";",
"createIfNotExists",
"(",
"STEPSTATUS_TABLE",
",",
"CREATE_TAB_STEPSTATUS",
")",
";",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"checkAllTables\"",
")",
";",
"}"
] |
Checks if all the runtime batch table exists. If not, it creates them.
@throws SQLException
|
[
"Checks",
"if",
"all",
"the",
"runtime",
"batch",
"table",
"exists",
".",
"If",
"not",
"it",
"creates",
"them",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L213-L229
|
4,050 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.createIfNotExists
|
private void createIfNotExists(String tableName, String createTableStatement) throws SQLException {
logger.entering(CLASSNAME, "createIfNotExists", new Object[] {tableName, createTableStatement});
Connection conn = getConnection();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getTables(null, schema, tableName, null);
PreparedStatement ps = null;
if(!rs.next()) {
logger.log(Level.INFO, tableName + " table does not exists. Trying to create it.");
ps = conn.prepareStatement(createTableStatement);
ps.executeUpdate();
}
cleanupConnection(conn, rs, ps);
logger.exiting(CLASSNAME, "createIfNotExists");
}
|
java
|
private void createIfNotExists(String tableName, String createTableStatement) throws SQLException {
logger.entering(CLASSNAME, "createIfNotExists", new Object[] {tableName, createTableStatement});
Connection conn = getConnection();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getTables(null, schema, tableName, null);
PreparedStatement ps = null;
if(!rs.next()) {
logger.log(Level.INFO, tableName + " table does not exists. Trying to create it.");
ps = conn.prepareStatement(createTableStatement);
ps.executeUpdate();
}
cleanupConnection(conn, rs, ps);
logger.exiting(CLASSNAME, "createIfNotExists");
}
|
[
"private",
"void",
"createIfNotExists",
"(",
"String",
"tableName",
",",
"String",
"createTableStatement",
")",
"throws",
"SQLException",
"{",
"logger",
".",
"entering",
"(",
"CLASSNAME",
",",
"\"createIfNotExists\"",
",",
"new",
"Object",
"[",
"]",
"{",
"tableName",
",",
"createTableStatement",
"}",
")",
";",
"Connection",
"conn",
"=",
"getConnection",
"(",
")",
";",
"DatabaseMetaData",
"dbmd",
"=",
"conn",
".",
"getMetaData",
"(",
")",
";",
"ResultSet",
"rs",
"=",
"dbmd",
".",
"getTables",
"(",
"null",
",",
"schema",
",",
"tableName",
",",
"null",
")",
";",
"PreparedStatement",
"ps",
"=",
"null",
";",
"if",
"(",
"!",
"rs",
".",
"next",
"(",
")",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"tableName",
"+",
"\" table does not exists. Trying to create it.\"",
")",
";",
"ps",
"=",
"conn",
".",
"prepareStatement",
"(",
"createTableStatement",
")",
";",
"ps",
".",
"executeUpdate",
"(",
")",
";",
"}",
"cleanupConnection",
"(",
"conn",
",",
"rs",
",",
"ps",
")",
";",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"createIfNotExists\"",
")",
";",
"}"
] |
Creates tableName using the createTableStatement DDL.
@param tableName
@param createTableStatement
@throws SQLException
|
[
"Creates",
"tableName",
"using",
"the",
"createTableStatement",
"DDL",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L238-L253
|
4,051 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.executeStatement
|
private void executeStatement(String statement) throws SQLException {
logger.entering(CLASSNAME, "executeStatement", statement);
Connection conn = getConnection();
PreparedStatement ps = null;
ps = conn.prepareStatement(statement);
ps.executeUpdate();
cleanupConnection(conn, ps);
logger.exiting(CLASSNAME, "executeStatement");
}
|
java
|
private void executeStatement(String statement) throws SQLException {
logger.entering(CLASSNAME, "executeStatement", statement);
Connection conn = getConnection();
PreparedStatement ps = null;
ps = conn.prepareStatement(statement);
ps.executeUpdate();
cleanupConnection(conn, ps);
logger.exiting(CLASSNAME, "executeStatement");
}
|
[
"private",
"void",
"executeStatement",
"(",
"String",
"statement",
")",
"throws",
"SQLException",
"{",
"logger",
".",
"entering",
"(",
"CLASSNAME",
",",
"\"executeStatement\"",
",",
"statement",
")",
";",
"Connection",
"conn",
"=",
"getConnection",
"(",
")",
";",
"PreparedStatement",
"ps",
"=",
"null",
";",
"ps",
"=",
"conn",
".",
"prepareStatement",
"(",
"statement",
")",
";",
"ps",
".",
"executeUpdate",
"(",
")",
";",
"cleanupConnection",
"(",
"conn",
",",
"ps",
")",
";",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"executeStatement\"",
")",
";",
"}"
] |
Executes the provided SQL statement
@param statement
@throws SQLException
|
[
"Executes",
"the",
"provided",
"SQL",
"statement"
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L261-L272
|
4,052 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.setSchemaOnConnection
|
private void setSchemaOnConnection(Connection connection) throws SQLException {
logger.finest("Entering " + CLASSNAME +".setSchemaOnConnection()");
String dbProductName = connection.getMetaData().getDatabaseProductName();
if (!"Oracle".equals(dbProductName) && !"Microsoft SQL Server".equals(dbProductName)) {
PreparedStatement ps = null;
if ("MySQL".equals(dbProductName)) {
ps = connection.prepareStatement("USE " + schema);
} else {
ps = connection.prepareStatement("SET SCHEMA ?");
ps.setString(1, schema);
}
ps.executeUpdate();
ps.close();
}
logger.finest("Exiting " + CLASSNAME +".setSchemaOnConnection()");
}
|
java
|
private void setSchemaOnConnection(Connection connection) throws SQLException {
logger.finest("Entering " + CLASSNAME +".setSchemaOnConnection()");
String dbProductName = connection.getMetaData().getDatabaseProductName();
if (!"Oracle".equals(dbProductName) && !"Microsoft SQL Server".equals(dbProductName)) {
PreparedStatement ps = null;
if ("MySQL".equals(dbProductName)) {
ps = connection.prepareStatement("USE " + schema);
} else {
ps = connection.prepareStatement("SET SCHEMA ?");
ps.setString(1, schema);
}
ps.executeUpdate();
ps.close();
}
logger.finest("Exiting " + CLASSNAME +".setSchemaOnConnection()");
}
|
[
"private",
"void",
"setSchemaOnConnection",
"(",
"Connection",
"connection",
")",
"throws",
"SQLException",
"{",
"logger",
".",
"finest",
"(",
"\"Entering \"",
"+",
"CLASSNAME",
"+",
"\".setSchemaOnConnection()\"",
")",
";",
"String",
"dbProductName",
"=",
"connection",
".",
"getMetaData",
"(",
")",
".",
"getDatabaseProductName",
"(",
")",
";",
"if",
"(",
"!",
"\"Oracle\"",
".",
"equals",
"(",
"dbProductName",
")",
"&&",
"!",
"\"Microsoft SQL Server\"",
".",
"equals",
"(",
"dbProductName",
")",
")",
"{",
"PreparedStatement",
"ps",
"=",
"null",
";",
"if",
"(",
"\"MySQL\"",
".",
"equals",
"(",
"dbProductName",
")",
")",
"{",
"ps",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"USE \"",
"+",
"schema",
")",
";",
"}",
"else",
"{",
"ps",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"SET SCHEMA ?\"",
")",
";",
"ps",
".",
"setString",
"(",
"1",
",",
"schema",
")",
";",
"}",
"ps",
".",
"executeUpdate",
"(",
")",
";",
"ps",
".",
"close",
"(",
")",
";",
"}",
"logger",
".",
"finest",
"(",
"\"Exiting \"",
"+",
"CLASSNAME",
"+",
"\".setSchemaOnConnection()\"",
")",
";",
"}"
] |
Set the default schema JBATCH or the schema defined in batch-config on the connection object.
@param connection
@throws SQLException
|
[
"Set",
"the",
"default",
"schema",
"JBATCH",
"or",
"the",
"schema",
"defined",
"in",
"batch",
"-",
"config",
"on",
"the",
"connection",
"object",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L392-L409
|
4,053 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.queryCheckpointData
|
private CheckpointData queryCheckpointData(Object key) {
logger.entering(CLASSNAME, "queryCheckpointData", new Object[] {key, SELECT_CHECKPOINTDATA});
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
ObjectInputStream objectIn = null;
CheckpointData data = null;
try {
conn = getConnection();
statement = conn.prepareStatement(SELECT_CHECKPOINTDATA);
statement.setObject(1, key);
rs = statement.executeQuery();
if (rs.next()) {
byte[] buf = rs.getBytes("obj");
data = (CheckpointData)deserializeObject(buf);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} catch (ClassNotFoundException e) {
throw new PersistenceException(e);
} finally {
if (objectIn != null) {
try {
objectIn.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
cleanupConnection(conn, rs, statement);
}
logger.exiting(CLASSNAME, "queryCheckpointData");
return data;
}
|
java
|
private CheckpointData queryCheckpointData(Object key) {
logger.entering(CLASSNAME, "queryCheckpointData", new Object[] {key, SELECT_CHECKPOINTDATA});
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
ObjectInputStream objectIn = null;
CheckpointData data = null;
try {
conn = getConnection();
statement = conn.prepareStatement(SELECT_CHECKPOINTDATA);
statement.setObject(1, key);
rs = statement.executeQuery();
if (rs.next()) {
byte[] buf = rs.getBytes("obj");
data = (CheckpointData)deserializeObject(buf);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} catch (ClassNotFoundException e) {
throw new PersistenceException(e);
} finally {
if (objectIn != null) {
try {
objectIn.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
cleanupConnection(conn, rs, statement);
}
logger.exiting(CLASSNAME, "queryCheckpointData");
return data;
}
|
[
"private",
"CheckpointData",
"queryCheckpointData",
"(",
"Object",
"key",
")",
"{",
"logger",
".",
"entering",
"(",
"CLASSNAME",
",",
"\"queryCheckpointData\"",
",",
"new",
"Object",
"[",
"]",
"{",
"key",
",",
"SELECT_CHECKPOINTDATA",
"}",
")",
";",
"Connection",
"conn",
"=",
"null",
";",
"PreparedStatement",
"statement",
"=",
"null",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"ObjectInputStream",
"objectIn",
"=",
"null",
";",
"CheckpointData",
"data",
"=",
"null",
";",
"try",
"{",
"conn",
"=",
"getConnection",
"(",
")",
";",
"statement",
"=",
"conn",
".",
"prepareStatement",
"(",
"SELECT_CHECKPOINTDATA",
")",
";",
"statement",
".",
"setObject",
"(",
"1",
",",
"key",
")",
";",
"rs",
"=",
"statement",
".",
"executeQuery",
"(",
")",
";",
"if",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"byte",
"[",
"]",
"buf",
"=",
"rs",
".",
"getBytes",
"(",
"\"obj\"",
")",
";",
"data",
"=",
"(",
"CheckpointData",
")",
"deserializeObject",
"(",
"buf",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"objectIn",
"!=",
"null",
")",
"{",
"try",
"{",
"objectIn",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"}",
"cleanupConnection",
"(",
"conn",
",",
"rs",
",",
"statement",
")",
";",
"}",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"queryCheckpointData\"",
")",
";",
"return",
"data",
";",
"}"
] |
select data from DB table
@param key - the IPersistenceDataKey object
@return List of serializable objects store in the DB table
Ex. select id, obj from tablename where id = ?
|
[
"select",
"data",
"from",
"DB",
"table"
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L419-L453
|
4,054 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.insertCheckpointData
|
private <T> void insertCheckpointData(Object key, T value) {
logger.entering(CLASSNAME, "insertCheckpointData", new Object[] {key, value});
Connection conn = null;
PreparedStatement statement = null;
ByteArrayOutputStream baos = null;
ObjectOutputStream oout = null;
byte[] b;
try {
conn = getConnection();
statement = conn.prepareStatement(INSERT_CHECKPOINTDATA);
baos = new ByteArrayOutputStream();
oout = new ObjectOutputStream(baos);
oout.writeObject(value);
b = baos.toByteArray();
statement.setObject(1, key);
statement.setBytes(2, b);
statement.executeUpdate();
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} finally {
if (baos != null) {
try {
baos.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
if (oout != null) {
try {
oout.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
cleanupConnection(conn, null, statement);
}
logger.exiting(CLASSNAME, "insertCheckpointData");
}
|
java
|
private <T> void insertCheckpointData(Object key, T value) {
logger.entering(CLASSNAME, "insertCheckpointData", new Object[] {key, value});
Connection conn = null;
PreparedStatement statement = null;
ByteArrayOutputStream baos = null;
ObjectOutputStream oout = null;
byte[] b;
try {
conn = getConnection();
statement = conn.prepareStatement(INSERT_CHECKPOINTDATA);
baos = new ByteArrayOutputStream();
oout = new ObjectOutputStream(baos);
oout.writeObject(value);
b = baos.toByteArray();
statement.setObject(1, key);
statement.setBytes(2, b);
statement.executeUpdate();
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} finally {
if (baos != null) {
try {
baos.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
if (oout != null) {
try {
oout.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
cleanupConnection(conn, null, statement);
}
logger.exiting(CLASSNAME, "insertCheckpointData");
}
|
[
"private",
"<",
"T",
">",
"void",
"insertCheckpointData",
"(",
"Object",
"key",
",",
"T",
"value",
")",
"{",
"logger",
".",
"entering",
"(",
"CLASSNAME",
",",
"\"insertCheckpointData\"",
",",
"new",
"Object",
"[",
"]",
"{",
"key",
",",
"value",
"}",
")",
";",
"Connection",
"conn",
"=",
"null",
";",
"PreparedStatement",
"statement",
"=",
"null",
";",
"ByteArrayOutputStream",
"baos",
"=",
"null",
";",
"ObjectOutputStream",
"oout",
"=",
"null",
";",
"byte",
"[",
"]",
"b",
";",
"try",
"{",
"conn",
"=",
"getConnection",
"(",
")",
";",
"statement",
"=",
"conn",
".",
"prepareStatement",
"(",
"INSERT_CHECKPOINTDATA",
")",
";",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"oout",
"=",
"new",
"ObjectOutputStream",
"(",
"baos",
")",
";",
"oout",
".",
"writeObject",
"(",
"value",
")",
";",
"b",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"statement",
".",
"setObject",
"(",
"1",
",",
"key",
")",
";",
"statement",
".",
"setBytes",
"(",
"2",
",",
"b",
")",
";",
"statement",
".",
"executeUpdate",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"baos",
"!=",
"null",
")",
"{",
"try",
"{",
"baos",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"}",
"if",
"(",
"oout",
"!=",
"null",
")",
"{",
"try",
"{",
"oout",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"}",
"cleanupConnection",
"(",
"conn",
",",
"null",
",",
"statement",
")",
";",
"}",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"insertCheckpointData\"",
")",
";",
"}"
] |
insert data to DB table
@param key - the IPersistenceDataKey object
@param value - serializable object to store
Ex. insert into tablename values(?, ?)
|
[
"insert",
"data",
"to",
"DB",
"table"
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L464-L505
|
4,055 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.cleanupConnection
|
private void cleanupConnection(Connection conn, ResultSet rs, PreparedStatement statement) {
logger.logp(Level.FINEST, CLASSNAME, "cleanupConnection", "Entering", new Object[] {conn, rs==null ? "<null>" : rs, statement==null ? "<null>" : statement});
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
try {
conn.close();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
}
logger.logp(Level.FINEST, CLASSNAME, "cleanupConnection", "Exiting");
}
|
java
|
private void cleanupConnection(Connection conn, ResultSet rs, PreparedStatement statement) {
logger.logp(Level.FINEST, CLASSNAME, "cleanupConnection", "Entering", new Object[] {conn, rs==null ? "<null>" : rs, statement==null ? "<null>" : statement});
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
try {
conn.close();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
}
logger.logp(Level.FINEST, CLASSNAME, "cleanupConnection", "Exiting");
}
|
[
"private",
"void",
"cleanupConnection",
"(",
"Connection",
"conn",
",",
"ResultSet",
"rs",
",",
"PreparedStatement",
"statement",
")",
"{",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINEST",
",",
"CLASSNAME",
",",
"\"cleanupConnection\"",
",",
"\"Entering\"",
",",
"new",
"Object",
"[",
"]",
"{",
"conn",
",",
"rs",
"==",
"null",
"?",
"\"<null>\"",
":",
"rs",
",",
"statement",
"==",
"null",
"?",
"\"<null>\"",
":",
"statement",
"}",
")",
";",
"if",
"(",
"statement",
"!=",
"null",
")",
"{",
"try",
"{",
"statement",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"}",
"if",
"(",
"rs",
"!=",
"null",
")",
"{",
"try",
"{",
"rs",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"}",
"if",
"(",
"conn",
"!=",
"null",
")",
"{",
"try",
"{",
"conn",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"conn",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINEST",
",",
"CLASSNAME",
",",
"\"cleanupConnection\"",
",",
"\"Exiting\"",
")",
";",
"}"
] |
closes connection, result set and statement
@param conn - connection object to close
@param rs - result set object to close
@param statement - statement object to close
|
[
"closes",
"connection",
"result",
"set",
"and",
"statement"
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L568-L602
|
4,056 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java
|
JDBCPersistenceManagerImpl.getPartitionLevelJobInstanceWildCard
|
private String getPartitionLevelJobInstanceWildCard(long rootJobInstanceId, String stepName) {
StringBuilder sb = new StringBuilder(":");
sb.append(Long.toString(rootJobInstanceId));
sb.append(":");
sb.append(stepName);
sb.append(":%");
return sb.toString();
}
|
java
|
private String getPartitionLevelJobInstanceWildCard(long rootJobInstanceId, String stepName) {
StringBuilder sb = new StringBuilder(":");
sb.append(Long.toString(rootJobInstanceId));
sb.append(":");
sb.append(stepName);
sb.append(":%");
return sb.toString();
}
|
[
"private",
"String",
"getPartitionLevelJobInstanceWildCard",
"(",
"long",
"rootJobInstanceId",
",",
"String",
"stepName",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"\":\"",
")",
";",
"sb",
".",
"append",
"(",
"Long",
".",
"toString",
"(",
"rootJobInstanceId",
")",
")",
";",
"sb",
".",
"append",
"(",
"\":\"",
")",
";",
"sb",
".",
"append",
"(",
"stepName",
")",
";",
"sb",
".",
"append",
"(",
"\":%\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Obviously would be nice if the code writing this special format were in the same place as this
code reading it.
Assumes format like:
JOBINSTANCEDATA
(jobinstanceid name, ...)
1197,"partitionMetrics","NOTSET"
1198,":1197:step1:0","NOTSET"
1199,":1197:step1:1","NOTSET"
1200,":1197:step2:0","NOTSET"
@param rootJobExecutionId JobExecution id of the top-level job
@param stepName Step name of the top-level stepName
|
[
"Obviously",
"would",
"be",
"nice",
"if",
"the",
"code",
"writing",
"this",
"special",
"format",
"were",
"in",
"the",
"same",
"place",
"as",
"this",
"code",
"reading",
"it",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L1919-L1928
|
4,057 |
overview/mime-types
|
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
|
MimeTypeDetector.unwrapFutureString
|
private static String unwrapFutureString(CompletionStage<String> future) throws GetBytesException {
try {
return future.toCompletableFuture().get();
} catch (Throwable e) {
if (e.getCause() instanceof GetBytesException) {
throw (GetBytesException) e.getCause();
}
throw new RuntimeException(e.getCause());
}
}
|
java
|
private static String unwrapFutureString(CompletionStage<String> future) throws GetBytesException {
try {
return future.toCompletableFuture().get();
} catch (Throwable e) {
if (e.getCause() instanceof GetBytesException) {
throw (GetBytesException) e.getCause();
}
throw new RuntimeException(e.getCause());
}
}
|
[
"private",
"static",
"String",
"unwrapFutureString",
"(",
"CompletionStage",
"<",
"String",
">",
"future",
")",
"throws",
"GetBytesException",
"{",
"try",
"{",
"return",
"future",
".",
"toCompletableFuture",
"(",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"if",
"(",
"e",
".",
"getCause",
"(",
")",
"instanceof",
"GetBytesException",
")",
"{",
"throw",
"(",
"GetBytesException",
")",
"e",
".",
"getCause",
"(",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"e",
".",
"getCause",
"(",
")",
")",
";",
"}",
"}"
] |
Waits for a CompletionStage, for non-async methods.
|
[
"Waits",
"for",
"a",
"CompletionStage",
"for",
"non",
"-",
"async",
"methods",
"."
] |
d5c45302049c0cd5e634a50954304d8ddeb9abb4
|
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L82-L91
|
4,058 |
overview/mime-types
|
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
|
MimeTypeDetector.detectMimeTypeAsync
|
public CompletionStage<String> detectMimeTypeAsync(String filename, Supplier<CompletionStage<byte[]>> getBytesAsync) {
Set<WeightedMimeType> weightedMimeTypes = filenameToWmts(filename);
Set<String> globMimeTypes = findBestMimeTypes(weightedMimeTypes);
if (globMimeTypes.size() == 1) {
return CompletableFuture.completedFuture(globMimeTypes.iterator().next());
}
return getBytesAsync.get()
.thenApply(bytes -> {
for (String magicMimeType : bytesToMimeTypes(bytes)) {
if (globMimeTypes.isEmpty()) {
return magicMimeType;
} else {
for (String globMimeType : globMimeTypes) {
if (isMimeTypeEqualOrSubclass(globMimeType, magicMimeType)) {
return globMimeType;
}
}
}
}
if (isText(bytes)) {
return "text/plain";
}
return "application/octet-stream";
})
.exceptionally(ex -> { throw new CompletionException(new GetBytesException(ex)); });
}
|
java
|
public CompletionStage<String> detectMimeTypeAsync(String filename, Supplier<CompletionStage<byte[]>> getBytesAsync) {
Set<WeightedMimeType> weightedMimeTypes = filenameToWmts(filename);
Set<String> globMimeTypes = findBestMimeTypes(weightedMimeTypes);
if (globMimeTypes.size() == 1) {
return CompletableFuture.completedFuture(globMimeTypes.iterator().next());
}
return getBytesAsync.get()
.thenApply(bytes -> {
for (String magicMimeType : bytesToMimeTypes(bytes)) {
if (globMimeTypes.isEmpty()) {
return magicMimeType;
} else {
for (String globMimeType : globMimeTypes) {
if (isMimeTypeEqualOrSubclass(globMimeType, magicMimeType)) {
return globMimeType;
}
}
}
}
if (isText(bytes)) {
return "text/plain";
}
return "application/octet-stream";
})
.exceptionally(ex -> { throw new CompletionException(new GetBytesException(ex)); });
}
|
[
"public",
"CompletionStage",
"<",
"String",
">",
"detectMimeTypeAsync",
"(",
"String",
"filename",
",",
"Supplier",
"<",
"CompletionStage",
"<",
"byte",
"[",
"]",
">",
">",
"getBytesAsync",
")",
"{",
"Set",
"<",
"WeightedMimeType",
">",
"weightedMimeTypes",
"=",
"filenameToWmts",
"(",
"filename",
")",
";",
"Set",
"<",
"String",
">",
"globMimeTypes",
"=",
"findBestMimeTypes",
"(",
"weightedMimeTypes",
")",
";",
"if",
"(",
"globMimeTypes",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"return",
"CompletableFuture",
".",
"completedFuture",
"(",
"globMimeTypes",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
")",
";",
"}",
"return",
"getBytesAsync",
".",
"get",
"(",
")",
".",
"thenApply",
"(",
"bytes",
"->",
"{",
"for",
"(",
"String",
"magicMimeType",
":",
"bytesToMimeTypes",
"(",
"bytes",
")",
")",
"{",
"if",
"(",
"globMimeTypes",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"magicMimeType",
";",
"}",
"else",
"{",
"for",
"(",
"String",
"globMimeType",
":",
"globMimeTypes",
")",
"{",
"if",
"(",
"isMimeTypeEqualOrSubclass",
"(",
"globMimeType",
",",
"magicMimeType",
")",
")",
"{",
"return",
"globMimeType",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"isText",
"(",
"bytes",
")",
")",
"{",
"return",
"\"text/plain\"",
";",
"}",
"return",
"\"application/octet-stream\"",
";",
"}",
")",
".",
"exceptionally",
"(",
"ex",
"->",
"{",
"throw",
"new",
"CompletionException",
"(",
"new",
"GetBytesException",
"(",
"ex",
")",
")",
";",
"}",
")",
";",
"}"
] |
Detects a MIME type from a filename and bytes.
<p>
This method follows the Shared Mime Info database's
<a href="http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#idm140625828606432">Recommended
Checking Order</a>. The only difference: it tests for
<tt>text/plain</tt> thoroughly, both by scanning more of the file and
by supporting many character sets.
</p>
<p>
getBytes() is a {@link java.util.concurrent.Callable} because it may or
may not be needed. A file named <tt>README</tt> will always be detected
as <tt>text/plain</tt>, for instance; a file named <tt>foo.doc</tt>
will need a magic-number check because it may be plain text or it may be
a Word document.
</p>
<p>
If you are creating your own {@code getBytesAsync} method, ensure its return
value is unpadded. (Use {@link java.util.Arrays#copyOf(byte[],int)} to truncate
it.) It needn't be any longer than {@link #getMaxGetBytesLength()}
bytes.
</p>
<p>
The CompletionStage may return a {@link ExecutionException} which is caused
by a {@link GetBytesException}. (That, in turn, will wrap a
{@link IOException} or other exception that prevented getBytesAsync() from
working.
</p>
@param filename Filename. To skip filename globbing, pass {@literal ""}
@param getBytesAsync Supplier that eventually returns a {@code byte[]}
@return Eventual MIME type String, falling back to <tt>"application/octet-stream</tt>"
|
[
"Detects",
"a",
"MIME",
"type",
"from",
"a",
"filename",
"and",
"bytes",
"."
] |
d5c45302049c0cd5e634a50954304d8ddeb9abb4
|
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L130-L159
|
4,059 |
overview/mime-types
|
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
|
MimeTypeDetector.detectMimeType
|
public String detectMimeType(String filename, Callable<byte[]> getBytes) throws GetBytesException {
Supplier<CompletionStage<byte[]>> supplier = () -> {
try {
return CompletableFuture.completedFuture(getBytes.call());
} catch (Exception ex) {
throw new CompletionException(ex);
}
};
return unwrapFutureString(detectMimeTypeAsync(filename, supplier));
}
|
java
|
public String detectMimeType(String filename, Callable<byte[]> getBytes) throws GetBytesException {
Supplier<CompletionStage<byte[]>> supplier = () -> {
try {
return CompletableFuture.completedFuture(getBytes.call());
} catch (Exception ex) {
throw new CompletionException(ex);
}
};
return unwrapFutureString(detectMimeTypeAsync(filename, supplier));
}
|
[
"public",
"String",
"detectMimeType",
"(",
"String",
"filename",
",",
"Callable",
"<",
"byte",
"[",
"]",
">",
"getBytes",
")",
"throws",
"GetBytesException",
"{",
"Supplier",
"<",
"CompletionStage",
"<",
"byte",
"[",
"]",
">",
">",
"supplier",
"=",
"(",
")",
"->",
"{",
"try",
"{",
"return",
"CompletableFuture",
".",
"completedFuture",
"(",
"getBytes",
".",
"call",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"CompletionException",
"(",
"ex",
")",
";",
"}",
"}",
";",
"return",
"unwrapFutureString",
"(",
"detectMimeTypeAsync",
"(",
"filename",
",",
"supplier",
")",
")",
";",
"}"
] |
Synchronously detects a MIME type from a filename and bytes.
<p>
This method follows the Shared Mime Info database's
<a href="http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#idm140625828606432">Recommended
Checking Order</a>. The only difference: it tests for
<tt>text/plain</tt> thoroughly, both by scanning more of the file and
by supporting many character sets.
</p>
<p>
getBytes() is a {@link java.util.concurrent.Callable} because it may or
may not be needed. A file named <tt>README</tt> will always be detected
as <tt>text/plain</tt>, for instance; a file named <tt>foo.doc</tt>
will need a magic-number check because it may be plain text or it may be
a Word document.
</p>
<p>
If you are creating your own {@code getBytes} method, ensure its return
value is unpadded. (Use {@link java.util.Arrays#copyOf(byte[],int)} to truncate
it.) It needn't be any longer than {@link #getMaxGetBytesLength()}
bytes.
</p>
@param filename Filename. To skip filename globbing, pass {@literal ""}
@param getBytes Callable that returns a {@code byte[]}
@return a MIME type such as {@literal "text/plain"}
@throws GetBytesException if {@code getBytes.call()} throws an Exception
|
[
"Synchronously",
"detects",
"a",
"MIME",
"type",
"from",
"a",
"filename",
"and",
"bytes",
"."
] |
d5c45302049c0cd5e634a50954304d8ddeb9abb4
|
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L192-L201
|
4,060 |
overview/mime-types
|
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
|
MimeTypeDetector.detectMimeType
|
public String detectMimeType(String filename, final InputStream is) throws GetBytesException {
Callable<byte[]> getBytes = new Callable<byte[]>() {
public byte[] call() throws IOException {
return inputStreamToFirstBytes(is);
}
};
return detectMimeType(filename, getBytes);
}
|
java
|
public String detectMimeType(String filename, final InputStream is) throws GetBytesException {
Callable<byte[]> getBytes = new Callable<byte[]>() {
public byte[] call() throws IOException {
return inputStreamToFirstBytes(is);
}
};
return detectMimeType(filename, getBytes);
}
|
[
"public",
"String",
"detectMimeType",
"(",
"String",
"filename",
",",
"final",
"InputStream",
"is",
")",
"throws",
"GetBytesException",
"{",
"Callable",
"<",
"byte",
"[",
"]",
">",
"getBytes",
"=",
"new",
"Callable",
"<",
"byte",
"[",
"]",
">",
"(",
")",
"{",
"public",
"byte",
"[",
"]",
"call",
"(",
")",
"throws",
"IOException",
"{",
"return",
"inputStreamToFirstBytes",
"(",
"is",
")",
";",
"}",
"}",
";",
"return",
"detectMimeType",
"(",
"filename",
",",
"getBytes",
")",
";",
"}"
] |
Determines the MIME type of a file with a given input stream.
<p>
The InputStream must exist. It must point to the beginning of the file
contents. And {@link java.io.InputStream#markSupported()} must return
{@literal true}. (When in doubt, pass a
{@link java.io.BufferedInputStream}.)
</p>
@param filename Name of file. To skip filename globbing, pass {@literal ""}
@param is InputStream that supports mark and reset.
@return a MIME type such as {@literal "text/plain"}
@throws GetBytesException if marking, reading or resetting the InputStream fails.
@see #detectMimeType(String, Callable)
|
[
"Determines",
"the",
"MIME",
"type",
"of",
"a",
"file",
"with",
"a",
"given",
"input",
"stream",
"."
] |
d5c45302049c0cd5e634a50954304d8ddeb9abb4
|
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L219-L227
|
4,061 |
overview/mime-types
|
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
|
MimeTypeDetector.detectMimeTypeAsync
|
public CompletionStage<String> detectMimeTypeAsync(final Path path) {
String filename = path.getFileName().toString();
Supplier<CompletionStage<byte[]>> supplier = () -> {
final CompletableFuture<byte[]> futureBytes = new CompletableFuture<byte[]>();
AsynchronousFileChannel channel;
try {
channel = AsynchronousFileChannel.open(path, StandardOpenOption.READ);
} catch (IOException e) {
futureBytes.completeExceptionally(new GetBytesException(e));
return futureBytes;
}
final ByteBuffer buf = ByteBuffer.allocate(getMaxGetBytesLength());
channel.read(buf, 0, futureBytes, new CompletionHandler<Integer, CompletableFuture<byte[]>>() {
@Override public void completed(Integer nBytes, CompletableFuture<byte[]> f) {
if (nBytes == -1) nBytes = 0; // handle empty file
byte[] bytes = new byte[nBytes];
buf.rewind();
buf.get(bytes, 0, nBytes);
f.complete(bytes);
}
@Override public void failed(Throwable exc, CompletableFuture<byte[]> f) {
f.completeExceptionally(new GetBytesException(exc));
}
});
return futureBytes;
};
return detectMimeTypeAsync(filename, supplier);
}
|
java
|
public CompletionStage<String> detectMimeTypeAsync(final Path path) {
String filename = path.getFileName().toString();
Supplier<CompletionStage<byte[]>> supplier = () -> {
final CompletableFuture<byte[]> futureBytes = new CompletableFuture<byte[]>();
AsynchronousFileChannel channel;
try {
channel = AsynchronousFileChannel.open(path, StandardOpenOption.READ);
} catch (IOException e) {
futureBytes.completeExceptionally(new GetBytesException(e));
return futureBytes;
}
final ByteBuffer buf = ByteBuffer.allocate(getMaxGetBytesLength());
channel.read(buf, 0, futureBytes, new CompletionHandler<Integer, CompletableFuture<byte[]>>() {
@Override public void completed(Integer nBytes, CompletableFuture<byte[]> f) {
if (nBytes == -1) nBytes = 0; // handle empty file
byte[] bytes = new byte[nBytes];
buf.rewind();
buf.get(bytes, 0, nBytes);
f.complete(bytes);
}
@Override public void failed(Throwable exc, CompletableFuture<byte[]> f) {
f.completeExceptionally(new GetBytesException(exc));
}
});
return futureBytes;
};
return detectMimeTypeAsync(filename, supplier);
}
|
[
"public",
"CompletionStage",
"<",
"String",
">",
"detectMimeTypeAsync",
"(",
"final",
"Path",
"path",
")",
"{",
"String",
"filename",
"=",
"path",
".",
"getFileName",
"(",
")",
".",
"toString",
"(",
")",
";",
"Supplier",
"<",
"CompletionStage",
"<",
"byte",
"[",
"]",
">",
">",
"supplier",
"=",
"(",
")",
"->",
"{",
"final",
"CompletableFuture",
"<",
"byte",
"[",
"]",
">",
"futureBytes",
"=",
"new",
"CompletableFuture",
"<",
"byte",
"[",
"]",
">",
"(",
")",
";",
"AsynchronousFileChannel",
"channel",
";",
"try",
"{",
"channel",
"=",
"AsynchronousFileChannel",
".",
"open",
"(",
"path",
",",
"StandardOpenOption",
".",
"READ",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"futureBytes",
".",
"completeExceptionally",
"(",
"new",
"GetBytesException",
"(",
"e",
")",
")",
";",
"return",
"futureBytes",
";",
"}",
"final",
"ByteBuffer",
"buf",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"getMaxGetBytesLength",
"(",
")",
")",
";",
"channel",
".",
"read",
"(",
"buf",
",",
"0",
",",
"futureBytes",
",",
"new",
"CompletionHandler",
"<",
"Integer",
",",
"CompletableFuture",
"<",
"byte",
"[",
"]",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"completed",
"(",
"Integer",
"nBytes",
",",
"CompletableFuture",
"<",
"byte",
"[",
"]",
">",
"f",
")",
"{",
"if",
"(",
"nBytes",
"==",
"-",
"1",
")",
"nBytes",
"=",
"0",
";",
"// handle empty file",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"nBytes",
"]",
";",
"buf",
".",
"rewind",
"(",
")",
";",
"buf",
".",
"get",
"(",
"bytes",
",",
"0",
",",
"nBytes",
")",
";",
"f",
".",
"complete",
"(",
"bytes",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"failed",
"(",
"Throwable",
"exc",
",",
"CompletableFuture",
"<",
"byte",
"[",
"]",
">",
"f",
")",
"{",
"f",
".",
"completeExceptionally",
"(",
"new",
"GetBytesException",
"(",
"exc",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"futureBytes",
";",
"}",
";",
"return",
"detectMimeTypeAsync",
"(",
"filename",
",",
"supplier",
")",
";",
"}"
] |
Determines the MIME type of a file.
<p>
The file must exist and be readable.
</p>
<p>
The CompletionStage may return a {@link ExecutionException} which is caused
by a {@link GetBytesException}. (That, in turn, will wrap a
{@link IOException} or other exception that prevented getBytesAsync() from
working.
</p>
@param path A file that exists and is readable
@return a MIME type such as {@literal "text/plain"}
@see #detectMimeType(String, Callable)
|
[
"Determines",
"the",
"MIME",
"type",
"of",
"a",
"file",
"."
] |
d5c45302049c0cd5e634a50954304d8ddeb9abb4
|
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L279-L312
|
4,062 |
overview/mime-types
|
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
|
MimeTypeDetector.matchletMagicCompareOr
|
private boolean matchletMagicCompareOr(int nMatchlets, int firstMatchletOffset, byte[] data) {
for (int i = 0, matchletOffset = firstMatchletOffset; i < nMatchlets; i++, matchletOffset += 32) {
if (matchletMagicCompare(matchletOffset, data)) {
return true;
}
}
return false;
}
|
java
|
private boolean matchletMagicCompareOr(int nMatchlets, int firstMatchletOffset, byte[] data) {
for (int i = 0, matchletOffset = firstMatchletOffset; i < nMatchlets; i++, matchletOffset += 32) {
if (matchletMagicCompare(matchletOffset, data)) {
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"matchletMagicCompareOr",
"(",
"int",
"nMatchlets",
",",
"int",
"firstMatchletOffset",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"matchletOffset",
"=",
"firstMatchletOffset",
";",
"i",
"<",
"nMatchlets",
";",
"i",
"++",
",",
"matchletOffset",
"+=",
"32",
")",
"{",
"if",
"(",
"matchletMagicCompare",
"(",
"matchletOffset",
",",
"data",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns whether one of the specified matchlets matches the data.
|
[
"Returns",
"whether",
"one",
"of",
"the",
"specified",
"matchlets",
"matches",
"the",
"data",
"."
] |
d5c45302049c0cd5e634a50954304d8ddeb9abb4
|
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L391-L399
|
4,063 |
overview/mime-types
|
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
|
MimeTypeDetector.subArraysEqual
|
private boolean subArraysEqual(byte[] a, int aStart, byte[] b, int bStart, int len) {
for (int i = aStart, j = bStart; len > 0; i++, j++, len--) {
if (a[i] != b[j]) {
return false;
}
}
return true;
}
|
java
|
private boolean subArraysEqual(byte[] a, int aStart, byte[] b, int bStart, int len) {
for (int i = aStart, j = bStart; len > 0; i++, j++, len--) {
if (a[i] != b[j]) {
return false;
}
}
return true;
}
|
[
"private",
"boolean",
"subArraysEqual",
"(",
"byte",
"[",
"]",
"a",
",",
"int",
"aStart",
",",
"byte",
"[",
"]",
"b",
",",
"int",
"bStart",
",",
"int",
"len",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"aStart",
",",
"j",
"=",
"bStart",
";",
"len",
">",
"0",
";",
"i",
"++",
",",
"j",
"++",
",",
"len",
"--",
")",
"{",
"if",
"(",
"a",
"[",
"i",
"]",
"!=",
"b",
"[",
"j",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Returns true if subarrays are equal.
|
[
"Returns",
"true",
"if",
"subarrays",
"are",
"equal",
"."
] |
d5c45302049c0cd5e634a50954304d8ddeb9abb4
|
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L404-L412
|
4,064 |
overview/mime-types
|
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
|
MimeTypeDetector.subArraysEqualWithMask
|
private boolean subArraysEqualWithMask(byte[] a, int aStart, byte[] b, int bStart, byte[] mask, int maskStart, int len) {
for (int i = aStart, j = bStart, k = maskStart; len > 0; i++, j++, k++, len--) {
if ((a[i] & mask[k]) != (b[j] & mask[k])) {
return false;
}
}
return true;
}
|
java
|
private boolean subArraysEqualWithMask(byte[] a, int aStart, byte[] b, int bStart, byte[] mask, int maskStart, int len) {
for (int i = aStart, j = bStart, k = maskStart; len > 0; i++, j++, k++, len--) {
if ((a[i] & mask[k]) != (b[j] & mask[k])) {
return false;
}
}
return true;
}
|
[
"private",
"boolean",
"subArraysEqualWithMask",
"(",
"byte",
"[",
"]",
"a",
",",
"int",
"aStart",
",",
"byte",
"[",
"]",
"b",
",",
"int",
"bStart",
",",
"byte",
"[",
"]",
"mask",
",",
"int",
"maskStart",
",",
"int",
"len",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"aStart",
",",
"j",
"=",
"bStart",
",",
"k",
"=",
"maskStart",
";",
"len",
">",
"0",
";",
"i",
"++",
",",
"j",
"++",
",",
"k",
"++",
",",
"len",
"--",
")",
"{",
"if",
"(",
"(",
"a",
"[",
"i",
"]",
"&",
"mask",
"[",
"k",
"]",
")",
"!=",
"(",
"b",
"[",
"j",
"]",
"&",
"mask",
"[",
"k",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Returns true if subarrays are equal, with the given mask.
<p>
The mask must have length <tt>len</tt>.
</p>
|
[
"Returns",
"true",
"if",
"subarrays",
"are",
"equal",
"with",
"the",
"given",
"mask",
"."
] |
d5c45302049c0cd5e634a50954304d8ddeb9abb4
|
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L421-L429
|
4,065 |
overview/mime-types
|
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
|
MimeTypeDetector.matchletMagicCompare
|
private boolean matchletMagicCompare(int offset, byte[] data) {
if (oneMatchletMagicEquals(offset, data)) {
int nChildren = content.getInt(offset + 24);
if (nChildren > 0) {
int firstChildOffset = content.getInt(offset + 28);
return matchletMagicCompareOr(nChildren, firstChildOffset, data);
} else {
return true;
}
} else {
return false;
}
}
|
java
|
private boolean matchletMagicCompare(int offset, byte[] data) {
if (oneMatchletMagicEquals(offset, data)) {
int nChildren = content.getInt(offset + 24);
if (nChildren > 0) {
int firstChildOffset = content.getInt(offset + 28);
return matchletMagicCompareOr(nChildren, firstChildOffset, data);
} else {
return true;
}
} else {
return false;
}
}
|
[
"private",
"boolean",
"matchletMagicCompare",
"(",
"int",
"offset",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"if",
"(",
"oneMatchletMagicEquals",
"(",
"offset",
",",
"data",
")",
")",
"{",
"int",
"nChildren",
"=",
"content",
".",
"getInt",
"(",
"offset",
"+",
"24",
")",
";",
"if",
"(",
"nChildren",
">",
"0",
")",
"{",
"int",
"firstChildOffset",
"=",
"content",
".",
"getInt",
"(",
"offset",
"+",
"28",
")",
";",
"return",
"matchletMagicCompareOr",
"(",
"nChildren",
",",
"firstChildOffset",
",",
"data",
")",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Returns whether data satisfies the matchlet and its children.
|
[
"Returns",
"whether",
"data",
"satisfies",
"the",
"matchlet",
"and",
"its",
"children",
"."
] |
d5c45302049c0cd5e634a50954304d8ddeb9abb4
|
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L466-L479
|
4,066 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/RetryHandler.java
|
RetryHandler.isRetryable
|
private boolean isRetryable(Exception e)
{
final String mName = "isRetryable";
String exClassName = e.getClass().getName();
boolean retVal = containsException(_retryIncludeExceptions, e) && !containsException(_retryExcludeExceptions, e);
if(logger.isLoggable(Level.FINE))
logger.logp(Level.FINE, className, mName, mName + ": " + retVal + ": " + exClassName);
return retVal;
}
|
java
|
private boolean isRetryable(Exception e)
{
final String mName = "isRetryable";
String exClassName = e.getClass().getName();
boolean retVal = containsException(_retryIncludeExceptions, e) && !containsException(_retryExcludeExceptions, e);
if(logger.isLoggable(Level.FINE))
logger.logp(Level.FINE, className, mName, mName + ": " + retVal + ": " + exClassName);
return retVal;
}
|
[
"private",
"boolean",
"isRetryable",
"(",
"Exception",
"e",
")",
"{",
"final",
"String",
"mName",
"=",
"\"isRetryable\"",
";",
"String",
"exClassName",
"=",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"boolean",
"retVal",
"=",
"containsException",
"(",
"_retryIncludeExceptions",
",",
"e",
")",
"&&",
"!",
"containsException",
"(",
"_retryExcludeExceptions",
",",
"e",
")",
";",
"if",
"(",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINE",
",",
"className",
",",
"mName",
",",
"mName",
"+",
"\": \"",
"+",
"retVal",
"+",
"\": \"",
"+",
"exClassName",
")",
";",
"return",
"retVal",
";",
"}"
] |
Check the retryable exception lists to determine whether
the given Exception is retryable.
|
[
"Check",
"the",
"retryable",
"exception",
"lists",
"to",
"determine",
"whether",
"the",
"given",
"Exception",
"is",
"retryable",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/RetryHandler.java#L327-L339
|
4,067 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.spi/src/main/java/com/ibm/jbatch/spi/BatchSPIManager.java
|
BatchSPIManager.registerPlatformMode
|
public void registerPlatformMode(PlatformMode mode) {
platformMode = mode;
if (mode.equals(PlatformMode.EE)) {
logger.config("Batch configured in EE mode by SPI, taking precedence over properties file");
} else if (mode.equals(PlatformMode.SE)) {
logger.config("Batch configured in SE mode by SPI, taking precedence over properties file");
}
}
|
java
|
public void registerPlatformMode(PlatformMode mode) {
platformMode = mode;
if (mode.equals(PlatformMode.EE)) {
logger.config("Batch configured in EE mode by SPI, taking precedence over properties file");
} else if (mode.equals(PlatformMode.SE)) {
logger.config("Batch configured in SE mode by SPI, taking precedence over properties file");
}
}
|
[
"public",
"void",
"registerPlatformMode",
"(",
"PlatformMode",
"mode",
")",
"{",
"platformMode",
"=",
"mode",
";",
"if",
"(",
"mode",
".",
"equals",
"(",
"PlatformMode",
".",
"EE",
")",
")",
"{",
"logger",
".",
"config",
"(",
"\"Batch configured in EE mode by SPI, taking precedence over properties file\"",
")",
";",
"}",
"else",
"if",
"(",
"mode",
".",
"equals",
"(",
"PlatformMode",
".",
"SE",
")",
")",
"{",
"logger",
".",
"config",
"(",
"\"Batch configured in SE mode by SPI, taking precedence over properties file\"",
")",
";",
"}",
"}"
] |
Override properties-file based config with programmatic setting of SE or EE
platform mode.
Note that by not calling this method, we do not get a given default behavior,
we simply defer to looking at other config mechanisms (properties files, etc.)
@param mode - Configures the batch runtime in EE mode or SE mode.
|
[
"Override",
"properties",
"-",
"file",
"based",
"config",
"with",
"programmatic",
"setting",
"of",
"SE",
"or",
"EE",
"platform",
"mode",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.spi/src/main/java/com/ibm/jbatch/spi/BatchSPIManager.java#L123-L132
|
4,068 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/SkipHandler.java
|
SkipHandler.isSkippable
|
private boolean isSkippable(Exception e)
{
final String mName = "isSkippable";
String exClassName = e.getClass().getName();
boolean retVal = containsSkippable(_skipIncludeExceptions, e) && !containsSkippable(_skipExcludeExceptions, e);
if(logger.isLoggable(Level.FINE))
logger.logp(Level.FINE, className, mName, mName + ": " + retVal + ": " + exClassName);
return retVal;
}
|
java
|
private boolean isSkippable(Exception e)
{
final String mName = "isSkippable";
String exClassName = e.getClass().getName();
boolean retVal = containsSkippable(_skipIncludeExceptions, e) && !containsSkippable(_skipExcludeExceptions, e);
if(logger.isLoggable(Level.FINE))
logger.logp(Level.FINE, className, mName, mName + ": " + retVal + ": " + exClassName);
return retVal;
}
|
[
"private",
"boolean",
"isSkippable",
"(",
"Exception",
"e",
")",
"{",
"final",
"String",
"mName",
"=",
"\"isSkippable\"",
";",
"String",
"exClassName",
"=",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"boolean",
"retVal",
"=",
"containsSkippable",
"(",
"_skipIncludeExceptions",
",",
"e",
")",
"&&",
"!",
"containsSkippable",
"(",
"_skipExcludeExceptions",
",",
"e",
")",
";",
"if",
"(",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINE",
",",
"className",
",",
"mName",
",",
"mName",
"+",
"\": \"",
"+",
"retVal",
"+",
"\": \"",
"+",
"exClassName",
")",
";",
"return",
"retVal",
";",
"}"
] |
Check the skipCount and skippable exception lists to determine whether
the given Exception is skippable.
|
[
"Check",
"the",
"skipCount",
"and",
"skippable",
"exception",
"lists",
"to",
"determine",
"whether",
"the",
"given",
"Exception",
"is",
"skippable",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/SkipHandler.java#L273-L285
|
4,069 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/SkipHandler.java
|
SkipHandler.containsSkippable
|
private boolean containsSkippable(Set<String> skipList, Exception e)
{
final String mName = "containsSkippable";
boolean retVal = false;
for ( Iterator it = skipList.iterator(); it.hasNext(); ) {
String exClassName = (String) it.next();
try {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
if (retVal = tccl.loadClass(exClassName).isInstance(e))
break;
} catch (ClassNotFoundException cnf) {
logger.logp(Level.FINE, className, mName, cnf.getLocalizedMessage());
}
}
if(logger.isLoggable(Level.FINE))
logger.logp(Level.FINE, className, mName, mName + ": " + retVal );
return retVal;
}
|
java
|
private boolean containsSkippable(Set<String> skipList, Exception e)
{
final String mName = "containsSkippable";
boolean retVal = false;
for ( Iterator it = skipList.iterator(); it.hasNext(); ) {
String exClassName = (String) it.next();
try {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
if (retVal = tccl.loadClass(exClassName).isInstance(e))
break;
} catch (ClassNotFoundException cnf) {
logger.logp(Level.FINE, className, mName, cnf.getLocalizedMessage());
}
}
if(logger.isLoggable(Level.FINE))
logger.logp(Level.FINE, className, mName, mName + ": " + retVal );
return retVal;
}
|
[
"private",
"boolean",
"containsSkippable",
"(",
"Set",
"<",
"String",
">",
"skipList",
",",
"Exception",
"e",
")",
"{",
"final",
"String",
"mName",
"=",
"\"containsSkippable\"",
";",
"boolean",
"retVal",
"=",
"false",
";",
"for",
"(",
"Iterator",
"it",
"=",
"skipList",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"exClassName",
"=",
"(",
"String",
")",
"it",
".",
"next",
"(",
")",
";",
"try",
"{",
"ClassLoader",
"tccl",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"if",
"(",
"retVal",
"=",
"tccl",
".",
"loadClass",
"(",
"exClassName",
")",
".",
"isInstance",
"(",
"e",
")",
")",
"break",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"cnf",
")",
"{",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINE",
",",
"className",
",",
"mName",
",",
"cnf",
".",
"getLocalizedMessage",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINE",
",",
"className",
",",
"mName",
",",
"mName",
"+",
"\": \"",
"+",
"retVal",
")",
";",
"return",
"retVal",
";",
"}"
] |
Check whether given exception is in skippable exception list
|
[
"Check",
"whether",
"given",
"exception",
"is",
"in",
"skippable",
"exception",
"list"
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/SkipHandler.java#L290-L310
|
4,070 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/ChunkStepControllerImpl.java
|
ChunkStepControllerImpl.processItem
|
private Object processItem(Object itemRead) {
logger.entering(sourceClass, "processItem", itemRead);
Object processedItem = null;
// if no processor defined for this chunk
if (processorProxy == null){
return itemRead;
}
try {
// call process listeners before and after the actual process call
for (ItemProcessListenerProxy processListenerProxy : itemProcessListeners) {
processListenerProxy.beforeProcess(itemRead);
}
processedItem = processorProxy.processItem(itemRead);
if (processedItem == null) {
currentItemStatus.setFiltered(true);
}
for (ItemProcessListenerProxy processListenerProxy : itemProcessListeners) {
processListenerProxy.afterProcess(itemRead, processedItem);
}
} catch (Exception e) {
for (ItemProcessListenerProxy processListenerProxy : itemProcessListeners) {
processListenerProxy.onProcessError(itemRead, e);
}
if(!currentChunkStatus.isRetryingAfterRollback()) {
if (retryProcessException(e, itemRead)) {
if (!retryHandler.isRollbackException(e)) {
processedItem = processItem(itemRead);
} else {
currentChunkStatus.markForRollbackWithRetry(e);
}
}
else if (skipProcessException(e, itemRead)) {
currentItemStatus.setSkipped(true);
stepContext.getMetric(MetricImpl.MetricType.PROCESS_SKIP_COUNT).incValue();
}
else {
throw new BatchContainerRuntimeException(e);
}
}
else {
if (skipProcessException(e, itemRead)) {
currentItemStatus.setSkipped(true);
stepContext.getMetric(MetricImpl.MetricType.PROCESS_SKIP_COUNT).incValue();
} else if (retryProcessException(e, itemRead)) {
if (!retryHandler.isRollbackException(e)) {
// retry without rollback
processedItem = processItem(itemRead);
} else {
// retry with rollback
currentChunkStatus.markForRollbackWithRetry(e);
}
} else {
throw new BatchContainerRuntimeException(e);
}
}
} catch (Throwable e) {
throw new BatchContainerRuntimeException(e);
}
logger.exiting(sourceClass, "processItem", processedItem==null ? "<null>" : processedItem);
return processedItem;
}
|
java
|
private Object processItem(Object itemRead) {
logger.entering(sourceClass, "processItem", itemRead);
Object processedItem = null;
// if no processor defined for this chunk
if (processorProxy == null){
return itemRead;
}
try {
// call process listeners before and after the actual process call
for (ItemProcessListenerProxy processListenerProxy : itemProcessListeners) {
processListenerProxy.beforeProcess(itemRead);
}
processedItem = processorProxy.processItem(itemRead);
if (processedItem == null) {
currentItemStatus.setFiltered(true);
}
for (ItemProcessListenerProxy processListenerProxy : itemProcessListeners) {
processListenerProxy.afterProcess(itemRead, processedItem);
}
} catch (Exception e) {
for (ItemProcessListenerProxy processListenerProxy : itemProcessListeners) {
processListenerProxy.onProcessError(itemRead, e);
}
if(!currentChunkStatus.isRetryingAfterRollback()) {
if (retryProcessException(e, itemRead)) {
if (!retryHandler.isRollbackException(e)) {
processedItem = processItem(itemRead);
} else {
currentChunkStatus.markForRollbackWithRetry(e);
}
}
else if (skipProcessException(e, itemRead)) {
currentItemStatus.setSkipped(true);
stepContext.getMetric(MetricImpl.MetricType.PROCESS_SKIP_COUNT).incValue();
}
else {
throw new BatchContainerRuntimeException(e);
}
}
else {
if (skipProcessException(e, itemRead)) {
currentItemStatus.setSkipped(true);
stepContext.getMetric(MetricImpl.MetricType.PROCESS_SKIP_COUNT).incValue();
} else if (retryProcessException(e, itemRead)) {
if (!retryHandler.isRollbackException(e)) {
// retry without rollback
processedItem = processItem(itemRead);
} else {
// retry with rollback
currentChunkStatus.markForRollbackWithRetry(e);
}
} else {
throw new BatchContainerRuntimeException(e);
}
}
} catch (Throwable e) {
throw new BatchContainerRuntimeException(e);
}
logger.exiting(sourceClass, "processItem", processedItem==null ? "<null>" : processedItem);
return processedItem;
}
|
[
"private",
"Object",
"processItem",
"(",
"Object",
"itemRead",
")",
"{",
"logger",
".",
"entering",
"(",
"sourceClass",
",",
"\"processItem\"",
",",
"itemRead",
")",
";",
"Object",
"processedItem",
"=",
"null",
";",
"// if no processor defined for this chunk\r",
"if",
"(",
"processorProxy",
"==",
"null",
")",
"{",
"return",
"itemRead",
";",
"}",
"try",
"{",
"// call process listeners before and after the actual process call\r",
"for",
"(",
"ItemProcessListenerProxy",
"processListenerProxy",
":",
"itemProcessListeners",
")",
"{",
"processListenerProxy",
".",
"beforeProcess",
"(",
"itemRead",
")",
";",
"}",
"processedItem",
"=",
"processorProxy",
".",
"processItem",
"(",
"itemRead",
")",
";",
"if",
"(",
"processedItem",
"==",
"null",
")",
"{",
"currentItemStatus",
".",
"setFiltered",
"(",
"true",
")",
";",
"}",
"for",
"(",
"ItemProcessListenerProxy",
"processListenerProxy",
":",
"itemProcessListeners",
")",
"{",
"processListenerProxy",
".",
"afterProcess",
"(",
"itemRead",
",",
"processedItem",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"for",
"(",
"ItemProcessListenerProxy",
"processListenerProxy",
":",
"itemProcessListeners",
")",
"{",
"processListenerProxy",
".",
"onProcessError",
"(",
"itemRead",
",",
"e",
")",
";",
"}",
"if",
"(",
"!",
"currentChunkStatus",
".",
"isRetryingAfterRollback",
"(",
")",
")",
"{",
"if",
"(",
"retryProcessException",
"(",
"e",
",",
"itemRead",
")",
")",
"{",
"if",
"(",
"!",
"retryHandler",
".",
"isRollbackException",
"(",
"e",
")",
")",
"{",
"processedItem",
"=",
"processItem",
"(",
"itemRead",
")",
";",
"}",
"else",
"{",
"currentChunkStatus",
".",
"markForRollbackWithRetry",
"(",
"e",
")",
";",
"}",
"}",
"else",
"if",
"(",
"skipProcessException",
"(",
"e",
",",
"itemRead",
")",
")",
"{",
"currentItemStatus",
".",
"setSkipped",
"(",
"true",
")",
";",
"stepContext",
".",
"getMetric",
"(",
"MetricImpl",
".",
"MetricType",
".",
"PROCESS_SKIP_COUNT",
")",
".",
"incValue",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BatchContainerRuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"skipProcessException",
"(",
"e",
",",
"itemRead",
")",
")",
"{",
"currentItemStatus",
".",
"setSkipped",
"(",
"true",
")",
";",
"stepContext",
".",
"getMetric",
"(",
"MetricImpl",
".",
"MetricType",
".",
"PROCESS_SKIP_COUNT",
")",
".",
"incValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"retryProcessException",
"(",
"e",
",",
"itemRead",
")",
")",
"{",
"if",
"(",
"!",
"retryHandler",
".",
"isRollbackException",
"(",
"e",
")",
")",
"{",
"// retry without rollback\r",
"processedItem",
"=",
"processItem",
"(",
"itemRead",
")",
";",
"}",
"else",
"{",
"// retry with rollback\r",
"currentChunkStatus",
".",
"markForRollbackWithRetry",
"(",
"e",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"BatchContainerRuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"throw",
"new",
"BatchContainerRuntimeException",
"(",
"e",
")",
";",
"}",
"logger",
".",
"exiting",
"(",
"sourceClass",
",",
"\"processItem\"",
",",
"processedItem",
"==",
"null",
"?",
"\"<null>\"",
":",
"processedItem",
")",
";",
"return",
"processedItem",
";",
"}"
] |
Process an item previously read by the reader
@param itemRead
the item read
@return the processed item
|
[
"Process",
"an",
"item",
"previously",
"read",
"by",
"the",
"reader"
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/ChunkStepControllerImpl.java#L394-L463
|
4,071 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/servicesmanager/ServicesManagerImpl.java
|
ServicesManagerImpl.initPlatformSEorEE
|
private void initPlatformSEorEE() {
String seMode = serviceImplClassNames.get(Name.JAVA_EDITION_IS_SE_DUMMY_SERVICE);
if (seMode.equalsIgnoreCase("true")) {
platformMode = PlatformMode.SE;
batchConfigImpl.setJ2seMode(true);
} else {
platformMode = PlatformMode.EE;
batchConfigImpl.setJ2seMode(false);
}
}
|
java
|
private void initPlatformSEorEE() {
String seMode = serviceImplClassNames.get(Name.JAVA_EDITION_IS_SE_DUMMY_SERVICE);
if (seMode.equalsIgnoreCase("true")) {
platformMode = PlatformMode.SE;
batchConfigImpl.setJ2seMode(true);
} else {
platformMode = PlatformMode.EE;
batchConfigImpl.setJ2seMode(false);
}
}
|
[
"private",
"void",
"initPlatformSEorEE",
"(",
")",
"{",
"String",
"seMode",
"=",
"serviceImplClassNames",
".",
"get",
"(",
"Name",
".",
"JAVA_EDITION_IS_SE_DUMMY_SERVICE",
")",
";",
"if",
"(",
"seMode",
".",
"equalsIgnoreCase",
"(",
"\"true\"",
")",
")",
"{",
"platformMode",
"=",
"PlatformMode",
".",
"SE",
";",
"batchConfigImpl",
".",
"setJ2seMode",
"(",
"true",
")",
";",
"}",
"else",
"{",
"platformMode",
"=",
"PlatformMode",
".",
"EE",
";",
"batchConfigImpl",
".",
"setJ2seMode",
"(",
"false",
")",
";",
"}",
"}"
] |
Push hardened config value onto batchConfigImpl and cache the value in a field.
|
[
"Push",
"hardened",
"config",
"value",
"onto",
"batchConfigImpl",
"and",
"cache",
"the",
"value",
"in",
"a",
"field",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/servicesmanager/ServicesManagerImpl.java#L285-L294
|
4,072 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/jsl/util/ValidatorHelper.java
|
ValidatorHelper.getXJCLSchema
|
public static synchronized Schema getXJCLSchema() {
if (schema == null) {
try {
URL url = ValidatorHelper.class.getResource("/" + SCHEMA_LOCATION);
schema = sf.newSchema(url);
} catch (SAXException e) {
throw new RuntimeException(e);
}
}
return schema;
}
|
java
|
public static synchronized Schema getXJCLSchema() {
if (schema == null) {
try {
URL url = ValidatorHelper.class.getResource("/" + SCHEMA_LOCATION);
schema = sf.newSchema(url);
} catch (SAXException e) {
throw new RuntimeException(e);
}
}
return schema;
}
|
[
"public",
"static",
"synchronized",
"Schema",
"getXJCLSchema",
"(",
")",
"{",
"if",
"(",
"schema",
"==",
"null",
")",
"{",
"try",
"{",
"URL",
"url",
"=",
"ValidatorHelper",
".",
"class",
".",
"getResource",
"(",
"\"/\"",
"+",
"SCHEMA_LOCATION",
")",
";",
"schema",
"=",
"sf",
".",
"newSchema",
"(",
"url",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"schema",
";",
"}"
] |
This method must be synchronized as SchemaFactory is not thread-safe
|
[
"This",
"method",
"must",
"be",
"synchronized",
"as",
"SchemaFactory",
"is",
"not",
"thread",
"-",
"safe"
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/jsl/util/ValidatorHelper.java#L39-L49
|
4,073 |
WASdev/standards.jsr352.jbatch
|
com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/SplitControllerImpl.java
|
SplitControllerImpl.buildSubJobBatchWorkUnits
|
private void buildSubJobBatchWorkUnits() {
List<Flow> flows = this.split.getFlows();
parallelBatchWorkUnits = new ArrayList<BatchFlowInSplitWorkUnit>();
// Build all sub jobs from flows in split
synchronized (subJobs) {
for (Flow flow : flows) {
subJobs.add(PartitionedStepBuilder.buildFlowInSplitSubJob(jobContext, this.split, flow));
}
// Go back to earlier idea that we may have seen this id before, and need a special "always restart" behavior
// for split-flows.
for (JSLJob job : subJobs) {
int count = batchKernel.getJobInstanceCount(job.getId());
FlowInSplitBuilderConfig config = new FlowInSplitBuilderConfig(job, completedWorkQueue, rootJobExecutionId);
if (count == 0) {
parallelBatchWorkUnits.add(batchKernel.buildNewFlowInSplitWorkUnit(config));
} else if (count == 1) {
parallelBatchWorkUnits.add(batchKernel.buildOnRestartFlowInSplitWorkUnit(config));
} else {
throw new IllegalStateException("There is an inconsistency somewhere in the internal subjob creation");
}
}
}
}
|
java
|
private void buildSubJobBatchWorkUnits() {
List<Flow> flows = this.split.getFlows();
parallelBatchWorkUnits = new ArrayList<BatchFlowInSplitWorkUnit>();
// Build all sub jobs from flows in split
synchronized (subJobs) {
for (Flow flow : flows) {
subJobs.add(PartitionedStepBuilder.buildFlowInSplitSubJob(jobContext, this.split, flow));
}
// Go back to earlier idea that we may have seen this id before, and need a special "always restart" behavior
// for split-flows.
for (JSLJob job : subJobs) {
int count = batchKernel.getJobInstanceCount(job.getId());
FlowInSplitBuilderConfig config = new FlowInSplitBuilderConfig(job, completedWorkQueue, rootJobExecutionId);
if (count == 0) {
parallelBatchWorkUnits.add(batchKernel.buildNewFlowInSplitWorkUnit(config));
} else if (count == 1) {
parallelBatchWorkUnits.add(batchKernel.buildOnRestartFlowInSplitWorkUnit(config));
} else {
throw new IllegalStateException("There is an inconsistency somewhere in the internal subjob creation");
}
}
}
}
|
[
"private",
"void",
"buildSubJobBatchWorkUnits",
"(",
")",
"{",
"List",
"<",
"Flow",
">",
"flows",
"=",
"this",
".",
"split",
".",
"getFlows",
"(",
")",
";",
"parallelBatchWorkUnits",
"=",
"new",
"ArrayList",
"<",
"BatchFlowInSplitWorkUnit",
">",
"(",
")",
";",
"// Build all sub jobs from flows in split\r",
"synchronized",
"(",
"subJobs",
")",
"{",
"for",
"(",
"Flow",
"flow",
":",
"flows",
")",
"{",
"subJobs",
".",
"add",
"(",
"PartitionedStepBuilder",
".",
"buildFlowInSplitSubJob",
"(",
"jobContext",
",",
"this",
".",
"split",
",",
"flow",
")",
")",
";",
"}",
"// Go back to earlier idea that we may have seen this id before, and need a special \"always restart\" behavior\r",
"// for split-flows.\r",
"for",
"(",
"JSLJob",
"job",
":",
"subJobs",
")",
"{",
"int",
"count",
"=",
"batchKernel",
".",
"getJobInstanceCount",
"(",
"job",
".",
"getId",
"(",
")",
")",
";",
"FlowInSplitBuilderConfig",
"config",
"=",
"new",
"FlowInSplitBuilderConfig",
"(",
"job",
",",
"completedWorkQueue",
",",
"rootJobExecutionId",
")",
";",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"parallelBatchWorkUnits",
".",
"add",
"(",
"batchKernel",
".",
"buildNewFlowInSplitWorkUnit",
"(",
"config",
")",
")",
";",
"}",
"else",
"if",
"(",
"count",
"==",
"1",
")",
"{",
"parallelBatchWorkUnits",
".",
"add",
"(",
"batchKernel",
".",
"buildOnRestartFlowInSplitWorkUnit",
"(",
"config",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"There is an inconsistency somewhere in the internal subjob creation\"",
")",
";",
"}",
"}",
"}",
"}"
] |
Note we restart all flows. There is no concept of "the flow completed". It is only steps
within the flows that may have already completed and so may not have needed to be rerun.
|
[
"Note",
"we",
"restart",
"all",
"flows",
".",
"There",
"is",
"no",
"concept",
"of",
"the",
"flow",
"completed",
".",
"It",
"is",
"only",
"steps",
"within",
"the",
"flows",
"that",
"may",
"have",
"already",
"completed",
"and",
"so",
"may",
"not",
"have",
"needed",
"to",
"be",
"rerun",
"."
] |
e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f
|
https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/SplitControllerImpl.java#L138-L163
|
4,074 |
weld/api
|
weld-spi/src/main/java/org/jboss/weld/bootstrap/api/SingletonProvider.java
|
SingletonProvider.initializeWithDefaultScope
|
private static void initializeWithDefaultScope() {
try {
Class<?> aClass = Class.forName(DEFAULT_SCOPE_FACTORY);
INSTANCE = (SingletonProvider) aClass.newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
java
|
private static void initializeWithDefaultScope() {
try {
Class<?> aClass = Class.forName(DEFAULT_SCOPE_FACTORY);
INSTANCE = (SingletonProvider) aClass.newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
[
"private",
"static",
"void",
"initializeWithDefaultScope",
"(",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"aClass",
"=",
"Class",
".",
"forName",
"(",
"DEFAULT_SCOPE_FACTORY",
")",
";",
"INSTANCE",
"=",
"(",
"SingletonProvider",
")",
"aClass",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Initialize with the default instance
|
[
"Initialize",
"with",
"the",
"default",
"instance"
] |
d28bafe36798e2c1dc6a69b6b9df14fd600f97d9
|
https://github.com/weld/api/blob/d28bafe36798e2c1dc6a69b6b9df14fd600f97d9/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/SingletonProvider.java#L75-L82
|
4,075 |
weld/api
|
weld-spi/src/main/java/org/jboss/weld/bootstrap/api/SingletonProvider.java
|
SingletonProvider.initialize
|
public static void initialize(SingletonProvider instance) {
synchronized (SingletonProvider.class) {
if (INSTANCE == null) {
INSTANCE = instance;
} else {
throw new RuntimeException("SingletonProvider is already initialized with " + INSTANCE);
}
}
}
|
java
|
public static void initialize(SingletonProvider instance) {
synchronized (SingletonProvider.class) {
if (INSTANCE == null) {
INSTANCE = instance;
} else {
throw new RuntimeException("SingletonProvider is already initialized with " + INSTANCE);
}
}
}
|
[
"public",
"static",
"void",
"initialize",
"(",
"SingletonProvider",
"instance",
")",
"{",
"synchronized",
"(",
"SingletonProvider",
".",
"class",
")",
"{",
"if",
"(",
"INSTANCE",
"==",
"null",
")",
"{",
"INSTANCE",
"=",
"instance",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"SingletonProvider is already initialized with \"",
"+",
"INSTANCE",
")",
";",
"}",
"}",
"}"
] |
Initialize with an explicit instance
@param instance the explicit instance
|
[
"Initialize",
"with",
"an",
"explicit",
"instance"
] |
d28bafe36798e2c1dc6a69b6b9df14fd600f97d9
|
https://github.com/weld/api/blob/d28bafe36798e2c1dc6a69b6b9df14fd600f97d9/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/SingletonProvider.java#L89-L97
|
4,076 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/functions/pca/PCoAnalysis.java
|
PCoAnalysis.getPcaData
|
private List<GraphResult> getPcaData(double[][] data, BiMap<Integer, String> dataNames) {
int rows = data.length;
int cols = data.length;
// Center the similarity matrix.
double matrixSum = 0;
double[] rowSums = new double[rows];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
matrixSum += data[i][j];
rowSums[i] += data[i][j];
}
}
double matrixMean = matrixSum / rows / cols;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
double rowMean = rowSums[i] / rows;
double colMean = rowSums[j] / rows;
data[i][j] = data[i][j] - rowMean - colMean + matrixMean;
}
}
// Determine the eigenvectors, and scale them so that their
// sum of squares equals their associated eigenvalue.
Matrix matrix = new Matrix(data);
EigenvalueDecomposition eig = matrix.eig();
Matrix eigenvectors = eig.getV();
double[] realEigenvalues = eig.getRealEigenvalues();
for (int j = 0; j < eigenvectors.getColumnDimension(); j++) {
double sumSquares = 0;
for (int i = 0; i < eigenvectors.getRowDimension(); i++) {
sumSquares += eigenvectors.get(i, j) * eigenvectors.get(i, j);
}
for (int i = 0; i < eigenvectors.getRowDimension(); i++) {
eigenvectors.set(i, j, eigenvectors.get(i,j) * Math.sqrt(realEigenvalues[j] / sumSquares));
}
}
// Find the indices of the top two eigenvalues.
int maxIndex = -1;
int secondIndex = -1;
double maxEigenvalue = 0;
double secondEigenvalue = 0;
for (int i = 0; i < realEigenvalues.length; i++) {
double eigenvector = realEigenvalues[i];
if (eigenvector > maxEigenvalue) {
secondEigenvalue = maxEigenvalue;
secondIndex = maxIndex;
maxEigenvalue = eigenvector;
maxIndex = i;
} else if (eigenvector > secondEigenvalue) {
secondEigenvalue = eigenvector;
secondIndex = i;
}
}
// Return projected data
List<GraphResult> results = Lists.newArrayList();
for (int i = 0; i < rows; i++) {
results.add(new GraphResult(dataNames.get(i),
eigenvectors.get(i, maxIndex), eigenvectors.get(i, secondIndex)));
}
return results;
}
|
java
|
private List<GraphResult> getPcaData(double[][] data, BiMap<Integer, String> dataNames) {
int rows = data.length;
int cols = data.length;
// Center the similarity matrix.
double matrixSum = 0;
double[] rowSums = new double[rows];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
matrixSum += data[i][j];
rowSums[i] += data[i][j];
}
}
double matrixMean = matrixSum / rows / cols;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
double rowMean = rowSums[i] / rows;
double colMean = rowSums[j] / rows;
data[i][j] = data[i][j] - rowMean - colMean + matrixMean;
}
}
// Determine the eigenvectors, and scale them so that their
// sum of squares equals their associated eigenvalue.
Matrix matrix = new Matrix(data);
EigenvalueDecomposition eig = matrix.eig();
Matrix eigenvectors = eig.getV();
double[] realEigenvalues = eig.getRealEigenvalues();
for (int j = 0; j < eigenvectors.getColumnDimension(); j++) {
double sumSquares = 0;
for (int i = 0; i < eigenvectors.getRowDimension(); i++) {
sumSquares += eigenvectors.get(i, j) * eigenvectors.get(i, j);
}
for (int i = 0; i < eigenvectors.getRowDimension(); i++) {
eigenvectors.set(i, j, eigenvectors.get(i,j) * Math.sqrt(realEigenvalues[j] / sumSquares));
}
}
// Find the indices of the top two eigenvalues.
int maxIndex = -1;
int secondIndex = -1;
double maxEigenvalue = 0;
double secondEigenvalue = 0;
for (int i = 0; i < realEigenvalues.length; i++) {
double eigenvector = realEigenvalues[i];
if (eigenvector > maxEigenvalue) {
secondEigenvalue = maxEigenvalue;
secondIndex = maxIndex;
maxEigenvalue = eigenvector;
maxIndex = i;
} else if (eigenvector > secondEigenvalue) {
secondEigenvalue = eigenvector;
secondIndex = i;
}
}
// Return projected data
List<GraphResult> results = Lists.newArrayList();
for (int i = 0; i < rows; i++) {
results.add(new GraphResult(dataNames.get(i),
eigenvectors.get(i, maxIndex), eigenvectors.get(i, secondIndex)));
}
return results;
}
|
[
"private",
"List",
"<",
"GraphResult",
">",
"getPcaData",
"(",
"double",
"[",
"]",
"[",
"]",
"data",
",",
"BiMap",
"<",
"Integer",
",",
"String",
">",
"dataNames",
")",
"{",
"int",
"rows",
"=",
"data",
".",
"length",
";",
"int",
"cols",
"=",
"data",
".",
"length",
";",
"// Center the similarity matrix.",
"double",
"matrixSum",
"=",
"0",
";",
"double",
"[",
"]",
"rowSums",
"=",
"new",
"double",
"[",
"rows",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"cols",
";",
"j",
"++",
")",
"{",
"matrixSum",
"+=",
"data",
"[",
"i",
"]",
"[",
"j",
"]",
";",
"rowSums",
"[",
"i",
"]",
"+=",
"data",
"[",
"i",
"]",
"[",
"j",
"]",
";",
"}",
"}",
"double",
"matrixMean",
"=",
"matrixSum",
"/",
"rows",
"/",
"cols",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"cols",
";",
"j",
"++",
")",
"{",
"double",
"rowMean",
"=",
"rowSums",
"[",
"i",
"]",
"/",
"rows",
";",
"double",
"colMean",
"=",
"rowSums",
"[",
"j",
"]",
"/",
"rows",
";",
"data",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"data",
"[",
"i",
"]",
"[",
"j",
"]",
"-",
"rowMean",
"-",
"colMean",
"+",
"matrixMean",
";",
"}",
"}",
"// Determine the eigenvectors, and scale them so that their",
"// sum of squares equals their associated eigenvalue.",
"Matrix",
"matrix",
"=",
"new",
"Matrix",
"(",
"data",
")",
";",
"EigenvalueDecomposition",
"eig",
"=",
"matrix",
".",
"eig",
"(",
")",
";",
"Matrix",
"eigenvectors",
"=",
"eig",
".",
"getV",
"(",
")",
";",
"double",
"[",
"]",
"realEigenvalues",
"=",
"eig",
".",
"getRealEigenvalues",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"eigenvectors",
".",
"getColumnDimension",
"(",
")",
";",
"j",
"++",
")",
"{",
"double",
"sumSquares",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"eigenvectors",
".",
"getRowDimension",
"(",
")",
";",
"i",
"++",
")",
"{",
"sumSquares",
"+=",
"eigenvectors",
".",
"get",
"(",
"i",
",",
"j",
")",
"*",
"eigenvectors",
".",
"get",
"(",
"i",
",",
"j",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"eigenvectors",
".",
"getRowDimension",
"(",
")",
";",
"i",
"++",
")",
"{",
"eigenvectors",
".",
"set",
"(",
"i",
",",
"j",
",",
"eigenvectors",
".",
"get",
"(",
"i",
",",
"j",
")",
"*",
"Math",
".",
"sqrt",
"(",
"realEigenvalues",
"[",
"j",
"]",
"/",
"sumSquares",
")",
")",
";",
"}",
"}",
"// Find the indices of the top two eigenvalues.",
"int",
"maxIndex",
"=",
"-",
"1",
";",
"int",
"secondIndex",
"=",
"-",
"1",
";",
"double",
"maxEigenvalue",
"=",
"0",
";",
"double",
"secondEigenvalue",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"realEigenvalues",
".",
"length",
";",
"i",
"++",
")",
"{",
"double",
"eigenvector",
"=",
"realEigenvalues",
"[",
"i",
"]",
";",
"if",
"(",
"eigenvector",
">",
"maxEigenvalue",
")",
"{",
"secondEigenvalue",
"=",
"maxEigenvalue",
";",
"secondIndex",
"=",
"maxIndex",
";",
"maxEigenvalue",
"=",
"eigenvector",
";",
"maxIndex",
"=",
"i",
";",
"}",
"else",
"if",
"(",
"eigenvector",
">",
"secondEigenvalue",
")",
"{",
"secondEigenvalue",
"=",
"eigenvector",
";",
"secondIndex",
"=",
"i",
";",
"}",
"}",
"// Return projected data",
"List",
"<",
"GraphResult",
">",
"results",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
";",
"i",
"++",
")",
"{",
"results",
".",
"add",
"(",
"new",
"GraphResult",
"(",
"dataNames",
".",
"get",
"(",
"i",
")",
",",
"eigenvectors",
".",
"get",
"(",
"i",
",",
"maxIndex",
")",
",",
"eigenvectors",
".",
"get",
"(",
"i",
",",
"secondIndex",
")",
")",
")",
";",
"}",
"return",
"results",
";",
"}"
] |
Convert the similarity matrix to an Eigen matrix.
|
[
"Convert",
"the",
"similarity",
"matrix",
"to",
"an",
"Eigen",
"matrix",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/functions/pca/PCoAnalysis.java#L127-L196
|
4,077 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/readers/bam/BAMShard.java
|
BAMShard.addBin
|
public void addBin(List<Chunk> chunksToAdd, long lastLocus) {
assert chunks != null;
contig = new Contig(contig.referenceName, contig.start, lastLocus);
chunks.addAll(chunksToAdd);
updateSpan();
}
|
java
|
public void addBin(List<Chunk> chunksToAdd, long lastLocus) {
assert chunks != null;
contig = new Contig(contig.referenceName, contig.start, lastLocus);
chunks.addAll(chunksToAdd);
updateSpan();
}
|
[
"public",
"void",
"addBin",
"(",
"List",
"<",
"Chunk",
">",
"chunksToAdd",
",",
"long",
"lastLocus",
")",
"{",
"assert",
"chunks",
"!=",
"null",
";",
"contig",
"=",
"new",
"Contig",
"(",
"contig",
".",
"referenceName",
",",
"contig",
".",
"start",
",",
"lastLocus",
")",
";",
"chunks",
".",
"addAll",
"(",
"chunksToAdd",
")",
";",
"updateSpan",
"(",
")",
";",
"}"
] |
Appends chunks from another bin to the list and moved the end position.
|
[
"Appends",
"chunks",
"from",
"another",
"bin",
"to",
"the",
"list",
"and",
"moved",
"the",
"end",
"position",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/readers/bam/BAMShard.java#L71-L76
|
4,078 |
googlegenomics/dataflow-java
|
src/main/java/htsjdk/samtools/BAMShardIndexer.java
|
BAMShardIndexer.finish
|
public long finish() {
final BAMIndexContent content = indexBuilder.processReference(referenceIndex);
outputWriter.writeReference(content);
outputWriter.close();
return indexBuilder.getNoCoordinateRecordCount();
}
|
java
|
public long finish() {
final BAMIndexContent content = indexBuilder.processReference(referenceIndex);
outputWriter.writeReference(content);
outputWriter.close();
return indexBuilder.getNoCoordinateRecordCount();
}
|
[
"public",
"long",
"finish",
"(",
")",
"{",
"final",
"BAMIndexContent",
"content",
"=",
"indexBuilder",
".",
"processReference",
"(",
"referenceIndex",
")",
";",
"outputWriter",
".",
"writeReference",
"(",
"content",
")",
";",
"outputWriter",
".",
"close",
"(",
")",
";",
"return",
"indexBuilder",
".",
"getNoCoordinateRecordCount",
"(",
")",
";",
"}"
] |
Finalizes writing and closes the file.
@return count of records with no coordinates.
|
[
"Finalizes",
"writing",
"and",
"closes",
"the",
"file",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/htsjdk/samtools/BAMShardIndexer.java#L42-L47
|
4,079 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/Solver.java
|
Solver.gridSearch
|
static Interval gridSearch(UnivariateFunction fn, double start,
double end, double step) {
double lowMax = start; // lower bound on interval surrounding alphaMax
double alphaMax = start - step;
double likMax = 0.0;
double lastAlpha = start;
double alpha = start;
while (alpha < end) {
double likelihood = fn.value(alpha);
if (alphaMax < start || likelihood > likMax) {
lowMax = lastAlpha;
alphaMax = alpha;
likMax = likelihood;
}
lastAlpha = alpha;
alpha += step;
}
// make sure we've checked the rightmost endpoint (won't happen if
// end - start is not an integer multiple of step, because of roundoff
// errors, etc)
double likelihood = fn.value(end);
if (likelihood > likMax) {
lowMax = lastAlpha;
alphaMax = end;
likMax = likelihood;
}
return new Interval(lowMax, Math.min(end, alphaMax + step));
}
|
java
|
static Interval gridSearch(UnivariateFunction fn, double start,
double end, double step) {
double lowMax = start; // lower bound on interval surrounding alphaMax
double alphaMax = start - step;
double likMax = 0.0;
double lastAlpha = start;
double alpha = start;
while (alpha < end) {
double likelihood = fn.value(alpha);
if (alphaMax < start || likelihood > likMax) {
lowMax = lastAlpha;
alphaMax = alpha;
likMax = likelihood;
}
lastAlpha = alpha;
alpha += step;
}
// make sure we've checked the rightmost endpoint (won't happen if
// end - start is not an integer multiple of step, because of roundoff
// errors, etc)
double likelihood = fn.value(end);
if (likelihood > likMax) {
lowMax = lastAlpha;
alphaMax = end;
likMax = likelihood;
}
return new Interval(lowMax, Math.min(end, alphaMax + step));
}
|
[
"static",
"Interval",
"gridSearch",
"(",
"UnivariateFunction",
"fn",
",",
"double",
"start",
",",
"double",
"end",
",",
"double",
"step",
")",
"{",
"double",
"lowMax",
"=",
"start",
";",
"// lower bound on interval surrounding alphaMax",
"double",
"alphaMax",
"=",
"start",
"-",
"step",
";",
"double",
"likMax",
"=",
"0.0",
";",
"double",
"lastAlpha",
"=",
"start",
";",
"double",
"alpha",
"=",
"start",
";",
"while",
"(",
"alpha",
"<",
"end",
")",
"{",
"double",
"likelihood",
"=",
"fn",
".",
"value",
"(",
"alpha",
")",
";",
"if",
"(",
"alphaMax",
"<",
"start",
"||",
"likelihood",
">",
"likMax",
")",
"{",
"lowMax",
"=",
"lastAlpha",
";",
"alphaMax",
"=",
"alpha",
";",
"likMax",
"=",
"likelihood",
";",
"}",
"lastAlpha",
"=",
"alpha",
";",
"alpha",
"+=",
"step",
";",
"}",
"// make sure we've checked the rightmost endpoint (won't happen if",
"// end - start is not an integer multiple of step, because of roundoff",
"// errors, etc)",
"double",
"likelihood",
"=",
"fn",
".",
"value",
"(",
"end",
")",
";",
"if",
"(",
"likelihood",
">",
"likMax",
")",
"{",
"lowMax",
"=",
"lastAlpha",
";",
"alphaMax",
"=",
"end",
";",
"likMax",
"=",
"likelihood",
";",
"}",
"return",
"new",
"Interval",
"(",
"lowMax",
",",
"Math",
".",
"min",
"(",
"end",
",",
"alphaMax",
"+",
"step",
")",
")",
";",
"}"
] |
Runs a grid search for the maximum value of a univariate function.
@param fn the likelihood function to minimize
@param start lower bound of the interval to search
@param end upper bound of the interval to search
@param step grid step size
@return an Interval bracketing the minimum
|
[
"Runs",
"a",
"grid",
"search",
"for",
"the",
"maximum",
"value",
"of",
"a",
"univariate",
"function",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/Solver.java#L42-L70
|
4,080 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/Solver.java
|
Solver.maximize
|
public static double maximize(UnivariateFunction fn, double gridStart, double gridEnd,
double gridStep, double relErr, double absErr, int maxIter, int maxEval) {
Interval interval = gridSearch(fn, gridStart, gridEnd, gridStep);
BrentOptimizer bo = new BrentOptimizer(relErr, absErr);
UnivariatePointValuePair max = bo.optimize(
new MaxIter(maxIter),
new MaxEval(maxEval),
new SearchInterval(interval.getInf(), interval.getSup()),
new UnivariateObjectiveFunction(fn),
GoalType.MAXIMIZE);
return max.getPoint();
}
|
java
|
public static double maximize(UnivariateFunction fn, double gridStart, double gridEnd,
double gridStep, double relErr, double absErr, int maxIter, int maxEval) {
Interval interval = gridSearch(fn, gridStart, gridEnd, gridStep);
BrentOptimizer bo = new BrentOptimizer(relErr, absErr);
UnivariatePointValuePair max = bo.optimize(
new MaxIter(maxIter),
new MaxEval(maxEval),
new SearchInterval(interval.getInf(), interval.getSup()),
new UnivariateObjectiveFunction(fn),
GoalType.MAXIMIZE);
return max.getPoint();
}
|
[
"public",
"static",
"double",
"maximize",
"(",
"UnivariateFunction",
"fn",
",",
"double",
"gridStart",
",",
"double",
"gridEnd",
",",
"double",
"gridStep",
",",
"double",
"relErr",
",",
"double",
"absErr",
",",
"int",
"maxIter",
",",
"int",
"maxEval",
")",
"{",
"Interval",
"interval",
"=",
"gridSearch",
"(",
"fn",
",",
"gridStart",
",",
"gridEnd",
",",
"gridStep",
")",
";",
"BrentOptimizer",
"bo",
"=",
"new",
"BrentOptimizer",
"(",
"relErr",
",",
"absErr",
")",
";",
"UnivariatePointValuePair",
"max",
"=",
"bo",
".",
"optimize",
"(",
"new",
"MaxIter",
"(",
"maxIter",
")",
",",
"new",
"MaxEval",
"(",
"maxEval",
")",
",",
"new",
"SearchInterval",
"(",
"interval",
".",
"getInf",
"(",
")",
",",
"interval",
".",
"getSup",
"(",
")",
")",
",",
"new",
"UnivariateObjectiveFunction",
"(",
"fn",
")",
",",
"GoalType",
".",
"MAXIMIZE",
")",
";",
"return",
"max",
".",
"getPoint",
"(",
")",
";",
"}"
] |
Maximizes a univariate function using a grid search followed by Brent's algorithm.
@param fn the likelihood function to minimize
@param gridStart the lower bound for the grid search
@param gridEnd the upper bound for the grid search
@param gridStep step size for the grid search
@param relErr relative error tolerance for Brent's algorithm
@param absErr absolute error tolerance for Brent's algorithm
@param maxIter maximum # of iterations to perform in Brent's algorithm
@param maxEval maximum # of Likelihood function evaluations in Brent's algorithm
@return the value of the parameter that maximizes the function
|
[
"Maximizes",
"a",
"univariate",
"function",
"using",
"a",
"grid",
"search",
"followed",
"by",
"Brent",
"s",
"algorithm",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/Solver.java#L86-L97
|
4,081 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/readers/bam/Reader.java
|
Reader.passesFilter
|
static boolean passesFilter(SAMRecord record, Filter filter,
String referenceName) {
// If we are looking for only mapped or only unmapped reads then we will use
// the UnmappedFlag to decide if this read should be rejected.
if (filter == Filter.UNMAPPED_ONLY && !record.getReadUnmappedFlag()) {
return false;
}
if (filter == Filter.MAPPED_ONLY && record.getReadUnmappedFlag()) {
return false;
}
// If we are looking for mapped reads, then we check the reference name
// of the read matches the one we are looking for.
final boolean referenceNameMismatch = referenceName != null &&
!referenceName.isEmpty() &&
!referenceName.equals(record.getReferenceName());
// Note that unmapped mate pair of mapped read will have a reference
// name set to the reference of its mapped mate.
if ((filter == Filter.MAPPED_ONLY || filter == Filter.MAPPED_AND_UNMAPPED)
&& referenceNameMismatch) {
return false;
}
return true;
}
|
java
|
static boolean passesFilter(SAMRecord record, Filter filter,
String referenceName) {
// If we are looking for only mapped or only unmapped reads then we will use
// the UnmappedFlag to decide if this read should be rejected.
if (filter == Filter.UNMAPPED_ONLY && !record.getReadUnmappedFlag()) {
return false;
}
if (filter == Filter.MAPPED_ONLY && record.getReadUnmappedFlag()) {
return false;
}
// If we are looking for mapped reads, then we check the reference name
// of the read matches the one we are looking for.
final boolean referenceNameMismatch = referenceName != null &&
!referenceName.isEmpty() &&
!referenceName.equals(record.getReferenceName());
// Note that unmapped mate pair of mapped read will have a reference
// name set to the reference of its mapped mate.
if ((filter == Filter.MAPPED_ONLY || filter == Filter.MAPPED_AND_UNMAPPED)
&& referenceNameMismatch) {
return false;
}
return true;
}
|
[
"static",
"boolean",
"passesFilter",
"(",
"SAMRecord",
"record",
",",
"Filter",
"filter",
",",
"String",
"referenceName",
")",
"{",
"// If we are looking for only mapped or only unmapped reads then we will use",
"// the UnmappedFlag to decide if this read should be rejected.",
"if",
"(",
"filter",
"==",
"Filter",
".",
"UNMAPPED_ONLY",
"&&",
"!",
"record",
".",
"getReadUnmappedFlag",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"filter",
"==",
"Filter",
".",
"MAPPED_ONLY",
"&&",
"record",
".",
"getReadUnmappedFlag",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// If we are looking for mapped reads, then we check the reference name",
"// of the read matches the one we are looking for.",
"final",
"boolean",
"referenceNameMismatch",
"=",
"referenceName",
"!=",
"null",
"&&",
"!",
"referenceName",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"referenceName",
".",
"equals",
"(",
"record",
".",
"getReferenceName",
"(",
")",
")",
";",
"// Note that unmapped mate pair of mapped read will have a reference",
"// name set to the reference of its mapped mate.",
"if",
"(",
"(",
"filter",
"==",
"Filter",
".",
"MAPPED_ONLY",
"||",
"filter",
"==",
"Filter",
".",
"MAPPED_AND_UNMAPPED",
")",
"&&",
"referenceNameMismatch",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if the record matches our filter.
|
[
"Checks",
"if",
"the",
"record",
"matches",
"our",
"filter",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/readers/bam/Reader.java#L133-L159
|
4,082 |
googlegenomics/dataflow-java
|
src/main/java/htsjdk/samtools/BinaryBAMShardIndexWriter.java
|
BinaryBAMShardIndexWriter.writeReference
|
@Override
public void writeReference(final BAMIndexContent content) {
if (content == null) {
writeNullContent();
return;
}
// write bins
final BAMIndexContent.BinList bins = content.getBins();
final int size = bins == null ? 0 : content.getNumberOfNonNullBins();
if (size == 0) {
writeNullContent();
return;
}
//final List<Chunk> chunks = content.getMetaData() == null ? null
// : content.getMetaData().getMetaDataChunks();
final BAMIndexMetaData metaData = content.getMetaData();
codec.writeInt(size + ((metaData != null)? 1 : 0 ));
// codec.writeInt(size);
for (final Bin bin : bins) { // note, bins will always be sorted
if (bin.getBinNumber() == GenomicIndexUtil.MAX_BINS)
continue;
writeBin(bin);
}
// write metadata "bin" and chunks
if (metaData != null)
writeChunkMetaData(metaData);
// write linear index
final LinearIndex linearIndex = content.getLinearIndex();
final long[] entries = linearIndex == null ? null : linearIndex.getIndexEntries();
final int indexStart = linearIndex == null ? 0 : linearIndex.getIndexStart();
final int n_intv = entries == null ? indexStart : entries.length + indexStart;
codec.writeInt(n_intv);
if (entries == null) {
return;
}
// since indexStart is usually 0, this is usually a no-op
for (int i = 0; i < indexStart; i++) {
codec.writeLong(0);
}
for (int k = 0; k < entries.length; k++) {
codec.writeLong(entries[k]);
}
try {
codec.getOutputStream().flush();
} catch (final IOException e) {
throw new SAMException("IOException in BinaryBAMIndexWriter reference " + content.getReferenceSequence(), e);
}
}
|
java
|
@Override
public void writeReference(final BAMIndexContent content) {
if (content == null) {
writeNullContent();
return;
}
// write bins
final BAMIndexContent.BinList bins = content.getBins();
final int size = bins == null ? 0 : content.getNumberOfNonNullBins();
if (size == 0) {
writeNullContent();
return;
}
//final List<Chunk> chunks = content.getMetaData() == null ? null
// : content.getMetaData().getMetaDataChunks();
final BAMIndexMetaData metaData = content.getMetaData();
codec.writeInt(size + ((metaData != null)? 1 : 0 ));
// codec.writeInt(size);
for (final Bin bin : bins) { // note, bins will always be sorted
if (bin.getBinNumber() == GenomicIndexUtil.MAX_BINS)
continue;
writeBin(bin);
}
// write metadata "bin" and chunks
if (metaData != null)
writeChunkMetaData(metaData);
// write linear index
final LinearIndex linearIndex = content.getLinearIndex();
final long[] entries = linearIndex == null ? null : linearIndex.getIndexEntries();
final int indexStart = linearIndex == null ? 0 : linearIndex.getIndexStart();
final int n_intv = entries == null ? indexStart : entries.length + indexStart;
codec.writeInt(n_intv);
if (entries == null) {
return;
}
// since indexStart is usually 0, this is usually a no-op
for (int i = 0; i < indexStart; i++) {
codec.writeLong(0);
}
for (int k = 0; k < entries.length; k++) {
codec.writeLong(entries[k]);
}
try {
codec.getOutputStream().flush();
} catch (final IOException e) {
throw new SAMException("IOException in BinaryBAMIndexWriter reference " + content.getReferenceSequence(), e);
}
}
|
[
"@",
"Override",
"public",
"void",
"writeReference",
"(",
"final",
"BAMIndexContent",
"content",
")",
"{",
"if",
"(",
"content",
"==",
"null",
")",
"{",
"writeNullContent",
"(",
")",
";",
"return",
";",
"}",
"// write bins",
"final",
"BAMIndexContent",
".",
"BinList",
"bins",
"=",
"content",
".",
"getBins",
"(",
")",
";",
"final",
"int",
"size",
"=",
"bins",
"==",
"null",
"?",
"0",
":",
"content",
".",
"getNumberOfNonNullBins",
"(",
")",
";",
"if",
"(",
"size",
"==",
"0",
")",
"{",
"writeNullContent",
"(",
")",
";",
"return",
";",
"}",
"//final List<Chunk> chunks = content.getMetaData() == null ? null",
"// : content.getMetaData().getMetaDataChunks();",
"final",
"BAMIndexMetaData",
"metaData",
"=",
"content",
".",
"getMetaData",
"(",
")",
";",
"codec",
".",
"writeInt",
"(",
"size",
"+",
"(",
"(",
"metaData",
"!=",
"null",
")",
"?",
"1",
":",
"0",
")",
")",
";",
"// codec.writeInt(size);",
"for",
"(",
"final",
"Bin",
"bin",
":",
"bins",
")",
"{",
"// note, bins will always be sorted",
"if",
"(",
"bin",
".",
"getBinNumber",
"(",
")",
"==",
"GenomicIndexUtil",
".",
"MAX_BINS",
")",
"continue",
";",
"writeBin",
"(",
"bin",
")",
";",
"}",
"// write metadata \"bin\" and chunks ",
"if",
"(",
"metaData",
"!=",
"null",
")",
"writeChunkMetaData",
"(",
"metaData",
")",
";",
"// write linear index",
"final",
"LinearIndex",
"linearIndex",
"=",
"content",
".",
"getLinearIndex",
"(",
")",
";",
"final",
"long",
"[",
"]",
"entries",
"=",
"linearIndex",
"==",
"null",
"?",
"null",
":",
"linearIndex",
".",
"getIndexEntries",
"(",
")",
";",
"final",
"int",
"indexStart",
"=",
"linearIndex",
"==",
"null",
"?",
"0",
":",
"linearIndex",
".",
"getIndexStart",
"(",
")",
";",
"final",
"int",
"n_intv",
"=",
"entries",
"==",
"null",
"?",
"indexStart",
":",
"entries",
".",
"length",
"+",
"indexStart",
";",
"codec",
".",
"writeInt",
"(",
"n_intv",
")",
";",
"if",
"(",
"entries",
"==",
"null",
")",
"{",
"return",
";",
"}",
"// since indexStart is usually 0, this is usually a no-op",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"indexStart",
";",
"i",
"++",
")",
"{",
"codec",
".",
"writeLong",
"(",
"0",
")",
";",
"}",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"entries",
".",
"length",
";",
"k",
"++",
")",
"{",
"codec",
".",
"writeLong",
"(",
"entries",
"[",
"k",
"]",
")",
";",
"}",
"try",
"{",
"codec",
".",
"getOutputStream",
"(",
")",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SAMException",
"(",
"\"IOException in BinaryBAMIndexWriter reference \"",
"+",
"content",
".",
"getReferenceSequence",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Write this content as binary output
|
[
"Write",
"this",
"content",
"as",
"binary",
"output"
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/htsjdk/samtools/BinaryBAMShardIndexWriter.java#L37-L93
|
4,083 |
googlegenomics/dataflow-java
|
src/main/java/htsjdk/samtools/BinaryBAMShardIndexWriter.java
|
BinaryBAMShardIndexWriter.writeChunkMetaData
|
private void writeChunkMetaData(final BAMIndexMetaData metaData) {
codec.writeInt(GenomicIndexUtil.MAX_BINS);
final int nChunk = 2;
codec.writeInt(nChunk);
codec.writeLong(metaData.getFirstOffset());
codec.writeLong(metaData.getLastOffset());
codec.writeLong(metaData.getAlignedRecordCount());
codec.writeLong(metaData.getUnalignedRecordCount());
}
|
java
|
private void writeChunkMetaData(final BAMIndexMetaData metaData) {
codec.writeInt(GenomicIndexUtil.MAX_BINS);
final int nChunk = 2;
codec.writeInt(nChunk);
codec.writeLong(metaData.getFirstOffset());
codec.writeLong(metaData.getLastOffset());
codec.writeLong(metaData.getAlignedRecordCount());
codec.writeLong(metaData.getUnalignedRecordCount());
}
|
[
"private",
"void",
"writeChunkMetaData",
"(",
"final",
"BAMIndexMetaData",
"metaData",
")",
"{",
"codec",
".",
"writeInt",
"(",
"GenomicIndexUtil",
".",
"MAX_BINS",
")",
";",
"final",
"int",
"nChunk",
"=",
"2",
";",
"codec",
".",
"writeInt",
"(",
"nChunk",
")",
";",
"codec",
".",
"writeLong",
"(",
"metaData",
".",
"getFirstOffset",
"(",
")",
")",
";",
"codec",
".",
"writeLong",
"(",
"metaData",
".",
"getLastOffset",
"(",
")",
")",
";",
"codec",
".",
"writeLong",
"(",
"metaData",
".",
"getAlignedRecordCount",
"(",
")",
")",
";",
"codec",
".",
"writeLong",
"(",
"metaData",
".",
"getUnalignedRecordCount",
"(",
")",
")",
";",
"}"
] |
Write the meta data represented by the chunkLists associated with bin MAX_BINS 37450
@param metaData information describing numAligned records, numUnAligned, etc
|
[
"Write",
"the",
"meta",
"data",
"represented",
"by",
"the",
"chunkLists",
"associated",
"with",
"bin",
"MAX_BINS",
"37450"
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/htsjdk/samtools/BinaryBAMShardIndexWriter.java#L138-L147
|
4,084 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/functions/ibs/SharedAllelesRatioCalculator.java
|
SharedAllelesRatioCalculator.similarity
|
@Override
public double similarity(VariantCall call1, VariantCall call2) {
int minNumberOfGenotypes = Math.min(call1.getGenotypeCount(), call2.getGenotypeCount());
int numberOfSharedAlleles = 0;
for (int i = 0; i < minNumberOfGenotypes; ++i) {
if (call1.getGenotype(i) == call2.getGenotype(i)) {
++numberOfSharedAlleles;
}
}
int maxNumberOfGenotypes = Math.max(call1.getGenotypeCount(), call2.getGenotypeCount());
return (double) numberOfSharedAlleles / maxNumberOfGenotypes;
}
|
java
|
@Override
public double similarity(VariantCall call1, VariantCall call2) {
int minNumberOfGenotypes = Math.min(call1.getGenotypeCount(), call2.getGenotypeCount());
int numberOfSharedAlleles = 0;
for (int i = 0; i < minNumberOfGenotypes; ++i) {
if (call1.getGenotype(i) == call2.getGenotype(i)) {
++numberOfSharedAlleles;
}
}
int maxNumberOfGenotypes = Math.max(call1.getGenotypeCount(), call2.getGenotypeCount());
return (double) numberOfSharedAlleles / maxNumberOfGenotypes;
}
|
[
"@",
"Override",
"public",
"double",
"similarity",
"(",
"VariantCall",
"call1",
",",
"VariantCall",
"call2",
")",
"{",
"int",
"minNumberOfGenotypes",
"=",
"Math",
".",
"min",
"(",
"call1",
".",
"getGenotypeCount",
"(",
")",
",",
"call2",
".",
"getGenotypeCount",
"(",
")",
")",
";",
"int",
"numberOfSharedAlleles",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"minNumberOfGenotypes",
";",
"++",
"i",
")",
"{",
"if",
"(",
"call1",
".",
"getGenotype",
"(",
"i",
")",
"==",
"call2",
".",
"getGenotype",
"(",
"i",
")",
")",
"{",
"++",
"numberOfSharedAlleles",
";",
"}",
"}",
"int",
"maxNumberOfGenotypes",
"=",
"Math",
".",
"max",
"(",
"call1",
".",
"getGenotypeCount",
"(",
")",
",",
"call2",
".",
"getGenotypeCount",
"(",
")",
")",
";",
"return",
"(",
"double",
")",
"numberOfSharedAlleles",
"/",
"maxNumberOfGenotypes",
";",
"}"
] |
scores when the number of alleles is different than 2 and when the genotypes are unphased.
|
[
"scores",
"when",
"the",
"number",
"of",
"alleles",
"is",
"different",
"than",
"2",
"and",
"when",
"the",
"genotypes",
"are",
"unphased",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/functions/ibs/SharedAllelesRatioCalculator.java#L29-L40
|
4,085 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/ReadFunctions.java
|
ReadFunctions.extractReadBases
|
public static List<ReadBaseWithReference> extractReadBases(Read read) {
// Make sure this read has a valid alignment with Cigar Units
if (!read.hasAlignment() || (read.getAlignment().getCigarCount() == 0)) {
return null;
}
ImmutableList.Builder<ReadBaseWithReference> bases = ImmutableList.builder();
String readSeq = read.getAlignedSequence();
List<Integer> readQual = read.getAlignedQualityList();
String refSeq = UNINITIALIZED_REFERENCE_SEQUENCE;
int refPosAbsoluteOffset = 0;
int readOffset = 0;
for (CigarUnit unit : read.getAlignment().getCigarList()) {
switch(unit.getOperation()) {
case ALIGNMENT_MATCH:
case SEQUENCE_MISMATCH:
case SEQUENCE_MATCH:
for (int i = 0; i < unit.getOperationLength(); i++) {
String refBase = "";
if (unit.getOperation().equals(CigarUnit.Operation.SEQUENCE_MATCH)) {
refBase = readSeq.substring(readOffset, readOffset + 1);
} else if (!unit.getReferenceSequence().isEmpty()) {
// try to get the ref sequence from the Cigar unit
refBase = unit.getReferenceSequence().substring(i, i + 1);
} else {
// try to get the ref sequence by fully parsing the MD tag if not already cached
if (refSeq != null && refSeq.equals(UNINITIALIZED_REFERENCE_SEQUENCE)) {
refSeq = com.google.cloud.genomics.utils.grpc.ReadUtils
.inferReferenceSequenceByParsingMdFlag(read);
}
if (refSeq != null) {
refBase = refSeq.substring(readOffset, readOffset + 1);
}
}
String name = read.getAlignment().getPosition().getReferenceName();
Matcher m = Pattern.compile("^(chr)?(X|Y|([12]?\\d))$").matcher(name);
if (m.matches()) {
name = m.group(m.groupCount() - 1);
}
Position refPosition = Position.newBuilder()
.setReferenceName(name)
.setPosition(read.getAlignment().getPosition().getPosition()
+ refPosAbsoluteOffset)
.build();
bases.add(new ReadBaseWithReference(new ReadBaseQuality(
readSeq.substring(readOffset, readOffset + 1),
readQual.get(readOffset)),
refBase,
refPosition));
refPosAbsoluteOffset++;
readOffset++;
}
break;
case PAD: // padding (silent deletion from padded reference)
case CLIP_HARD: // hard clipping (clipped sequences NOT present in seq)
break;
case CLIP_SOFT: // soft clipping (clipped sequences present in SEQ)
case INSERT: // insertion to the reference
readOffset += unit.getOperationLength();
break;
case DELETE: // deletion from the reference
case SKIP: // intron (mRNA-to-genome alignment only)
refPosAbsoluteOffset += unit.getOperationLength();
break;
default:
throw new IllegalArgumentException("Illegal cigar code: " + unit.getOperation());
}
}
return bases.build();
}
|
java
|
public static List<ReadBaseWithReference> extractReadBases(Read read) {
// Make sure this read has a valid alignment with Cigar Units
if (!read.hasAlignment() || (read.getAlignment().getCigarCount() == 0)) {
return null;
}
ImmutableList.Builder<ReadBaseWithReference> bases = ImmutableList.builder();
String readSeq = read.getAlignedSequence();
List<Integer> readQual = read.getAlignedQualityList();
String refSeq = UNINITIALIZED_REFERENCE_SEQUENCE;
int refPosAbsoluteOffset = 0;
int readOffset = 0;
for (CigarUnit unit : read.getAlignment().getCigarList()) {
switch(unit.getOperation()) {
case ALIGNMENT_MATCH:
case SEQUENCE_MISMATCH:
case SEQUENCE_MATCH:
for (int i = 0; i < unit.getOperationLength(); i++) {
String refBase = "";
if (unit.getOperation().equals(CigarUnit.Operation.SEQUENCE_MATCH)) {
refBase = readSeq.substring(readOffset, readOffset + 1);
} else if (!unit.getReferenceSequence().isEmpty()) {
// try to get the ref sequence from the Cigar unit
refBase = unit.getReferenceSequence().substring(i, i + 1);
} else {
// try to get the ref sequence by fully parsing the MD tag if not already cached
if (refSeq != null && refSeq.equals(UNINITIALIZED_REFERENCE_SEQUENCE)) {
refSeq = com.google.cloud.genomics.utils.grpc.ReadUtils
.inferReferenceSequenceByParsingMdFlag(read);
}
if (refSeq != null) {
refBase = refSeq.substring(readOffset, readOffset + 1);
}
}
String name = read.getAlignment().getPosition().getReferenceName();
Matcher m = Pattern.compile("^(chr)?(X|Y|([12]?\\d))$").matcher(name);
if (m.matches()) {
name = m.group(m.groupCount() - 1);
}
Position refPosition = Position.newBuilder()
.setReferenceName(name)
.setPosition(read.getAlignment().getPosition().getPosition()
+ refPosAbsoluteOffset)
.build();
bases.add(new ReadBaseWithReference(new ReadBaseQuality(
readSeq.substring(readOffset, readOffset + 1),
readQual.get(readOffset)),
refBase,
refPosition));
refPosAbsoluteOffset++;
readOffset++;
}
break;
case PAD: // padding (silent deletion from padded reference)
case CLIP_HARD: // hard clipping (clipped sequences NOT present in seq)
break;
case CLIP_SOFT: // soft clipping (clipped sequences present in SEQ)
case INSERT: // insertion to the reference
readOffset += unit.getOperationLength();
break;
case DELETE: // deletion from the reference
case SKIP: // intron (mRNA-to-genome alignment only)
refPosAbsoluteOffset += unit.getOperationLength();
break;
default:
throw new IllegalArgumentException("Illegal cigar code: " + unit.getOperation());
}
}
return bases.build();
}
|
[
"public",
"static",
"List",
"<",
"ReadBaseWithReference",
">",
"extractReadBases",
"(",
"Read",
"read",
")",
"{",
"// Make sure this read has a valid alignment with Cigar Units",
"if",
"(",
"!",
"read",
".",
"hasAlignment",
"(",
")",
"||",
"(",
"read",
".",
"getAlignment",
"(",
")",
".",
"getCigarCount",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
"null",
";",
"}",
"ImmutableList",
".",
"Builder",
"<",
"ReadBaseWithReference",
">",
"bases",
"=",
"ImmutableList",
".",
"builder",
"(",
")",
";",
"String",
"readSeq",
"=",
"read",
".",
"getAlignedSequence",
"(",
")",
";",
"List",
"<",
"Integer",
">",
"readQual",
"=",
"read",
".",
"getAlignedQualityList",
"(",
")",
";",
"String",
"refSeq",
"=",
"UNINITIALIZED_REFERENCE_SEQUENCE",
";",
"int",
"refPosAbsoluteOffset",
"=",
"0",
";",
"int",
"readOffset",
"=",
"0",
";",
"for",
"(",
"CigarUnit",
"unit",
":",
"read",
".",
"getAlignment",
"(",
")",
".",
"getCigarList",
"(",
")",
")",
"{",
"switch",
"(",
"unit",
".",
"getOperation",
"(",
")",
")",
"{",
"case",
"ALIGNMENT_MATCH",
":",
"case",
"SEQUENCE_MISMATCH",
":",
"case",
"SEQUENCE_MATCH",
":",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"unit",
".",
"getOperationLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"refBase",
"=",
"\"\"",
";",
"if",
"(",
"unit",
".",
"getOperation",
"(",
")",
".",
"equals",
"(",
"CigarUnit",
".",
"Operation",
".",
"SEQUENCE_MATCH",
")",
")",
"{",
"refBase",
"=",
"readSeq",
".",
"substring",
"(",
"readOffset",
",",
"readOffset",
"+",
"1",
")",
";",
"}",
"else",
"if",
"(",
"!",
"unit",
".",
"getReferenceSequence",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"// try to get the ref sequence from the Cigar unit",
"refBase",
"=",
"unit",
".",
"getReferenceSequence",
"(",
")",
".",
"substring",
"(",
"i",
",",
"i",
"+",
"1",
")",
";",
"}",
"else",
"{",
"// try to get the ref sequence by fully parsing the MD tag if not already cached",
"if",
"(",
"refSeq",
"!=",
"null",
"&&",
"refSeq",
".",
"equals",
"(",
"UNINITIALIZED_REFERENCE_SEQUENCE",
")",
")",
"{",
"refSeq",
"=",
"com",
".",
"google",
".",
"cloud",
".",
"genomics",
".",
"utils",
".",
"grpc",
".",
"ReadUtils",
".",
"inferReferenceSequenceByParsingMdFlag",
"(",
"read",
")",
";",
"}",
"if",
"(",
"refSeq",
"!=",
"null",
")",
"{",
"refBase",
"=",
"refSeq",
".",
"substring",
"(",
"readOffset",
",",
"readOffset",
"+",
"1",
")",
";",
"}",
"}",
"String",
"name",
"=",
"read",
".",
"getAlignment",
"(",
")",
".",
"getPosition",
"(",
")",
".",
"getReferenceName",
"(",
")",
";",
"Matcher",
"m",
"=",
"Pattern",
".",
"compile",
"(",
"\"^(chr)?(X|Y|([12]?\\\\d))$\"",
")",
".",
"matcher",
"(",
"name",
")",
";",
"if",
"(",
"m",
".",
"matches",
"(",
")",
")",
"{",
"name",
"=",
"m",
".",
"group",
"(",
"m",
".",
"groupCount",
"(",
")",
"-",
"1",
")",
";",
"}",
"Position",
"refPosition",
"=",
"Position",
".",
"newBuilder",
"(",
")",
".",
"setReferenceName",
"(",
"name",
")",
".",
"setPosition",
"(",
"read",
".",
"getAlignment",
"(",
")",
".",
"getPosition",
"(",
")",
".",
"getPosition",
"(",
")",
"+",
"refPosAbsoluteOffset",
")",
".",
"build",
"(",
")",
";",
"bases",
".",
"add",
"(",
"new",
"ReadBaseWithReference",
"(",
"new",
"ReadBaseQuality",
"(",
"readSeq",
".",
"substring",
"(",
"readOffset",
",",
"readOffset",
"+",
"1",
")",
",",
"readQual",
".",
"get",
"(",
"readOffset",
")",
")",
",",
"refBase",
",",
"refPosition",
")",
")",
";",
"refPosAbsoluteOffset",
"++",
";",
"readOffset",
"++",
";",
"}",
"break",
";",
"case",
"PAD",
":",
"// padding (silent deletion from padded reference)",
"case",
"CLIP_HARD",
":",
"// hard clipping (clipped sequences NOT present in seq)",
"break",
";",
"case",
"CLIP_SOFT",
":",
"// soft clipping (clipped sequences present in SEQ)",
"case",
"INSERT",
":",
"// insertion to the reference",
"readOffset",
"+=",
"unit",
".",
"getOperationLength",
"(",
")",
";",
"break",
";",
"case",
"DELETE",
":",
"// deletion from the reference",
"case",
"SKIP",
":",
"// intron (mRNA-to-genome alignment only)",
"refPosAbsoluteOffset",
"+=",
"unit",
".",
"getOperationLength",
"(",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Illegal cigar code: \"",
"+",
"unit",
".",
"getOperation",
"(",
")",
")",
";",
"}",
"}",
"return",
"bases",
".",
"build",
"(",
")",
";",
"}"
] |
Use the given read to build a list of aligned read and reference base
information.
@param read The read with the alignment information
@return read and reference information. For a read without an alignment
or cigar units, null is returned.
|
[
"Use",
"the",
"given",
"read",
"to",
"build",
"a",
"list",
"of",
"aligned",
"read",
"and",
"reference",
"base",
"information",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/ReadFunctions.java#L45-L122
|
4,086 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/LikelihoodFn.java
|
LikelihoodFn.pGenotype
|
private static double pGenotype(Genotype g, double refProb) {
switch(g) {
case REF_HOMOZYGOUS:
return refProb * refProb;
case HETEROZYGOUS:
return refProb * (1.0 - refProb);
case NONREF_HOMOZYGOUS:
return (1.0 - refProb) * (1.0 - refProb);
default:
throw new IllegalArgumentException("Illegal genotype");
}
}
|
java
|
private static double pGenotype(Genotype g, double refProb) {
switch(g) {
case REF_HOMOZYGOUS:
return refProb * refProb;
case HETEROZYGOUS:
return refProb * (1.0 - refProb);
case NONREF_HOMOZYGOUS:
return (1.0 - refProb) * (1.0 - refProb);
default:
throw new IllegalArgumentException("Illegal genotype");
}
}
|
[
"private",
"static",
"double",
"pGenotype",
"(",
"Genotype",
"g",
",",
"double",
"refProb",
")",
"{",
"switch",
"(",
"g",
")",
"{",
"case",
"REF_HOMOZYGOUS",
":",
"return",
"refProb",
"*",
"refProb",
";",
"case",
"HETEROZYGOUS",
":",
"return",
"refProb",
"*",
"(",
"1.0",
"-",
"refProb",
")",
";",
"case",
"NONREF_HOMOZYGOUS",
":",
"return",
"(",
"1.0",
"-",
"refProb",
")",
"*",
"(",
"1.0",
"-",
"refProb",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Illegal genotype\"",
")",
";",
"}",
"}"
] |
Compute the probability of a genotype given the reference allele probability.
|
[
"Compute",
"the",
"probability",
"of",
"a",
"genotype",
"given",
"the",
"reference",
"allele",
"probability",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/LikelihoodFn.java#L105-L116
|
4,087 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/LikelihoodFn.java
|
LikelihoodFn.probObsGivenTruth
|
private static double probObsGivenTruth(Base observed, Genotype trueGenotype,
ReadStatus trueStatus) {
return P_OBS_GIVEN_TRUTH.get(toTableIndex(observed, trueGenotype, trueStatus));
}
|
java
|
private static double probObsGivenTruth(Base observed, Genotype trueGenotype,
ReadStatus trueStatus) {
return P_OBS_GIVEN_TRUTH.get(toTableIndex(observed, trueGenotype, trueStatus));
}
|
[
"private",
"static",
"double",
"probObsGivenTruth",
"(",
"Base",
"observed",
",",
"Genotype",
"trueGenotype",
",",
"ReadStatus",
"trueStatus",
")",
"{",
"return",
"P_OBS_GIVEN_TRUTH",
".",
"get",
"(",
"toTableIndex",
"(",
"observed",
",",
"trueGenotype",
",",
"trueStatus",
")",
")",
";",
"}"
] |
Look up the probability of an observation conditioned on the underlying state.
|
[
"Look",
"up",
"the",
"probability",
"of",
"an",
"observation",
"conditioned",
"on",
"the",
"underlying",
"state",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/LikelihoodFn.java#L121-L124
|
4,088 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/LikelihoodFn.java
|
LikelihoodFn.value
|
@Override
public double value(double alpha) {
double logLikelihood = 0.0;
for (ReadCounts rc : readCounts.values()) {
double refProb = rc.getRefFreq();
double pPosition = 0.0;
for (Genotype trueGenotype1 : Genotype.values()) {
double pGenotype1 = pGenotype(trueGenotype1, refProb);
for (Genotype trueGenotype2 : Genotype.values()) {
double pGenotype2 = pGenotype(trueGenotype2, refProb);
double pObsGivenGenotype = 1.0;
for (ReadQualityCount rqc : rc.getReadQualityCounts()) {
Base base = rqc.getBase();
double pErr = phredToProb(rqc.getQuality());
double pObs
= ((1.0 - alpha)
* probObsGivenTruth(base, trueGenotype1, ReadStatus.CORRECT)
+ (alpha)
* probObsGivenTruth(base, trueGenotype2, ReadStatus.CORRECT)
) * (1.0 - pErr)
+ ((1.0 - alpha)
* probObsGivenTruth(base, trueGenotype1, ReadStatus.ERROR)
+ (alpha)
* probObsGivenTruth(base, trueGenotype2, ReadStatus.ERROR)
) * pErr;
pObsGivenGenotype *= Math.pow(pObs, rqc.getCount());
}
pPosition += pObsGivenGenotype * pGenotype1 * pGenotype2;
}
}
logLikelihood += Math.log(pPosition);
}
return logLikelihood;
}
|
java
|
@Override
public double value(double alpha) {
double logLikelihood = 0.0;
for (ReadCounts rc : readCounts.values()) {
double refProb = rc.getRefFreq();
double pPosition = 0.0;
for (Genotype trueGenotype1 : Genotype.values()) {
double pGenotype1 = pGenotype(trueGenotype1, refProb);
for (Genotype trueGenotype2 : Genotype.values()) {
double pGenotype2 = pGenotype(trueGenotype2, refProb);
double pObsGivenGenotype = 1.0;
for (ReadQualityCount rqc : rc.getReadQualityCounts()) {
Base base = rqc.getBase();
double pErr = phredToProb(rqc.getQuality());
double pObs
= ((1.0 - alpha)
* probObsGivenTruth(base, trueGenotype1, ReadStatus.CORRECT)
+ (alpha)
* probObsGivenTruth(base, trueGenotype2, ReadStatus.CORRECT)
) * (1.0 - pErr)
+ ((1.0 - alpha)
* probObsGivenTruth(base, trueGenotype1, ReadStatus.ERROR)
+ (alpha)
* probObsGivenTruth(base, trueGenotype2, ReadStatus.ERROR)
) * pErr;
pObsGivenGenotype *= Math.pow(pObs, rqc.getCount());
}
pPosition += pObsGivenGenotype * pGenotype1 * pGenotype2;
}
}
logLikelihood += Math.log(pPosition);
}
return logLikelihood;
}
|
[
"@",
"Override",
"public",
"double",
"value",
"(",
"double",
"alpha",
")",
"{",
"double",
"logLikelihood",
"=",
"0.0",
";",
"for",
"(",
"ReadCounts",
"rc",
":",
"readCounts",
".",
"values",
"(",
")",
")",
"{",
"double",
"refProb",
"=",
"rc",
".",
"getRefFreq",
"(",
")",
";",
"double",
"pPosition",
"=",
"0.0",
";",
"for",
"(",
"Genotype",
"trueGenotype1",
":",
"Genotype",
".",
"values",
"(",
")",
")",
"{",
"double",
"pGenotype1",
"=",
"pGenotype",
"(",
"trueGenotype1",
",",
"refProb",
")",
";",
"for",
"(",
"Genotype",
"trueGenotype2",
":",
"Genotype",
".",
"values",
"(",
")",
")",
"{",
"double",
"pGenotype2",
"=",
"pGenotype",
"(",
"trueGenotype2",
",",
"refProb",
")",
";",
"double",
"pObsGivenGenotype",
"=",
"1.0",
";",
"for",
"(",
"ReadQualityCount",
"rqc",
":",
"rc",
".",
"getReadQualityCounts",
"(",
")",
")",
"{",
"Base",
"base",
"=",
"rqc",
".",
"getBase",
"(",
")",
";",
"double",
"pErr",
"=",
"phredToProb",
"(",
"rqc",
".",
"getQuality",
"(",
")",
")",
";",
"double",
"pObs",
"=",
"(",
"(",
"1.0",
"-",
"alpha",
")",
"*",
"probObsGivenTruth",
"(",
"base",
",",
"trueGenotype1",
",",
"ReadStatus",
".",
"CORRECT",
")",
"+",
"(",
"alpha",
")",
"*",
"probObsGivenTruth",
"(",
"base",
",",
"trueGenotype2",
",",
"ReadStatus",
".",
"CORRECT",
")",
")",
"*",
"(",
"1.0",
"-",
"pErr",
")",
"+",
"(",
"(",
"1.0",
"-",
"alpha",
")",
"*",
"probObsGivenTruth",
"(",
"base",
",",
"trueGenotype1",
",",
"ReadStatus",
".",
"ERROR",
")",
"+",
"(",
"alpha",
")",
"*",
"probObsGivenTruth",
"(",
"base",
",",
"trueGenotype2",
",",
"ReadStatus",
".",
"ERROR",
")",
")",
"*",
"pErr",
";",
"pObsGivenGenotype",
"*=",
"Math",
".",
"pow",
"(",
"pObs",
",",
"rqc",
".",
"getCount",
"(",
")",
")",
";",
"}",
"pPosition",
"+=",
"pObsGivenGenotype",
"*",
"pGenotype1",
"*",
"pGenotype2",
";",
"}",
"}",
"logLikelihood",
"+=",
"Math",
".",
"log",
"(",
"pPosition",
")",
";",
"}",
"return",
"logLikelihood",
";",
"}"
] |
Compute the likelihood of a contaminant fraction alpha.
<p>See equation (2) in Jun et al.
|
[
"Compute",
"the",
"likelihood",
"of",
"a",
"contaminant",
"fraction",
"alpha",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/LikelihoodFn.java#L131-L167
|
4,089 |
googlegenomics/dataflow-java
|
src/main/java/com/google/cloud/genomics/dataflow/readers/bam/ReadBAMTransform.java
|
ReadBAMTransform.getReadsFromBAMFileSharded
|
@Deprecated
public static PCollection<Read> getReadsFromBAMFileSharded(
Pipeline p,
PipelineOptions pipelineOptions,
OfflineAuth auth,
List<Contig> contigs,
ReaderOptions options,
String BAMFile,
ShardingPolicy shardingPolicy) throws IOException {
ReadBAMTransform readBAMSTransform = new ReadBAMTransform(options);
readBAMSTransform.setAuth(auth);
final Storage.Objects storage = Transport
.newStorageClient(pipelineOptions.as(GCSOptions.class)).build().objects();
final List<BAMShard> shardsList = Sharder.shardBAMFile(storage, BAMFile, contigs,
shardingPolicy);
PCollection<BAMShard> shards = p.apply(Create
.of(shardsList));
return readBAMSTransform.expand(shards);
}
|
java
|
@Deprecated
public static PCollection<Read> getReadsFromBAMFileSharded(
Pipeline p,
PipelineOptions pipelineOptions,
OfflineAuth auth,
List<Contig> contigs,
ReaderOptions options,
String BAMFile,
ShardingPolicy shardingPolicy) throws IOException {
ReadBAMTransform readBAMSTransform = new ReadBAMTransform(options);
readBAMSTransform.setAuth(auth);
final Storage.Objects storage = Transport
.newStorageClient(pipelineOptions.as(GCSOptions.class)).build().objects();
final List<BAMShard> shardsList = Sharder.shardBAMFile(storage, BAMFile, contigs,
shardingPolicy);
PCollection<BAMShard> shards = p.apply(Create
.of(shardsList));
return readBAMSTransform.expand(shards);
}
|
[
"@",
"Deprecated",
"public",
"static",
"PCollection",
"<",
"Read",
">",
"getReadsFromBAMFileSharded",
"(",
"Pipeline",
"p",
",",
"PipelineOptions",
"pipelineOptions",
",",
"OfflineAuth",
"auth",
",",
"List",
"<",
"Contig",
">",
"contigs",
",",
"ReaderOptions",
"options",
",",
"String",
"BAMFile",
",",
"ShardingPolicy",
"shardingPolicy",
")",
"throws",
"IOException",
"{",
"ReadBAMTransform",
"readBAMSTransform",
"=",
"new",
"ReadBAMTransform",
"(",
"options",
")",
";",
"readBAMSTransform",
".",
"setAuth",
"(",
"auth",
")",
";",
"final",
"Storage",
".",
"Objects",
"storage",
"=",
"Transport",
".",
"newStorageClient",
"(",
"pipelineOptions",
".",
"as",
"(",
"GCSOptions",
".",
"class",
")",
")",
".",
"build",
"(",
")",
".",
"objects",
"(",
")",
";",
"final",
"List",
"<",
"BAMShard",
">",
"shardsList",
"=",
"Sharder",
".",
"shardBAMFile",
"(",
"storage",
",",
"BAMFile",
",",
"contigs",
",",
"shardingPolicy",
")",
";",
"PCollection",
"<",
"BAMShard",
">",
"shards",
"=",
"p",
".",
"apply",
"(",
"Create",
".",
"of",
"(",
"shardsList",
")",
")",
";",
"return",
"readBAMSTransform",
".",
"expand",
"(",
"shards",
")",
";",
"}"
] |
Get reads from a single BAM file by serially reading one shard at a time.
This is useful when reads from a subset of genomic regions is desired.
This method is marked as deprecated because getReadsFromBAMFilesSharded offers
the same functionality but shard reading occurs in parallel.
This method should be removed when https://github.com/googlegenomics/dataflow-java/issues/214
is fixed.
@param p
@param pipelineOptions
@param auth
@param contigs
@param options
@param BAMFile
@param shardingPolicy
@return
@throws IOException
|
[
"Get",
"reads",
"from",
"a",
"single",
"BAM",
"file",
"by",
"serially",
"reading",
"one",
"shard",
"at",
"a",
"time",
"."
] |
ef2c56ed1a6397843c55102748b8c2b12aaa4772
|
https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/readers/bam/ReadBAMTransform.java#L115-L133
|
4,090 |
allcolor/YaHP-Converter
|
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoaderConfig.java
|
CClassLoaderConfig.addFile
|
public void addFile(
String loaderPath,
URL file
) {
List list = (List) filesMap.get(loaderPath);
if (list == null) {
list = new ArrayList();
filesMap.put(
loaderPath,
list
);
}
list.add(file);
}
|
java
|
public void addFile(
String loaderPath,
URL file
) {
List list = (List) filesMap.get(loaderPath);
if (list == null) {
list = new ArrayList();
filesMap.put(
loaderPath,
list
);
}
list.add(file);
}
|
[
"public",
"void",
"addFile",
"(",
"String",
"loaderPath",
",",
"URL",
"file",
")",
"{",
"List",
"list",
"=",
"(",
"List",
")",
"filesMap",
".",
"get",
"(",
"loaderPath",
")",
";",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"list",
"=",
"new",
"ArrayList",
"(",
")",
";",
"filesMap",
".",
"put",
"(",
"loaderPath",
",",
"list",
")",
";",
"}",
"list",
".",
"add",
"(",
"file",
")",
";",
"}"
] |
add a file to the given loader
@param loaderPath the path of the loader
@param file the jar file to add
|
[
"add",
"a",
"file",
"to",
"the",
"given",
"loader"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoaderConfig.java#L49-L64
|
4,091 |
allcolor/YaHP-Converter
|
YaHPConverter/src/org/allcolor/yahp/converter/CMutex.java
|
CMutex.releaseMultiple
|
public static final void releaseMultiple(CMutex mutex[]) {
Arrays.sort(mutex, new CMutexComparator());
for (int i = mutex.length - 1; i >= 0; i--) {
mutex[i].release();
}
}
|
java
|
public static final void releaseMultiple(CMutex mutex[]) {
Arrays.sort(mutex, new CMutexComparator());
for (int i = mutex.length - 1; i >= 0; i--) {
mutex[i].release();
}
}
|
[
"public",
"static",
"final",
"void",
"releaseMultiple",
"(",
"CMutex",
"mutex",
"[",
"]",
")",
"{",
"Arrays",
".",
"sort",
"(",
"mutex",
",",
"new",
"CMutexComparator",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"mutex",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"mutex",
"[",
"i",
"]",
".",
"release",
"(",
")",
";",
"}",
"}"
] |
Releases an array of mutex previously acquired
@param mutex
the mutex array to release
|
[
"Releases",
"an",
"array",
"of",
"mutex",
"previously",
"acquired"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CMutex.java#L118-L124
|
4,092 |
allcolor/YaHP-Converter
|
YaHPConverter/src/org/allcolor/yahp/converter/CMutex.java
|
CMutex.release
|
public final void release() {
synchronized (this.LOCK) {
if ((this.owner != null)
&& (this.owner.get() == Thread.currentThread())) {
this.acquire--;
if (this.acquire == 0) {
this.owner = null;
this.LOCK.notify();
}
return;
}
if ((this.owner != null) && (this.owner.get() == null)) {
this.owner = null;
this.acquire = 0;
this.LOCK.notify();
}
throw new IllegalMonitorStateException(Thread.currentThread()
.getName()
+ " is not the owner of the lock. "
+ ((this.owner != null) ? ((Thread) this.owner.get())
.getName() : "nobody") + " is the owner.");
}
}
|
java
|
public final void release() {
synchronized (this.LOCK) {
if ((this.owner != null)
&& (this.owner.get() == Thread.currentThread())) {
this.acquire--;
if (this.acquire == 0) {
this.owner = null;
this.LOCK.notify();
}
return;
}
if ((this.owner != null) && (this.owner.get() == null)) {
this.owner = null;
this.acquire = 0;
this.LOCK.notify();
}
throw new IllegalMonitorStateException(Thread.currentThread()
.getName()
+ " is not the owner of the lock. "
+ ((this.owner != null) ? ((Thread) this.owner.get())
.getName() : "nobody") + " is the owner.");
}
}
|
[
"public",
"final",
"void",
"release",
"(",
")",
"{",
"synchronized",
"(",
"this",
".",
"LOCK",
")",
"{",
"if",
"(",
"(",
"this",
".",
"owner",
"!=",
"null",
")",
"&&",
"(",
"this",
".",
"owner",
".",
"get",
"(",
")",
"==",
"Thread",
".",
"currentThread",
"(",
")",
")",
")",
"{",
"this",
".",
"acquire",
"--",
";",
"if",
"(",
"this",
".",
"acquire",
"==",
"0",
")",
"{",
"this",
".",
"owner",
"=",
"null",
";",
"this",
".",
"LOCK",
".",
"notify",
"(",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"(",
"this",
".",
"owner",
"!=",
"null",
")",
"&&",
"(",
"this",
".",
"owner",
".",
"get",
"(",
")",
"==",
"null",
")",
")",
"{",
"this",
".",
"owner",
"=",
"null",
";",
"this",
".",
"acquire",
"=",
"0",
";",
"this",
".",
"LOCK",
".",
"notify",
"(",
")",
";",
"}",
"throw",
"new",
"IllegalMonitorStateException",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" is not the owner of the lock. \"",
"+",
"(",
"(",
"this",
".",
"owner",
"!=",
"null",
")",
"?",
"(",
"(",
"Thread",
")",
"this",
".",
"owner",
".",
"get",
"(",
")",
")",
".",
"getName",
"(",
")",
":",
"\"nobody\"",
")",
"+",
"\" is the owner.\"",
")",
";",
"}",
"}"
] |
Releases the mutex
@throws IllegalMonitorStateException
If currentThread is not the owner.
|
[
"Releases",
"the",
"mutex"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CMutex.java#L226-L252
|
4,093 |
allcolor/YaHP-Converter
|
YaHPConverter/src/org/allcolor/yahp/cl/converter/CDocumentCut.java
|
CDocumentCut.isDescendant
|
private static boolean isDescendant(
final Node n,
final Node ref) {
if (ref == null) {
return false;
} // end if
if (n == ref) {
return true;
} // end if
NodeList nl = ref.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
boolean result = isDescendant(n, nl.item(i));
if (result) {
return result;
} // end if
} // end for
return false;
}
|
java
|
private static boolean isDescendant(
final Node n,
final Node ref) {
if (ref == null) {
return false;
} // end if
if (n == ref) {
return true;
} // end if
NodeList nl = ref.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
boolean result = isDescendant(n, nl.item(i));
if (result) {
return result;
} // end if
} // end for
return false;
}
|
[
"private",
"static",
"boolean",
"isDescendant",
"(",
"final",
"Node",
"n",
",",
"final",
"Node",
"ref",
")",
"{",
"if",
"(",
"ref",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"// end if",
"if",
"(",
"n",
"==",
"ref",
")",
"{",
"return",
"true",
";",
"}",
"// end if",
"NodeList",
"nl",
"=",
"ref",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nl",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"boolean",
"result",
"=",
"isDescendant",
"(",
"n",
",",
"nl",
".",
"item",
"(",
"i",
")",
")",
";",
"if",
"(",
"result",
")",
"{",
"return",
"result",
";",
"}",
"// end if",
"}",
"// end for",
"return",
"false",
";",
"}"
] |
return true if n is a descendant of ref
@param n node to test
@param ref reference node
@return true if n is a descendant of ref
|
[
"return",
"true",
"if",
"n",
"is",
"a",
"descendant",
"of",
"ref"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/CDocumentCut.java#L412-L434
|
4,094 |
allcolor/YaHP-Converter
|
YaHPConverter/src/org/allcolor/yahp/cl/converter/CDocumentCut.java
|
CDocumentCut.getPbDocs
|
private static PbDocument [] getPbDocs(final NodeList nl) {
List list = new ArrayList();
Element prevpb = null;
for (int i = 0; i < nl.getLength(); i++) {
Element pb = (Element) nl.item(i);
PbDocument pbdoc = new PbDocument(prevpb, pb);
list.add(pbdoc);
prevpb = pb;
if (i == (nl.getLength() - 1)) {
pbdoc = new PbDocument(pb, null);
list.add(pbdoc);
} // end if
} // end for
PbDocument array[] = new PbDocument[list.size()];
for (int i = 0; i < list.size(); i++) {
array[i] = (PbDocument) list.get(i);
} // end for
return array;
}
|
java
|
private static PbDocument [] getPbDocs(final NodeList nl) {
List list = new ArrayList();
Element prevpb = null;
for (int i = 0; i < nl.getLength(); i++) {
Element pb = (Element) nl.item(i);
PbDocument pbdoc = new PbDocument(prevpb, pb);
list.add(pbdoc);
prevpb = pb;
if (i == (nl.getLength() - 1)) {
pbdoc = new PbDocument(pb, null);
list.add(pbdoc);
} // end if
} // end for
PbDocument array[] = new PbDocument[list.size()];
for (int i = 0; i < list.size(); i++) {
array[i] = (PbDocument) list.get(i);
} // end for
return array;
}
|
[
"private",
"static",
"PbDocument",
"[",
"]",
"getPbDocs",
"(",
"final",
"NodeList",
"nl",
")",
"{",
"List",
"list",
"=",
"new",
"ArrayList",
"(",
")",
";",
"Element",
"prevpb",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nl",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Element",
"pb",
"=",
"(",
"Element",
")",
"nl",
".",
"item",
"(",
"i",
")",
";",
"PbDocument",
"pbdoc",
"=",
"new",
"PbDocument",
"(",
"prevpb",
",",
"pb",
")",
";",
"list",
".",
"add",
"(",
"pbdoc",
")",
";",
"prevpb",
"=",
"pb",
";",
"if",
"(",
"i",
"==",
"(",
"nl",
".",
"getLength",
"(",
")",
"-",
"1",
")",
")",
"{",
"pbdoc",
"=",
"new",
"PbDocument",
"(",
"pb",
",",
"null",
")",
";",
"list",
".",
"add",
"(",
"pbdoc",
")",
";",
"}",
"// end if",
"}",
"// end for",
"PbDocument",
"array",
"[",
"]",
"=",
"new",
"PbDocument",
"[",
"list",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"array",
"[",
"i",
"]",
"=",
"(",
"PbDocument",
")",
"list",
".",
"get",
"(",
"i",
")",
";",
"}",
"// end for",
"return",
"array",
";",
"}"
] |
Return the pagebreaks
@param nl pagebreaks nodelist
@return an array of subdoc composed of space between pb.
|
[
"Return",
"the",
"pagebreaks"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/CDocumentCut.java#L443-L466
|
4,095 |
allcolor/YaHP-Converter
|
YaHPConverter/src/org/allcolor/yahp/cl/converter/CDocumentCut.java
|
CDocumentCut.copyHeader
|
private static void copyHeader(
final Document doc,
final Document ndoc) {
NodeList headnl = doc.getElementsByTagName("head");
if (headnl.getLength() > 0) {
Element head = (Element) headnl.item(0);
ndoc.getDocumentElement()
.insertBefore(ndoc.adoptNode(head.cloneNode(true)),
ndoc.getDocumentElement().getFirstChild());
} // end if
}
|
java
|
private static void copyHeader(
final Document doc,
final Document ndoc) {
NodeList headnl = doc.getElementsByTagName("head");
if (headnl.getLength() > 0) {
Element head = (Element) headnl.item(0);
ndoc.getDocumentElement()
.insertBefore(ndoc.adoptNode(head.cloneNode(true)),
ndoc.getDocumentElement().getFirstChild());
} // end if
}
|
[
"private",
"static",
"void",
"copyHeader",
"(",
"final",
"Document",
"doc",
",",
"final",
"Document",
"ndoc",
")",
"{",
"NodeList",
"headnl",
"=",
"doc",
".",
"getElementsByTagName",
"(",
"\"head\"",
")",
";",
"if",
"(",
"headnl",
".",
"getLength",
"(",
")",
">",
"0",
")",
"{",
"Element",
"head",
"=",
"(",
"Element",
")",
"headnl",
".",
"item",
"(",
"0",
")",
";",
"ndoc",
".",
"getDocumentElement",
"(",
")",
".",
"insertBefore",
"(",
"ndoc",
".",
"adoptNode",
"(",
"head",
".",
"cloneNode",
"(",
"true",
")",
")",
",",
"ndoc",
".",
"getDocumentElement",
"(",
")",
".",
"getFirstChild",
"(",
")",
")",
";",
"}",
"// end if",
"}"
] |
Copy the html header from doc to ndoc
@param doc source of html header
@param ndoc destination
|
[
"Copy",
"the",
"html",
"header",
"from",
"doc",
"to",
"ndoc"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/CDocumentCut.java#L474-L485
|
4,096 |
allcolor/YaHP-Converter
|
YaHPSample/src/org/allcolor/yahp/sample/CSimpleConversion.java
|
CSimpleConversion.getParameter
|
private static String getParameter(
final String args[],
final String name) {
for (int i = 0; i < args.length; i++) {
if (args[i].equals(name)) {
if ((i + 1) < args.length) {
return args[i + 1];
} // end if
break;
} // end if
} // end for
return null;
}
|
java
|
private static String getParameter(
final String args[],
final String name) {
for (int i = 0; i < args.length; i++) {
if (args[i].equals(name)) {
if ((i + 1) < args.length) {
return args[i + 1];
} // end if
break;
} // end if
} // end for
return null;
}
|
[
"private",
"static",
"String",
"getParameter",
"(",
"final",
"String",
"args",
"[",
"]",
",",
"final",
"String",
"name",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"args",
"[",
"i",
"]",
".",
"equals",
"(",
"name",
")",
")",
"{",
"if",
"(",
"(",
"i",
"+",
"1",
")",
"<",
"args",
".",
"length",
")",
"{",
"return",
"args",
"[",
"i",
"+",
"1",
"]",
";",
"}",
"// end if",
"break",
";",
"}",
"// end if",
"}",
"// end for",
"return",
"null",
";",
"}"
] |
Return the value of the given parameter if set
@param args startup arguments
@param name parameter name
@return the value of the given parameter if set or null
|
[
"Return",
"the",
"value",
"of",
"the",
"given",
"parameter",
"if",
"set"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPSample/src/org/allcolor/yahp/sample/CSimpleConversion.java#L159-L173
|
4,097 |
allcolor/YaHP-Converter
|
YaHPSample/src/org/allcolor/yahp/sample/CSimpleConversion.java
|
CSimpleConversion.hasParameter
|
private static boolean hasParameter(
final String args[],
final String name) {
for (int i = 0; i < args.length; i++) {
if (args[i].equals(name)) {
return true;
} // end if
} // end for
return false;
}
|
java
|
private static boolean hasParameter(
final String args[],
final String name) {
for (int i = 0; i < args.length; i++) {
if (args[i].equals(name)) {
return true;
} // end if
} // end for
return false;
}
|
[
"private",
"static",
"boolean",
"hasParameter",
"(",
"final",
"String",
"args",
"[",
"]",
",",
"final",
"String",
"name",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"args",
"[",
"i",
"]",
".",
"equals",
"(",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"// end if",
"}",
"// end for",
"return",
"false",
";",
"}"
] |
return true if the given parameter is on the command line
@param args startup arguments
@param name parameter name
@return true if the given parameter is on the command line
|
[
"return",
"true",
"if",
"the",
"given",
"parameter",
"is",
"on",
"the",
"command",
"line"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPSample/src/org/allcolor/yahp/sample/CSimpleConversion.java#L183-L193
|
4,098 |
allcolor/YaHP-Converter
|
YaHPSample/src/org/allcolor/yahp/sample/CSimpleConversion.java
|
CSimpleConversion.showUsage
|
private static void showUsage(final String message) {
if (message != null) {
System.out.println(message);
} // end if
System.out.println(
"Usage :\n\tjava -cp yahp-sample.jar:yahp.jar org.allcolor.yahp.sample.CSimpleConversion" +
" --url [http|file]://myuri --out /path/to.pdf [font options] [renderer options] [security options] [--help|-h]");
System.out.println("\t[font options]:");
System.out.println("\t\t[--fontpath directory where TTF font files are located]");
System.out.println("\t[renderer options]:");
System.out.println("\t(Default renderer use Flying Saucer XHTML renderer. no option.)");
System.out.println("\t[security options]:");
System.out.println("\t\t[--password password]");
System.out.println("\t\t[--ks keystore file path]");
System.out.println("\t\t[--kspassword keystore file password]");
System.out.println("\t\t[--keypassword private key password]");
System.out.println("\t\t[--cryptreason reason]");
System.out.println("\t\t[--cryptlocation location]");
if (message != null) {
System.exit(-2);
} else {
System.exit(0);
}
}
|
java
|
private static void showUsage(final String message) {
if (message != null) {
System.out.println(message);
} // end if
System.out.println(
"Usage :\n\tjava -cp yahp-sample.jar:yahp.jar org.allcolor.yahp.sample.CSimpleConversion" +
" --url [http|file]://myuri --out /path/to.pdf [font options] [renderer options] [security options] [--help|-h]");
System.out.println("\t[font options]:");
System.out.println("\t\t[--fontpath directory where TTF font files are located]");
System.out.println("\t[renderer options]:");
System.out.println("\t(Default renderer use Flying Saucer XHTML renderer. no option.)");
System.out.println("\t[security options]:");
System.out.println("\t\t[--password password]");
System.out.println("\t\t[--ks keystore file path]");
System.out.println("\t\t[--kspassword keystore file password]");
System.out.println("\t\t[--keypassword private key password]");
System.out.println("\t\t[--cryptreason reason]");
System.out.println("\t\t[--cryptlocation location]");
if (message != null) {
System.exit(-2);
} else {
System.exit(0);
}
}
|
[
"private",
"static",
"void",
"showUsage",
"(",
"final",
"String",
"message",
")",
"{",
"if",
"(",
"message",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"message",
")",
";",
"}",
"// end if",
"System",
".",
"out",
".",
"println",
"(",
"\"Usage :\\n\\tjava -cp yahp-sample.jar:yahp.jar org.allcolor.yahp.sample.CSimpleConversion\"",
"+",
"\" --url [http|file]://myuri --out /path/to.pdf [font options] [renderer options] [security options] [--help|-h]\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t[font options]:\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t\\t[--fontpath directory where TTF font files are located]\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t[renderer options]:\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t(Default renderer use Flying Saucer XHTML renderer. no option.)\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t[security options]:\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t\\t[--password password]\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t\\t[--ks keystore file path]\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t\\t[--kspassword keystore file password]\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t\\t[--keypassword private key password]\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t\\t[--cryptreason reason]\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\t\\t[--cryptlocation location]\"",
")",
";",
"if",
"(",
"message",
"!=",
"null",
")",
"{",
"System",
".",
"exit",
"(",
"-",
"2",
")",
";",
"}",
"else",
"{",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}",
"}"
] |
Show the usage of the tool
@param message An error message
|
[
"Show",
"the",
"usage",
"of",
"the",
"tool"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPSample/src/org/allcolor/yahp/sample/CSimpleConversion.java#L200-L224
|
4,099 |
allcolor/YaHP-Converter
|
YaHPConverter/src/org/allcolor/yahp/converter/CJarLoaderURLStreamHandler.java
|
CJarLoaderURLStreamHandler.addClassPreload
|
public void addClassPreload(final String path, final byte array[]) {
try {
this.preload.put(path, new SoftReference(
new CGCCleaner(path, array)));
} catch (Exception ignore) {
}
}
|
java
|
public void addClassPreload(final String path, final byte array[]) {
try {
this.preload.put(path, new SoftReference(
new CGCCleaner(path, array)));
} catch (Exception ignore) {
}
}
|
[
"public",
"void",
"addClassPreload",
"(",
"final",
"String",
"path",
",",
"final",
"byte",
"array",
"[",
"]",
")",
"{",
"try",
"{",
"this",
".",
"preload",
".",
"put",
"(",
"path",
",",
"new",
"SoftReference",
"(",
"new",
"CGCCleaner",
"(",
"path",
",",
"array",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ignore",
")",
"{",
"}",
"}"
] |
add a class byte representation in the preload map
@param path
path to the class inside the jar
@param array
byte representation
|
[
"add",
"a",
"class",
"byte",
"representation",
"in",
"the",
"preload",
"map"
] |
d72745281766a784a6b319f3787aa1d8de7cd0fe
|
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CJarLoaderURLStreamHandler.java#L86-L92
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.