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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
23,200 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.getTotalPaddingEnd | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public int getTotalPaddingEnd (){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
return getPaddingEnd() + mInputView.getTotalPaddingEnd();
return getTotalPaddingRight();
} | java | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public int getTotalPaddingEnd (){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
return getPaddingEnd() + mInputView.getTotalPaddingEnd();
return getTotalPaddingRight();
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"JELLY_BEAN_MR1",
")",
"public",
"int",
"getTotalPaddingEnd",
"(",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"JELLY_BEAN_MR1",
")",
"return",
"getPaddingEnd",
"(",
")",
"+",
"mInputView",
".",
"getTotalPaddingEnd",
"(",
")",
";",
"return",
"getTotalPaddingRight",
"(",
")",
";",
"}"
] | Returns the total end padding of the view, including the end
Drawable if any. | [
"Returns",
"the",
"total",
"end",
"padding",
"of",
"the",
"view",
"including",
"the",
"end",
"Drawable",
"if",
"any",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2295-L2301 |
23,201 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.getTotalPaddingStart | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public int getTotalPaddingStart (){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
return getPaddingStart() + mInputView.getTotalPaddingStart();
return getTotalPaddingLeft();
} | java | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public int getTotalPaddingStart (){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
return getPaddingStart() + mInputView.getTotalPaddingStart();
return getTotalPaddingLeft();
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"JELLY_BEAN_MR1",
")",
"public",
"int",
"getTotalPaddingStart",
"(",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"JELLY_BEAN_MR1",
")",
"return",
"getPaddingStart",
"(",
")",
"+",
"mInputView",
".",
"getTotalPaddingStart",
"(",
")",
";",
"return",
"getTotalPaddingLeft",
"(",
")",
";",
"}"
] | Returns the total start padding of the view, including the start
Drawable if any. | [
"Returns",
"the",
"total",
"start",
"padding",
"of",
"the",
"view",
"including",
"the",
"start",
"Drawable",
"if",
"any",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2323-L2329 |
23,202 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.onSelectionChanged | protected void onSelectionChanged(int selStart, int selEnd) {
if(mInputView == null)
return;
if(mInputView instanceof InternalEditText)
((InternalEditText)mInputView).superOnSelectionChanged(selStart, selEnd);
else if(mInputView instanceof InternalAutoCompleteTextView)
((InternalAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);
else
((InternalMultiAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);
if(mOnSelectionChangedListener != null)
mOnSelectionChangedListener.onSelectionChanged(this, selStart, selEnd);
} | java | protected void onSelectionChanged(int selStart, int selEnd) {
if(mInputView == null)
return;
if(mInputView instanceof InternalEditText)
((InternalEditText)mInputView).superOnSelectionChanged(selStart, selEnd);
else if(mInputView instanceof InternalAutoCompleteTextView)
((InternalAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);
else
((InternalMultiAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);
if(mOnSelectionChangedListener != null)
mOnSelectionChangedListener.onSelectionChanged(this, selStart, selEnd);
} | [
"protected",
"void",
"onSelectionChanged",
"(",
"int",
"selStart",
",",
"int",
"selEnd",
")",
"{",
"if",
"(",
"mInputView",
"==",
"null",
")",
"return",
";",
"if",
"(",
"mInputView",
"instanceof",
"InternalEditText",
")",
"(",
"(",
"InternalEditText",
")",
"mInputView",
")",
".",
"superOnSelectionChanged",
"(",
"selStart",
",",
"selEnd",
")",
";",
"else",
"if",
"(",
"mInputView",
"instanceof",
"InternalAutoCompleteTextView",
")",
"(",
"(",
"InternalAutoCompleteTextView",
")",
"mInputView",
")",
".",
"superOnSelectionChanged",
"(",
"selStart",
",",
"selEnd",
")",
";",
"else",
"(",
"(",
"InternalMultiAutoCompleteTextView",
")",
"mInputView",
")",
".",
"superOnSelectionChanged",
"(",
"selStart",
",",
"selEnd",
")",
";",
"if",
"(",
"mOnSelectionChangedListener",
"!=",
"null",
")",
"mOnSelectionChangedListener",
".",
"onSelectionChanged",
"(",
"this",
",",
"selStart",
",",
"selEnd",
")",
";",
"}"
] | This method is called when the selection has changed, in case any
subclasses would like to know.
@param selStart The new selection start location.
@param selEnd The new selection end location. | [
"This",
"method",
"is",
"called",
"when",
"the",
"selection",
"has",
"changed",
"in",
"case",
"any",
"subclasses",
"would",
"like",
"to",
"know",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2609-L2622 |
23,203 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.setAllCaps | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void setAllCaps (boolean allCaps){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
mInputView.setAllCaps(allCaps);
} | java | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void setAllCaps (boolean allCaps){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
mInputView.setAllCaps(allCaps);
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"ICE_CREAM_SANDWICH",
")",
"public",
"void",
"setAllCaps",
"(",
"boolean",
"allCaps",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"ICE_CREAM_SANDWICH",
")",
"mInputView",
".",
"setAllCaps",
"(",
"allCaps",
")",
";",
"}"
] | Sets the properties of this field to transform input to ALL CAPS
display. This may use a "small caps" formatting if available.
This setting will be ignored if this field is editable or selectable.
This call replaces the current transformation method. Disabling this
will not necessarily restore the previous behavior from before this
was enabled.
@see #setTransformationMethod(TransformationMethod)
@attr ref android.R.styleable#TextView_textAllCaps | [
"Sets",
"the",
"properties",
"of",
"this",
"field",
"to",
"transform",
"input",
"to",
"ALL",
"CAPS",
"display",
".",
"This",
"may",
"use",
"a",
"small",
"caps",
"formatting",
"if",
"available",
".",
"This",
"setting",
"will",
"be",
"ignored",
"if",
"this",
"field",
"is",
"editable",
"or",
"selectable",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2645-L2649 |
23,204 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.setCompoundDrawablePadding | public void setCompoundDrawablePadding (int pad){
mInputView.setCompoundDrawablePadding(pad);
if(mDividerCompoundPadding) {
mDivider.setPadding(mInputView.getTotalPaddingLeft(), mInputView.getTotalPaddingRight());
if(mLabelEnable)
mLabelView.setPadding(mDivider.getPaddingLeft(), mLabelView.getPaddingTop(), mDivider.getPaddingRight(), mLabelView.getPaddingBottom());
if(mSupportMode != SUPPORT_MODE_NONE)
mSupportView.setPadding(mDivider.getPaddingLeft(), mSupportView.getPaddingTop(), mDivider.getPaddingRight(), mSupportView.getPaddingBottom());
}
} | java | public void setCompoundDrawablePadding (int pad){
mInputView.setCompoundDrawablePadding(pad);
if(mDividerCompoundPadding) {
mDivider.setPadding(mInputView.getTotalPaddingLeft(), mInputView.getTotalPaddingRight());
if(mLabelEnable)
mLabelView.setPadding(mDivider.getPaddingLeft(), mLabelView.getPaddingTop(), mDivider.getPaddingRight(), mLabelView.getPaddingBottom());
if(mSupportMode != SUPPORT_MODE_NONE)
mSupportView.setPadding(mDivider.getPaddingLeft(), mSupportView.getPaddingTop(), mDivider.getPaddingRight(), mSupportView.getPaddingBottom());
}
} | [
"public",
"void",
"setCompoundDrawablePadding",
"(",
"int",
"pad",
")",
"{",
"mInputView",
".",
"setCompoundDrawablePadding",
"(",
"pad",
")",
";",
"if",
"(",
"mDividerCompoundPadding",
")",
"{",
"mDivider",
".",
"setPadding",
"(",
"mInputView",
".",
"getTotalPaddingLeft",
"(",
")",
",",
"mInputView",
".",
"getTotalPaddingRight",
"(",
")",
")",
";",
"if",
"(",
"mLabelEnable",
")",
"mLabelView",
".",
"setPadding",
"(",
"mDivider",
".",
"getPaddingLeft",
"(",
")",
",",
"mLabelView",
".",
"getPaddingTop",
"(",
")",
",",
"mDivider",
".",
"getPaddingRight",
"(",
")",
",",
"mLabelView",
".",
"getPaddingBottom",
"(",
")",
")",
";",
"if",
"(",
"mSupportMode",
"!=",
"SUPPORT_MODE_NONE",
")",
"mSupportView",
".",
"setPadding",
"(",
"mDivider",
".",
"getPaddingLeft",
"(",
")",
",",
"mSupportView",
".",
"getPaddingTop",
"(",
")",
",",
"mDivider",
".",
"getPaddingRight",
"(",
")",
",",
"mSupportView",
".",
"getPaddingBottom",
"(",
")",
")",
";",
"}",
"}"
] | Sets the size of the padding between the compound drawables and
the text.
@attr ref android.R.styleable#TextView_drawablePadding | [
"Sets",
"the",
"size",
"of",
"the",
"padding",
"between",
"the",
"compound",
"drawables",
"and",
"the",
"text",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2668-L2677 |
23,205 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.setCustomSelectionActionModeCallback | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setCustomSelectionActionModeCallback (ActionMode.Callback actionModeCallback){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mInputView.setCustomSelectionActionModeCallback(actionModeCallback);
} | java | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setCustomSelectionActionModeCallback (ActionMode.Callback actionModeCallback){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mInputView.setCustomSelectionActionModeCallback(actionModeCallback);
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"public",
"void",
"setCustomSelectionActionModeCallback",
"(",
"ActionMode",
".",
"Callback",
"actionModeCallback",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"mInputView",
".",
"setCustomSelectionActionModeCallback",
"(",
"actionModeCallback",
")",
";",
"}"
] | If provided, this ActionMode.Callback will be used to create the ActionMode when text
selection is initiated in this View.
The standard implementation populates the menu with a subset of Select All, Cut, Copy and
Paste actions, depending on what this View supports.
A custom implementation can add new entries in the default menu in its
{@link ActionMode.Callback#onPrepareActionMode(ActionMode, android.view.Menu)} method. The
default actions can also be removed from the menu using {@link android.view.Menu#removeItem(int)} and
passing {@link android.R.id#selectAll}, {@link android.R.id#cut}, {@link android.R.id#copy}
or {@link android.R.id#paste} ids as parameters.
Returning false from
{@link ActionMode.Callback#onCreateActionMode(ActionMode, android.view.Menu)} will prevent
the action mode from being started.
Action click events should be handled by the custom implementation of
{@link ActionMode.Callback#onActionItemClicked(ActionMode, android.view.MenuItem)}.
Note that text selection mode is not started when a TextView receives focus and the
{@link android.R.attr#selectAllOnFocus} flag has been set. The content is highlighted in
that case, to allow for quick replacement. | [
"If",
"provided",
"this",
"ActionMode",
".",
"Callback",
"will",
"be",
"used",
"to",
"create",
"the",
"ActionMode",
"when",
"text",
"selection",
"is",
"initiated",
"in",
"this",
"View",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2849-L2853 |
23,206 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.setElegantTextHeight | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setElegantTextHeight (boolean elegant){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
mInputView.setElegantTextHeight(elegant);
} | java | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setElegantTextHeight (boolean elegant){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
mInputView.setElegantTextHeight(elegant);
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"LOLLIPOP",
")",
"public",
"void",
"setElegantTextHeight",
"(",
"boolean",
"elegant",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"LOLLIPOP",
")",
"mInputView",
".",
"setElegantTextHeight",
"(",
"elegant",
")",
";",
"}"
] | Set the TextView's elegant height metrics flag. This setting selects font
variants that have not been compacted to fit Latin-based vertical
metrics, and also increases top and bottom bounds to provide more space.
@param elegant set the paint's elegant metrics flag.
@attr ref android.R.styleable#TextView_elegantTextHeight | [
"Set",
"the",
"TextView",
"s",
"elegant",
"height",
"metrics",
"flag",
".",
"This",
"setting",
"selects",
"font",
"variants",
"that",
"have",
"not",
"been",
"compacted",
"to",
"fit",
"Latin",
"-",
"based",
"vertical",
"metrics",
"and",
"also",
"increases",
"top",
"and",
"bottom",
"bounds",
"to",
"provide",
"more",
"space",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2871-L2875 |
23,207 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.setHint | public final void setHint (CharSequence hint){
mInputView.setHint(hint);
if(mLabelView != null)
mLabelView.setText(hint);
} | java | public final void setHint (CharSequence hint){
mInputView.setHint(hint);
if(mLabelView != null)
mLabelView.setText(hint);
} | [
"public",
"final",
"void",
"setHint",
"(",
"CharSequence",
"hint",
")",
"{",
"mInputView",
".",
"setHint",
"(",
"hint",
")",
";",
"if",
"(",
"mLabelView",
"!=",
"null",
")",
"mLabelView",
".",
"setText",
"(",
"hint",
")",
";",
"}"
] | Sets the text to be displayed when the text of the TextView is empty.
Null means to use the normal empty text. The hint does not currently
participate in determining the size of the view.
@attr ref android.R.styleable#TextView_hint | [
"Sets",
"the",
"text",
"to",
"be",
"displayed",
"when",
"the",
"text",
"of",
"the",
"TextView",
"is",
"empty",
".",
"Null",
"means",
"to",
"use",
"the",
"normal",
"empty",
"text",
".",
"The",
"hint",
"does",
"not",
"currently",
"participate",
"in",
"determining",
"the",
"size",
"of",
"the",
"view",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2971-L2975 |
23,208 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.setHint | public final void setHint (int resid){
mInputView.setHint(resid);
if(mLabelView != null)
mLabelView.setText(resid);
} | java | public final void setHint (int resid){
mInputView.setHint(resid);
if(mLabelView != null)
mLabelView.setText(resid);
} | [
"public",
"final",
"void",
"setHint",
"(",
"int",
"resid",
")",
"{",
"mInputView",
".",
"setHint",
"(",
"resid",
")",
";",
"if",
"(",
"mLabelView",
"!=",
"null",
")",
"mLabelView",
".",
"setText",
"(",
"resid",
")",
";",
"}"
] | Sets the text to be displayed when the text of the TextView is empty,
from a resource.
@attr ref android.R.styleable#TextView_hint | [
"Sets",
"the",
"text",
"to",
"be",
"displayed",
"when",
"the",
"text",
"of",
"the",
"TextView",
"is",
"empty",
"from",
"a",
"resource",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2983-L2987 |
23,209 | rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.setLetterSpacing | public void setLetterSpacing (float letterSpacing){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
mInputView.setLetterSpacing(letterSpacing);
} | java | public void setLetterSpacing (float letterSpacing){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
mInputView.setLetterSpacing(letterSpacing);
} | [
"public",
"void",
"setLetterSpacing",
"(",
"float",
"letterSpacing",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"LOLLIPOP",
")",
"mInputView",
".",
"setLetterSpacing",
"(",
"letterSpacing",
")",
";",
"}"
] | Sets text letter-spacing. The value is in 'EM' units. Typical values
for slight expansion will be around 0.05. Negative values tighten text.
@see #getLetterSpacing()
@see android.graphics.Paint#getLetterSpacing
@attr ref android.R.styleable#TextView_letterSpacing | [
"Sets",
"text",
"letter",
"-",
"spacing",
".",
"The",
"value",
"is",
"in",
"EM",
"units",
".",
"Typical",
"values",
"for",
"slight",
"expansion",
"will",
"be",
"around",
"0",
".",
"05",
".",
"Negative",
"values",
"tighten",
"text",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L3135-L3138 |
23,210 | rey5137/material | material/src/main/java/com/rey/material/widget/DatePicker.java | DatePicker.goTo | public void goTo(int month, int year){
int position = mAdapter.positionOfMonth(month, year);
postSetSelectionFromTop(position, 0);
} | java | public void goTo(int month, int year){
int position = mAdapter.positionOfMonth(month, year);
postSetSelectionFromTop(position, 0);
} | [
"public",
"void",
"goTo",
"(",
"int",
"month",
",",
"int",
"year",
")",
"{",
"int",
"position",
"=",
"mAdapter",
".",
"positionOfMonth",
"(",
"month",
",",
"year",
")",
";",
"postSetSelectionFromTop",
"(",
"position",
",",
"0",
")",
";",
"}"
] | Jump to the view of a specific month.
@param month
@param year | [
"Jump",
"to",
"the",
"view",
"of",
"a",
"specific",
"month",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/DatePicker.java#L397-L400 |
23,211 | rey5137/material | material/src/main/java/com/rey/material/widget/DatePicker.java | DatePicker.setDate | public void setDate(int day, int month, int year){
if(mAdapter.getYear() == year && mAdapter.getMonth() == month && mAdapter.getDay() == day)
return;
mAdapter.setDate(day, month, year, false);
goTo(month, year);
} | java | public void setDate(int day, int month, int year){
if(mAdapter.getYear() == year && mAdapter.getMonth() == month && mAdapter.getDay() == day)
return;
mAdapter.setDate(day, month, year, false);
goTo(month, year);
} | [
"public",
"void",
"setDate",
"(",
"int",
"day",
",",
"int",
"month",
",",
"int",
"year",
")",
"{",
"if",
"(",
"mAdapter",
".",
"getYear",
"(",
")",
"==",
"year",
"&&",
"mAdapter",
".",
"getMonth",
"(",
")",
"==",
"month",
"&&",
"mAdapter",
".",
"getDay",
"(",
")",
"==",
"day",
")",
"return",
";",
"mAdapter",
".",
"setDate",
"(",
"day",
",",
"month",
",",
"year",
",",
"false",
")",
";",
"goTo",
"(",
"month",
",",
"year",
")",
";",
"}"
] | Set the selected date of this DatePicker.
@param day The day value of selected date.
@param month The month value of selected date.
@param year The year value of selected date. | [
"Set",
"the",
"selected",
"date",
"of",
"this",
"DatePicker",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/DatePicker.java#L418-L424 |
23,212 | rey5137/material | material/src/main/java/com/rey/material/widget/DatePicker.java | DatePicker.getFormattedDate | public String getFormattedDate(DateFormat formatter){
mCalendar.set(Calendar.YEAR, mAdapter.getYear());
mCalendar.set(Calendar.MONTH, mAdapter.getMonth());
mCalendar.set(Calendar.DAY_OF_MONTH, mAdapter.getDay());
return formatter.format(mCalendar.getTime());
} | java | public String getFormattedDate(DateFormat formatter){
mCalendar.set(Calendar.YEAR, mAdapter.getYear());
mCalendar.set(Calendar.MONTH, mAdapter.getMonth());
mCalendar.set(Calendar.DAY_OF_MONTH, mAdapter.getDay());
return formatter.format(mCalendar.getTime());
} | [
"public",
"String",
"getFormattedDate",
"(",
"DateFormat",
"formatter",
")",
"{",
"mCalendar",
".",
"set",
"(",
"Calendar",
".",
"YEAR",
",",
"mAdapter",
".",
"getYear",
"(",
")",
")",
";",
"mCalendar",
".",
"set",
"(",
"Calendar",
".",
"MONTH",
",",
"mAdapter",
".",
"getMonth",
"(",
")",
")",
";",
"mCalendar",
".",
"set",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
",",
"mAdapter",
".",
"getDay",
"(",
")",
")",
";",
"return",
"formatter",
".",
"format",
"(",
"mCalendar",
".",
"getTime",
"(",
")",
")",
";",
"}"
] | Get the formatted string of selected date.
@param formatter The DateFormat used to format the date.
@return | [
"Get",
"the",
"formatted",
"string",
"of",
"selected",
"date",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/DatePicker.java#L460-L465 |
23,213 | rey5137/material | material/src/main/java/com/rey/material/app/DatePickerDialog.java | DatePickerDialog.date | public DatePickerDialog date(int day, int month, int year){
mDatePickerLayout.setDate(day, month, year);
return this;
} | java | public DatePickerDialog date(int day, int month, int year){
mDatePickerLayout.setDate(day, month, year);
return this;
} | [
"public",
"DatePickerDialog",
"date",
"(",
"int",
"day",
",",
"int",
"month",
",",
"int",
"year",
")",
"{",
"mDatePickerLayout",
".",
"setDate",
"(",
"day",
",",
"month",
",",
"year",
")",
";",
"return",
"this",
";",
"}"
] | Set the selected date of this DatePickerDialog.
@param day The day value of selected date.
@param month The month value of selected date.
@param year The year value of selected date.
@return The DatePickerDialog for chaining methods. | [
"Set",
"the",
"selected",
"date",
"of",
"this",
"DatePickerDialog",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/DatePickerDialog.java#L126-L129 |
23,214 | rey5137/material | material/src/main/java/com/rey/material/app/ToolbarManager.java | ToolbarManager.setCurrentGroup | public void setCurrentGroup(int groupId){
if(mCurrentGroup != groupId){
int oldGroupId = mCurrentGroup;
mCurrentGroup = groupId;
mGroupChanged = true;
dispatchOnToolbarGroupChanged(oldGroupId, mCurrentGroup);
animateOut();
}
} | java | public void setCurrentGroup(int groupId){
if(mCurrentGroup != groupId){
int oldGroupId = mCurrentGroup;
mCurrentGroup = groupId;
mGroupChanged = true;
dispatchOnToolbarGroupChanged(oldGroupId, mCurrentGroup);
animateOut();
}
} | [
"public",
"void",
"setCurrentGroup",
"(",
"int",
"groupId",
")",
"{",
"if",
"(",
"mCurrentGroup",
"!=",
"groupId",
")",
"{",
"int",
"oldGroupId",
"=",
"mCurrentGroup",
";",
"mCurrentGroup",
"=",
"groupId",
";",
"mGroupChanged",
"=",
"true",
";",
"dispatchOnToolbarGroupChanged",
"(",
"oldGroupId",
",",
"mCurrentGroup",
")",
";",
"animateOut",
"(",
")",
";",
"}",
"}"
] | Set current group of the Toolbar.
@param groupId The id of group. | [
"Set",
"current",
"group",
"of",
"the",
"Toolbar",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/ToolbarManager.java#L140-L148 |
23,215 | rey5137/material | material/src/main/java/com/rey/material/app/ToolbarManager.java | ToolbarManager.createMenu | public void createMenu(int menuId){
mToolbar.inflateMenu(menuId);
mMenuDataChanged = true;
if(mAppCompatDelegate == null)
onPrepareMenu();
} | java | public void createMenu(int menuId){
mToolbar.inflateMenu(menuId);
mMenuDataChanged = true;
if(mAppCompatDelegate == null)
onPrepareMenu();
} | [
"public",
"void",
"createMenu",
"(",
"int",
"menuId",
")",
"{",
"mToolbar",
".",
"inflateMenu",
"(",
"menuId",
")",
";",
"mMenuDataChanged",
"=",
"true",
";",
"if",
"(",
"mAppCompatDelegate",
"==",
"null",
")",
"onPrepareMenu",
"(",
")",
";",
"}"
] | This funcction should be called in onCreateOptionsMenu of Activity or Fragment to inflate a new menu.
@param menuId | [
"This",
"funcction",
"should",
"be",
"called",
"in",
"onCreateOptionsMenu",
"of",
"Activity",
"or",
"Fragment",
"to",
"inflate",
"a",
"new",
"menu",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/ToolbarManager.java#L154-L159 |
23,216 | rey5137/material | material/src/main/java/com/rey/material/widget/CheckBox.java | CheckBox.setCheckedImmediately | public void setCheckedImmediately(boolean checked){
if(getButtonDrawable() instanceof CheckBoxDrawable){
CheckBoxDrawable drawable = (CheckBoxDrawable)getButtonDrawable();
drawable.setAnimEnable(false);
setChecked(checked);
drawable.setAnimEnable(true);
}
else
setChecked(checked);
} | java | public void setCheckedImmediately(boolean checked){
if(getButtonDrawable() instanceof CheckBoxDrawable){
CheckBoxDrawable drawable = (CheckBoxDrawable)getButtonDrawable();
drawable.setAnimEnable(false);
setChecked(checked);
drawable.setAnimEnable(true);
}
else
setChecked(checked);
} | [
"public",
"void",
"setCheckedImmediately",
"(",
"boolean",
"checked",
")",
"{",
"if",
"(",
"getButtonDrawable",
"(",
")",
"instanceof",
"CheckBoxDrawable",
")",
"{",
"CheckBoxDrawable",
"drawable",
"=",
"(",
"CheckBoxDrawable",
")",
"getButtonDrawable",
"(",
")",
";",
"drawable",
".",
"setAnimEnable",
"(",
"false",
")",
";",
"setChecked",
"(",
"checked",
")",
";",
"drawable",
".",
"setAnimEnable",
"(",
"true",
")",
";",
"}",
"else",
"setChecked",
"(",
"checked",
")",
";",
"}"
] | Change the checked state of this button immediately without showing animation.
@param checked The checked state. | [
"Change",
"the",
"checked",
"state",
"of",
"this",
"button",
"immediately",
"without",
"showing",
"animation",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/CheckBox.java#L37-L46 |
23,217 | rey5137/material | material/src/main/java/com/rey/material/widget/Switch.java | Switch.setCheckedImmediately | public void setCheckedImmediately(boolean checked){
if(mChecked != checked) {
mChecked = checked;
if(mOnCheckedChangeListener != null)
mOnCheckedChangeListener.onCheckedChanged(this, mChecked);
}
mThumbPosition = mChecked ? 1f : 0f;
invalidate();
} | java | public void setCheckedImmediately(boolean checked){
if(mChecked != checked) {
mChecked = checked;
if(mOnCheckedChangeListener != null)
mOnCheckedChangeListener.onCheckedChanged(this, mChecked);
}
mThumbPosition = mChecked ? 1f : 0f;
invalidate();
} | [
"public",
"void",
"setCheckedImmediately",
"(",
"boolean",
"checked",
")",
"{",
"if",
"(",
"mChecked",
"!=",
"checked",
")",
"{",
"mChecked",
"=",
"checked",
";",
"if",
"(",
"mOnCheckedChangeListener",
"!=",
"null",
")",
"mOnCheckedChangeListener",
".",
"onCheckedChanged",
"(",
"this",
",",
"mChecked",
")",
";",
"}",
"mThumbPosition",
"=",
"mChecked",
"?",
"1f",
":",
"0f",
";",
"invalidate",
"(",
")",
";",
"}"
] | Change the checked state of this Switch immediately without showing animation.
@param checked The checked state. | [
"Change",
"the",
"checked",
"state",
"of",
"this",
"Switch",
"immediately",
"without",
"showing",
"animation",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/Switch.java#L305-L313 |
23,218 | rey5137/material | material/src/main/java/com/rey/material/widget/YearPicker.java | YearPicker.goTo | public void goTo(int year){
int position = mAdapter.positionOfYear(year) - mPositionShift;
int offset = mDistanceShift;
if(position < 0){
position = 0;
offset = 0;
}
postSetSelectionFromTop(position, offset);
} | java | public void goTo(int year){
int position = mAdapter.positionOfYear(year) - mPositionShift;
int offset = mDistanceShift;
if(position < 0){
position = 0;
offset = 0;
}
postSetSelectionFromTop(position, offset);
} | [
"public",
"void",
"goTo",
"(",
"int",
"year",
")",
"{",
"int",
"position",
"=",
"mAdapter",
".",
"positionOfYear",
"(",
"year",
")",
"-",
"mPositionShift",
";",
"int",
"offset",
"=",
"mDistanceShift",
";",
"if",
"(",
"position",
"<",
"0",
")",
"{",
"position",
"=",
"0",
";",
"offset",
"=",
"0",
";",
"}",
"postSetSelectionFromTop",
"(",
"position",
",",
"offset",
")",
";",
"}"
] | Jump to a specific year.
@param year | [
"Jump",
"to",
"a",
"specific",
"year",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/YearPicker.java#L219-L227 |
23,219 | rey5137/material | material/src/main/java/com/rey/material/widget/YearPicker.java | YearPicker.setYear | public void setYear(int year){
if(mAdapter.getYear() == year)
return;
mAdapter.setYear(year);
goTo(year);
} | java | public void setYear(int year){
if(mAdapter.getYear() == year)
return;
mAdapter.setYear(year);
goTo(year);
} | [
"public",
"void",
"setYear",
"(",
"int",
"year",
")",
"{",
"if",
"(",
"mAdapter",
".",
"getYear",
"(",
")",
"==",
"year",
")",
"return",
";",
"mAdapter",
".",
"setYear",
"(",
"year",
")",
";",
"goTo",
"(",
"year",
")",
";",
"}"
] | Set the selected year.
@param year The selected year value. | [
"Set",
"the",
"selected",
"year",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/YearPicker.java#L243-L249 |
23,220 | rey5137/material | material/src/main/java/com/rey/material/widget/SnackBar.java | SnackBar.actionRipple | public SnackBar actionRipple(int resId){
if(resId != 0)
ViewUtil.setBackground(mAction, new RippleDrawable.Builder(getContext(), resId).build());
return this;
} | java | public SnackBar actionRipple(int resId){
if(resId != 0)
ViewUtil.setBackground(mAction, new RippleDrawable.Builder(getContext(), resId).build());
return this;
} | [
"public",
"SnackBar",
"actionRipple",
"(",
"int",
"resId",
")",
"{",
"if",
"(",
"resId",
"!=",
"0",
")",
"ViewUtil",
".",
"setBackground",
"(",
"mAction",
",",
"new",
"RippleDrawable",
".",
"Builder",
"(",
"getContext",
"(",
")",
",",
"resId",
")",
".",
"build",
"(",
")",
")",
";",
"return",
"this",
";",
"}"
] | Set the style of RippleEffect of the ActionButton.
@param resId The resourceId of RippleEffect.
@return This SnackBar for chaining methods. | [
"Set",
"the",
"style",
"of",
"RippleEffect",
"of",
"the",
"ActionButton",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/SnackBar.java#L551-L555 |
23,221 | rey5137/material | material/src/main/java/com/rey/material/widget/SnackBar.java | SnackBar.horizontalPadding | public SnackBar horizontalPadding(int padding){
mText.setPadding(padding, mText.getPaddingTop(), padding, mText.getPaddingBottom());
mAction.setPadding(padding, mAction.getPaddingTop(), padding, mAction.getPaddingBottom());
return this;
} | java | public SnackBar horizontalPadding(int padding){
mText.setPadding(padding, mText.getPaddingTop(), padding, mText.getPaddingBottom());
mAction.setPadding(padding, mAction.getPaddingTop(), padding, mAction.getPaddingBottom());
return this;
} | [
"public",
"SnackBar",
"horizontalPadding",
"(",
"int",
"padding",
")",
"{",
"mText",
".",
"setPadding",
"(",
"padding",
",",
"mText",
".",
"getPaddingTop",
"(",
")",
",",
"padding",
",",
"mText",
".",
"getPaddingBottom",
"(",
")",
")",
";",
"mAction",
".",
"setPadding",
"(",
"padding",
",",
"mAction",
".",
"getPaddingTop",
"(",
")",
",",
"padding",
",",
"mAction",
".",
"getPaddingBottom",
"(",
")",
")",
";",
"return",
"this",
";",
"}"
] | Set the horizontal padding between this SnackBar and it's text and button.
@param padding
@return This SnackBar for chaining methods. | [
"Set",
"the",
"horizontal",
"padding",
"between",
"this",
"SnackBar",
"and",
"it",
"s",
"text",
"and",
"button",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/SnackBar.java#L592-L596 |
23,222 | rey5137/material | material/src/main/java/com/rey/material/widget/SnackBar.java | SnackBar.verticalPadding | public SnackBar verticalPadding(int padding){
mText.setPadding(mText.getPaddingLeft(), padding, mText.getPaddingRight(), padding);
mAction.setPadding(mAction.getPaddingLeft(), padding, mAction.getPaddingRight(), padding);
return this;
} | java | public SnackBar verticalPadding(int padding){
mText.setPadding(mText.getPaddingLeft(), padding, mText.getPaddingRight(), padding);
mAction.setPadding(mAction.getPaddingLeft(), padding, mAction.getPaddingRight(), padding);
return this;
} | [
"public",
"SnackBar",
"verticalPadding",
"(",
"int",
"padding",
")",
"{",
"mText",
".",
"setPadding",
"(",
"mText",
".",
"getPaddingLeft",
"(",
")",
",",
"padding",
",",
"mText",
".",
"getPaddingRight",
"(",
")",
",",
"padding",
")",
";",
"mAction",
".",
"setPadding",
"(",
"mAction",
".",
"getPaddingLeft",
"(",
")",
",",
"padding",
",",
"mAction",
".",
"getPaddingRight",
"(",
")",
",",
"padding",
")",
";",
"return",
"this",
";",
"}"
] | Set the vertical padding between this SnackBar and it's text and button.
@param padding
@return This SnackBar for chaining methods. | [
"Set",
"the",
"vertical",
"padding",
"between",
"this",
"SnackBar",
"and",
"it",
"s",
"text",
"and",
"button",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/SnackBar.java#L603-L607 |
23,223 | rey5137/material | material/src/main/java/com/rey/material/widget/SnackBar.java | SnackBar.padding | public SnackBar padding(int horizontalPadding, int verticalPadding){
mText.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
mAction.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
return this;
} | java | public SnackBar padding(int horizontalPadding, int verticalPadding){
mText.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
mAction.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
return this;
} | [
"public",
"SnackBar",
"padding",
"(",
"int",
"horizontalPadding",
",",
"int",
"verticalPadding",
")",
"{",
"mText",
".",
"setPadding",
"(",
"horizontalPadding",
",",
"verticalPadding",
",",
"horizontalPadding",
",",
"verticalPadding",
")",
";",
"mAction",
".",
"setPadding",
"(",
"horizontalPadding",
",",
"verticalPadding",
",",
"horizontalPadding",
",",
"verticalPadding",
")",
";",
"return",
"this",
";",
"}"
] | Set the padding between this SnackBar and it's text and button.
@param horizontalPadding The horizontal padding.
@param verticalPadding The vertical padding.
@return This SnackBar for chaining methods. | [
"Set",
"the",
"padding",
"between",
"this",
"SnackBar",
"and",
"it",
"s",
"text",
"and",
"button",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/SnackBar.java#L615-L619 |
23,224 | rey5137/material | material/src/main/java/com/rey/material/widget/SnackBar.java | SnackBar.show | public void show(Activity activity){
show((ViewGroup)activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT));
} | java | public void show(Activity activity){
show((ViewGroup)activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT));
} | [
"public",
"void",
"show",
"(",
"Activity",
"activity",
")",
"{",
"show",
"(",
"(",
"ViewGroup",
")",
"activity",
".",
"getWindow",
"(",
")",
".",
"findViewById",
"(",
"Window",
".",
"ID_ANDROID_CONTENT",
")",
")",
";",
"}"
] | Show this SnackBar. It will auto attach to the activity's root view.
@param activity | [
"Show",
"this",
"SnackBar",
".",
"It",
"will",
"auto",
"attach",
"to",
"the",
"activity",
"s",
"root",
"view",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/SnackBar.java#L755-L757 |
23,225 | rey5137/material | material/src/main/java/com/rey/material/widget/SnackBar.java | SnackBar.show | public void show(ViewGroup parent){
if(mState == STATE_SHOWING || mState == STATE_DISMISSING)
return;
if(getParent() != parent) {
if(getParent() != null)
((ViewGroup) getParent()).removeView(this);
parent.addView(this);
}
show();
} | java | public void show(ViewGroup parent){
if(mState == STATE_SHOWING || mState == STATE_DISMISSING)
return;
if(getParent() != parent) {
if(getParent() != null)
((ViewGroup) getParent()).removeView(this);
parent.addView(this);
}
show();
} | [
"public",
"void",
"show",
"(",
"ViewGroup",
"parent",
")",
"{",
"if",
"(",
"mState",
"==",
"STATE_SHOWING",
"||",
"mState",
"==",
"STATE_DISMISSING",
")",
"return",
";",
"if",
"(",
"getParent",
"(",
")",
"!=",
"parent",
")",
"{",
"if",
"(",
"getParent",
"(",
")",
"!=",
"null",
")",
"(",
"(",
"ViewGroup",
")",
"getParent",
"(",
")",
")",
".",
"removeView",
"(",
"this",
")",
";",
"parent",
".",
"addView",
"(",
"this",
")",
";",
"}",
"show",
"(",
")",
";",
"}"
] | Show this SnackBar. It will auto attach to the parent view.
@param parent Must be {@linke android.widget.FrameLayout} or {@link android.widget.RelativeLayout} | [
"Show",
"this",
"SnackBar",
".",
"It",
"will",
"auto",
"attach",
"to",
"the",
"parent",
"view",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/SnackBar.java#L763-L775 |
23,226 | rey5137/material | material/src/main/java/com/rey/material/widget/SnackBar.java | SnackBar.show | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void show(){
ViewGroup parent = (ViewGroup)getParent();
if(parent == null || mState == STATE_SHOWING || mState == STATE_DISMISSING)
return;
if(parent instanceof android.widget.FrameLayout){
LayoutParams params = (LayoutParams)getLayoutParams();
params.width = mWidth;
params.height = mHeight;
params.gravity = Gravity.START | Gravity.BOTTOM;
if(mIsRtl)
params.rightMargin = mMarginStart;
else
params.leftMargin = mMarginStart;
params.bottomMargin = mMarginBottom;
setLayoutParams(params);
}
else if(parent instanceof android.widget.RelativeLayout){
android.widget.RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams)getLayoutParams();
params.width = mWidth;
params.height = mHeight;
params.addRule(android.widget.RelativeLayout.ALIGN_PARENT_BOTTOM);
params.addRule(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? android.widget.RelativeLayout.ALIGN_PARENT_START : android.widget.RelativeLayout.ALIGN_PARENT_LEFT);
if(mIsRtl)
params.rightMargin = mMarginStart;
else
params.leftMargin = mMarginStart;
params.bottomMargin = mMarginBottom;
setLayoutParams(params);
}
if(mInAnimation != null && mState != STATE_SHOWN){
mInAnimation.cancel();
mInAnimation.reset();
mInAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
setState(STATE_SHOWING);
setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
setState(STATE_SHOWN);
startTimer();
}
});
clearAnimation();
startAnimation(mInAnimation);
}
else {
setVisibility(View.VISIBLE);
setState(STATE_SHOWN);
startTimer();
}
} | java | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void show(){
ViewGroup parent = (ViewGroup)getParent();
if(parent == null || mState == STATE_SHOWING || mState == STATE_DISMISSING)
return;
if(parent instanceof android.widget.FrameLayout){
LayoutParams params = (LayoutParams)getLayoutParams();
params.width = mWidth;
params.height = mHeight;
params.gravity = Gravity.START | Gravity.BOTTOM;
if(mIsRtl)
params.rightMargin = mMarginStart;
else
params.leftMargin = mMarginStart;
params.bottomMargin = mMarginBottom;
setLayoutParams(params);
}
else if(parent instanceof android.widget.RelativeLayout){
android.widget.RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams)getLayoutParams();
params.width = mWidth;
params.height = mHeight;
params.addRule(android.widget.RelativeLayout.ALIGN_PARENT_BOTTOM);
params.addRule(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? android.widget.RelativeLayout.ALIGN_PARENT_START : android.widget.RelativeLayout.ALIGN_PARENT_LEFT);
if(mIsRtl)
params.rightMargin = mMarginStart;
else
params.leftMargin = mMarginStart;
params.bottomMargin = mMarginBottom;
setLayoutParams(params);
}
if(mInAnimation != null && mState != STATE_SHOWN){
mInAnimation.cancel();
mInAnimation.reset();
mInAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
setState(STATE_SHOWING);
setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
setState(STATE_SHOWN);
startTimer();
}
});
clearAnimation();
startAnimation(mInAnimation);
}
else {
setVisibility(View.VISIBLE);
setState(STATE_SHOWN);
startTimer();
}
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"JELLY_BEAN_MR1",
")",
"public",
"void",
"show",
"(",
")",
"{",
"ViewGroup",
"parent",
"=",
"(",
"ViewGroup",
")",
"getParent",
"(",
")",
";",
"if",
"(",
"parent",
"==",
"null",
"||",
"mState",
"==",
"STATE_SHOWING",
"||",
"mState",
"==",
"STATE_DISMISSING",
")",
"return",
";",
"if",
"(",
"parent",
"instanceof",
"android",
".",
"widget",
".",
"FrameLayout",
")",
"{",
"LayoutParams",
"params",
"=",
"(",
"LayoutParams",
")",
"getLayoutParams",
"(",
")",
";",
"params",
".",
"width",
"=",
"mWidth",
";",
"params",
".",
"height",
"=",
"mHeight",
";",
"params",
".",
"gravity",
"=",
"Gravity",
".",
"START",
"|",
"Gravity",
".",
"BOTTOM",
";",
"if",
"(",
"mIsRtl",
")",
"params",
".",
"rightMargin",
"=",
"mMarginStart",
";",
"else",
"params",
".",
"leftMargin",
"=",
"mMarginStart",
";",
"params",
".",
"bottomMargin",
"=",
"mMarginBottom",
";",
"setLayoutParams",
"(",
"params",
")",
";",
"}",
"else",
"if",
"(",
"parent",
"instanceof",
"android",
".",
"widget",
".",
"RelativeLayout",
")",
"{",
"android",
".",
"widget",
".",
"RelativeLayout",
".",
"LayoutParams",
"params",
"=",
"(",
"android",
".",
"widget",
".",
"RelativeLayout",
".",
"LayoutParams",
")",
"getLayoutParams",
"(",
")",
";",
"params",
".",
"width",
"=",
"mWidth",
";",
"params",
".",
"height",
"=",
"mHeight",
";",
"params",
".",
"addRule",
"(",
"android",
".",
"widget",
".",
"RelativeLayout",
".",
"ALIGN_PARENT_BOTTOM",
")",
";",
"params",
".",
"addRule",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"JELLY_BEAN_MR1",
"?",
"android",
".",
"widget",
".",
"RelativeLayout",
".",
"ALIGN_PARENT_START",
":",
"android",
".",
"widget",
".",
"RelativeLayout",
".",
"ALIGN_PARENT_LEFT",
")",
";",
"if",
"(",
"mIsRtl",
")",
"params",
".",
"rightMargin",
"=",
"mMarginStart",
";",
"else",
"params",
".",
"leftMargin",
"=",
"mMarginStart",
";",
"params",
".",
"bottomMargin",
"=",
"mMarginBottom",
";",
"setLayoutParams",
"(",
"params",
")",
";",
"}",
"if",
"(",
"mInAnimation",
"!=",
"null",
"&&",
"mState",
"!=",
"STATE_SHOWN",
")",
"{",
"mInAnimation",
".",
"cancel",
"(",
")",
";",
"mInAnimation",
".",
"reset",
"(",
")",
";",
"mInAnimation",
".",
"setAnimationListener",
"(",
"new",
"Animation",
".",
"AnimationListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onAnimationStart",
"(",
"Animation",
"animation",
")",
"{",
"setState",
"(",
"STATE_SHOWING",
")",
";",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onAnimationRepeat",
"(",
"Animation",
"animation",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"onAnimationEnd",
"(",
"Animation",
"animation",
")",
"{",
"setState",
"(",
"STATE_SHOWN",
")",
";",
"startTimer",
"(",
")",
";",
"}",
"}",
")",
";",
"clearAnimation",
"(",
")",
";",
"startAnimation",
"(",
"mInAnimation",
")",
";",
"}",
"else",
"{",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"setState",
"(",
"STATE_SHOWN",
")",
";",
"startTimer",
"(",
")",
";",
"}",
"}"
] | Show this SnackBar.
Make sure it already attached to a parent view or this method will do nothing. | [
"Show",
"this",
"SnackBar",
".",
"Make",
"sure",
"it",
"already",
"attached",
"to",
"a",
"parent",
"view",
"or",
"this",
"method",
"will",
"do",
"nothing",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/SnackBar.java#L781-L846 |
23,227 | rey5137/material | material/src/main/java/com/rey/material/app/ThemeManager.java | ThemeManager.getStyleId | public static int getStyleId(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ThemableView, defStyleAttr, defStyleRes);
int styleId = a.getResourceId(R.styleable.ThemableView_v_styleId, 0);
a.recycle();
return styleId;
} | java | public static int getStyleId(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ThemableView, defStyleAttr, defStyleRes);
int styleId = a.getResourceId(R.styleable.ThemableView_v_styleId, 0);
a.recycle();
return styleId;
} | [
"public",
"static",
"int",
"getStyleId",
"(",
"Context",
"context",
",",
"AttributeSet",
"attrs",
",",
"int",
"defStyleAttr",
",",
"int",
"defStyleRes",
")",
"{",
"TypedArray",
"a",
"=",
"context",
".",
"obtainStyledAttributes",
"(",
"attrs",
",",
"R",
".",
"styleable",
".",
"ThemableView",
",",
"defStyleAttr",
",",
"defStyleRes",
")",
";",
"int",
"styleId",
"=",
"a",
".",
"getResourceId",
"(",
"R",
".",
"styleable",
".",
"ThemableView_v_styleId",
",",
"0",
")",
";",
"a",
".",
"recycle",
"(",
")",
";",
"return",
"styleId",
";",
"}"
] | Get the styleId from attributes.
@param context
@param attrs
@param defStyleAttr
@param defStyleRes
@return The styleId. | [
"Get",
"the",
"styleId",
"from",
"attributes",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/ThemeManager.java#L45-L51 |
23,228 | rey5137/material | material/src/main/java/com/rey/material/app/ThemeManager.java | ThemeManager.getInstance | public static ThemeManager getInstance(){
if(mInstance == null){
synchronized (ThemeManager.class){
if(mInstance == null)
mInstance = new ThemeManager();
}
}
return mInstance;
} | java | public static ThemeManager getInstance(){
if(mInstance == null){
synchronized (ThemeManager.class){
if(mInstance == null)
mInstance = new ThemeManager();
}
}
return mInstance;
} | [
"public",
"static",
"ThemeManager",
"getInstance",
"(",
")",
"{",
"if",
"(",
"mInstance",
"==",
"null",
")",
"{",
"synchronized",
"(",
"ThemeManager",
".",
"class",
")",
"{",
"if",
"(",
"mInstance",
"==",
"null",
")",
"mInstance",
"=",
"new",
"ThemeManager",
"(",
")",
";",
"}",
"}",
"return",
"mInstance",
";",
"}"
] | Get the singleton instance of ThemeManager.
@return The singleton instance of ThemeManager. | [
"Get",
"the",
"singleton",
"instance",
"of",
"ThemeManager",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/ThemeManager.java#L68-L77 |
23,229 | rey5137/material | material/src/main/java/com/rey/material/app/ThemeManager.java | ThemeManager.getStyle | public int getStyle(int styleId, int theme){
int[] styles = getStyleList(styleId);
return styles == null ? 0 : styles[theme];
} | java | public int getStyle(int styleId, int theme){
int[] styles = getStyleList(styleId);
return styles == null ? 0 : styles[theme];
} | [
"public",
"int",
"getStyle",
"(",
"int",
"styleId",
",",
"int",
"theme",
")",
"{",
"int",
"[",
"]",
"styles",
"=",
"getStyleList",
"(",
"styleId",
")",
";",
"return",
"styles",
"==",
"null",
"?",
"0",
":",
"styles",
"[",
"theme",
"]",
";",
"}"
] | Get a specific style of a styleId.
@param styleId The styleId.
@param theme The theme.
@return The specific style. | [
"Get",
"a",
"specific",
"style",
"of",
"a",
"styleId",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/ThemeManager.java#L184-L187 |
23,230 | rey5137/material | material/src/main/java/com/rey/material/app/SimpleDialog.java | SimpleDialog.messageTextAppearance | public SimpleDialog messageTextAppearance(int resId){
if(mMessageTextAppearanceId != resId){
mMessageTextAppearanceId = resId;
if(mMessage != null)
mMessage.setTextAppearance(getContext(), mMessageTextAppearanceId);
}
return this;
} | java | public SimpleDialog messageTextAppearance(int resId){
if(mMessageTextAppearanceId != resId){
mMessageTextAppearanceId = resId;
if(mMessage != null)
mMessage.setTextAppearance(getContext(), mMessageTextAppearanceId);
}
return this;
} | [
"public",
"SimpleDialog",
"messageTextAppearance",
"(",
"int",
"resId",
")",
"{",
"if",
"(",
"mMessageTextAppearanceId",
"!=",
"resId",
")",
"{",
"mMessageTextAppearanceId",
"=",
"resId",
";",
"if",
"(",
"mMessage",
"!=",
"null",
")",
"mMessage",
".",
"setTextAppearance",
"(",
"getContext",
"(",
")",
",",
"mMessageTextAppearanceId",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the text color, size, style of the message view from the specified TextAppearance resource.
@param resId The resourceId value.
@return The SimpleDialog for chaining methods. | [
"Sets",
"the",
"text",
"color",
"size",
"style",
"of",
"the",
"message",
"view",
"from",
"the",
"specified",
"TextAppearance",
"resource",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/SimpleDialog.java#L205-L212 |
23,231 | rey5137/material | material/src/main/java/com/rey/material/app/SimpleDialog.java | SimpleDialog.messageTextColor | public SimpleDialog messageTextColor(int color){
if(mMessageTextColor != color){
mMessageTextColor = color;
if(mMessage != null)
mMessage.setTextColor(color);
}
return this;
} | java | public SimpleDialog messageTextColor(int color){
if(mMessageTextColor != color){
mMessageTextColor = color;
if(mMessage != null)
mMessage.setTextColor(color);
}
return this;
} | [
"public",
"SimpleDialog",
"messageTextColor",
"(",
"int",
"color",
")",
"{",
"if",
"(",
"mMessageTextColor",
"!=",
"color",
")",
"{",
"mMessageTextColor",
"=",
"color",
";",
"if",
"(",
"mMessage",
"!=",
"null",
")",
"mMessage",
".",
"setTextColor",
"(",
"color",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the text color of the message view.
@param color The color value.
@return The SimpleDialog for chaining methods. | [
"Sets",
"the",
"text",
"color",
"of",
"the",
"message",
"view",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/SimpleDialog.java#L219-L226 |
23,232 | rey5137/material | material/src/main/java/com/rey/material/app/SimpleDialog.java | SimpleDialog.radioButtonStyle | public SimpleDialog radioButtonStyle(int resId){
if(mRadioButtonStyle != resId){
mRadioButtonStyle = resId;
if(mAdapter != null && mMode == MODE_ITEMS)
mAdapter.notifyDataSetChanged();
}
return this;
} | java | public SimpleDialog radioButtonStyle(int resId){
if(mRadioButtonStyle != resId){
mRadioButtonStyle = resId;
if(mAdapter != null && mMode == MODE_ITEMS)
mAdapter.notifyDataSetChanged();
}
return this;
} | [
"public",
"SimpleDialog",
"radioButtonStyle",
"(",
"int",
"resId",
")",
"{",
"if",
"(",
"mRadioButtonStyle",
"!=",
"resId",
")",
"{",
"mRadioButtonStyle",
"=",
"resId",
";",
"if",
"(",
"mAdapter",
"!=",
"null",
"&&",
"mMode",
"==",
"MODE_ITEMS",
")",
"mAdapter",
".",
"notifyDataSetChanged",
"(",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the style of radio button.
@param resId The resourceId of style.
@return The SimpleDialog for chaining methods. | [
"Sets",
"the",
"style",
"of",
"radio",
"button",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/SimpleDialog.java#L233-L240 |
23,233 | rey5137/material | material/src/main/java/com/rey/material/app/SimpleDialog.java | SimpleDialog.checkBoxStyle | public SimpleDialog checkBoxStyle(int resId){
if(mCheckBoxStyle != resId){
mCheckBoxStyle = resId;
if(mAdapter != null && mMode == MODE_MULTI_ITEMS)
mAdapter.notifyDataSetChanged();
}
return this;
} | java | public SimpleDialog checkBoxStyle(int resId){
if(mCheckBoxStyle != resId){
mCheckBoxStyle = resId;
if(mAdapter != null && mMode == MODE_MULTI_ITEMS)
mAdapter.notifyDataSetChanged();
}
return this;
} | [
"public",
"SimpleDialog",
"checkBoxStyle",
"(",
"int",
"resId",
")",
"{",
"if",
"(",
"mCheckBoxStyle",
"!=",
"resId",
")",
"{",
"mCheckBoxStyle",
"=",
"resId",
";",
"if",
"(",
"mAdapter",
"!=",
"null",
"&&",
"mMode",
"==",
"MODE_MULTI_ITEMS",
")",
"mAdapter",
".",
"notifyDataSetChanged",
"(",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the style of check box.
@param resId The resourceId of style.
@return The SimpleDialog for chaining methods. | [
"Sets",
"the",
"style",
"of",
"check",
"box",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/SimpleDialog.java#L247-L254 |
23,234 | rey5137/material | material/src/main/java/com/rey/material/app/SimpleDialog.java | SimpleDialog.itemHeight | public SimpleDialog itemHeight(int height){
if(mItemHeight != height){
mItemHeight = height;
if(mAdapter != null)
mAdapter.notifyDataSetChanged();
}
return this;
} | java | public SimpleDialog itemHeight(int height){
if(mItemHeight != height){
mItemHeight = height;
if(mAdapter != null)
mAdapter.notifyDataSetChanged();
}
return this;
} | [
"public",
"SimpleDialog",
"itemHeight",
"(",
"int",
"height",
")",
"{",
"if",
"(",
"mItemHeight",
"!=",
"height",
")",
"{",
"mItemHeight",
"=",
"height",
";",
"if",
"(",
"mAdapter",
"!=",
"null",
")",
"mAdapter",
".",
"notifyDataSetChanged",
"(",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the height of item
@param height The size in pixels.
@return The SimpleDialog for chaining methods. | [
"Sets",
"the",
"height",
"of",
"item"
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/SimpleDialog.java#L261-L268 |
23,235 | rey5137/material | material/src/main/java/com/rey/material/app/SimpleDialog.java | SimpleDialog.itemTextAppearance | public SimpleDialog itemTextAppearance(int resId){
if(mItemTextAppearance != resId){
mItemTextAppearance = resId;
if(mAdapter != null)
mAdapter.notifyDataSetChanged();
}
return this;
} | java | public SimpleDialog itemTextAppearance(int resId){
if(mItemTextAppearance != resId){
mItemTextAppearance = resId;
if(mAdapter != null)
mAdapter.notifyDataSetChanged();
}
return this;
} | [
"public",
"SimpleDialog",
"itemTextAppearance",
"(",
"int",
"resId",
")",
"{",
"if",
"(",
"mItemTextAppearance",
"!=",
"resId",
")",
"{",
"mItemTextAppearance",
"=",
"resId",
";",
"if",
"(",
"mAdapter",
"!=",
"null",
")",
"mAdapter",
".",
"notifyDataSetChanged",
"(",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the text color, size, style of the item view from the specified TextAppearance resource.
@param resId The resourceId value.
@return The SimpleDialog for chaining methods. | [
"Sets",
"the",
"text",
"color",
"size",
"style",
"of",
"the",
"item",
"view",
"from",
"the",
"specified",
"TextAppearance",
"resource",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/SimpleDialog.java#L275-L282 |
23,236 | rey5137/material | material/src/main/java/com/rey/material/app/SimpleDialog.java | SimpleDialog.items | public SimpleDialog items(CharSequence[] items, int selectedIndex){
if(mListView == null)
initListView();
mMode = MODE_ITEMS;
mAdapter.setItems(items, selectedIndex);
super.contentView(mListView);
return this;
} | java | public SimpleDialog items(CharSequence[] items, int selectedIndex){
if(mListView == null)
initListView();
mMode = MODE_ITEMS;
mAdapter.setItems(items, selectedIndex);
super.contentView(mListView);
return this;
} | [
"public",
"SimpleDialog",
"items",
"(",
"CharSequence",
"[",
"]",
"items",
",",
"int",
"selectedIndex",
")",
"{",
"if",
"(",
"mListView",
"==",
"null",
")",
"initListView",
"(",
")",
";",
"mMode",
"=",
"MODE_ITEMS",
";",
"mAdapter",
".",
"setItems",
"(",
"items",
",",
"selectedIndex",
")",
";",
"super",
".",
"contentView",
"(",
"mListView",
")",
";",
"return",
"this",
";",
"}"
] | Set the list of items in single-choice mode.
@param items The list of items.
@param selectedIndex The index of selected item.
@return The SimpleDialog for chaining methods. | [
"Set",
"the",
"list",
"of",
"items",
"in",
"single",
"-",
"choice",
"mode",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/SimpleDialog.java#L306-L314 |
23,237 | rey5137/material | material/src/main/java/com/rey/material/app/SimpleDialog.java | SimpleDialog.multiChoiceItems | public SimpleDialog multiChoiceItems(CharSequence[] items, int... selectedIndexes){
if(mListView == null)
initListView();
mMode = MODE_MULTI_ITEMS;
mAdapter.setItems(items, selectedIndexes);
super.contentView(mListView);
return this;
} | java | public SimpleDialog multiChoiceItems(CharSequence[] items, int... selectedIndexes){
if(mListView == null)
initListView();
mMode = MODE_MULTI_ITEMS;
mAdapter.setItems(items, selectedIndexes);
super.contentView(mListView);
return this;
} | [
"public",
"SimpleDialog",
"multiChoiceItems",
"(",
"CharSequence",
"[",
"]",
"items",
",",
"int",
"...",
"selectedIndexes",
")",
"{",
"if",
"(",
"mListView",
"==",
"null",
")",
"initListView",
"(",
")",
";",
"mMode",
"=",
"MODE_MULTI_ITEMS",
";",
"mAdapter",
".",
"setItems",
"(",
"items",
",",
"selectedIndexes",
")",
";",
"super",
".",
"contentView",
"(",
"mListView",
")",
";",
"return",
"this",
";",
"}"
] | Set the list of items in multi-choice mode.
@param items The list of items.
@param selectedIndexes The indexes of selected items.
@return The SimpleDialog for chaining methods. | [
"Set",
"the",
"list",
"of",
"items",
"in",
"multi",
"-",
"choice",
"mode",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/app/SimpleDialog.java#L322-L330 |
23,238 | rey5137/material | material/src/main/java/com/rey/material/widget/ProgressView.java | ProgressView.setProgress | public void setProgress(float percent){
if(mCircular)
((CircularProgressDrawable)mProgressDrawable).setProgress(percent);
else
((LinearProgressDrawable)mProgressDrawable).setProgress(percent);
} | java | public void setProgress(float percent){
if(mCircular)
((CircularProgressDrawable)mProgressDrawable).setProgress(percent);
else
((LinearProgressDrawable)mProgressDrawable).setProgress(percent);
} | [
"public",
"void",
"setProgress",
"(",
"float",
"percent",
")",
"{",
"if",
"(",
"mCircular",
")",
"(",
"(",
"CircularProgressDrawable",
")",
"mProgressDrawable",
")",
".",
"setProgress",
"(",
"percent",
")",
";",
"else",
"(",
"(",
"LinearProgressDrawable",
")",
"mProgressDrawable",
")",
".",
"setProgress",
"(",
"percent",
")",
";",
"}"
] | Set the current progress of this view.
@param percent The progress value in [0..1] range. | [
"Set",
"the",
"current",
"progress",
"of",
"this",
"view",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/ProgressView.java#L212-L217 |
23,239 | rey5137/material | material/src/main/java/com/rey/material/widget/ProgressView.java | ProgressView.setSecondaryProgress | public void setSecondaryProgress(float percent){
if(mCircular)
((CircularProgressDrawable)mProgressDrawable).setSecondaryProgress(percent);
else
((LinearProgressDrawable)mProgressDrawable).setSecondaryProgress(percent);
} | java | public void setSecondaryProgress(float percent){
if(mCircular)
((CircularProgressDrawable)mProgressDrawable).setSecondaryProgress(percent);
else
((LinearProgressDrawable)mProgressDrawable).setSecondaryProgress(percent);
} | [
"public",
"void",
"setSecondaryProgress",
"(",
"float",
"percent",
")",
"{",
"if",
"(",
"mCircular",
")",
"(",
"(",
"CircularProgressDrawable",
")",
"mProgressDrawable",
")",
".",
"setSecondaryProgress",
"(",
"percent",
")",
";",
"else",
"(",
"(",
"LinearProgressDrawable",
")",
"mProgressDrawable",
")",
".",
"setSecondaryProgress",
"(",
"percent",
")",
";",
"}"
] | Set the current secondary progress of this view.
@param percent The progress value in [0..1] range. | [
"Set",
"the",
"current",
"secondary",
"progress",
"of",
"this",
"view",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/ProgressView.java#L223-L228 |
23,240 | rey5137/material | material/src/main/java/com/rey/material/widget/Spinner.java | Spinner.setSelection | public void setSelection(int position) {
if(mAdapter != null)
position = Math.max(0, Math.min(position, mAdapter.getCount() - 1));
if(mSelectedPosition != position){
mSelectedPosition = position;
if(mOnItemSelectedListener != null)
mOnItemSelectedListener.onItemSelected(this, getSelectedView(), position, mAdapter == null ? -1 : mAdapter.getItemId(position));
onDataInvalidated();
}
} | java | public void setSelection(int position) {
if(mAdapter != null)
position = Math.max(0, Math.min(position, mAdapter.getCount() - 1));
if(mSelectedPosition != position){
mSelectedPosition = position;
if(mOnItemSelectedListener != null)
mOnItemSelectedListener.onItemSelected(this, getSelectedView(), position, mAdapter == null ? -1 : mAdapter.getItemId(position));
onDataInvalidated();
}
} | [
"public",
"void",
"setSelection",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"mAdapter",
"!=",
"null",
")",
"position",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"Math",
".",
"min",
"(",
"position",
",",
"mAdapter",
".",
"getCount",
"(",
")",
"-",
"1",
")",
")",
";",
"if",
"(",
"mSelectedPosition",
"!=",
"position",
")",
"{",
"mSelectedPosition",
"=",
"position",
";",
"if",
"(",
"mOnItemSelectedListener",
"!=",
"null",
")",
"mOnItemSelectedListener",
".",
"onItemSelected",
"(",
"this",
",",
"getSelectedView",
"(",
")",
",",
"position",
",",
"mAdapter",
"==",
"null",
"?",
"-",
"1",
":",
"mAdapter",
".",
"getItemId",
"(",
"position",
")",
")",
";",
"onDataInvalidated",
"(",
")",
";",
"}",
"}"
] | Set the selected position of this Spinner.
@param position The selected position. | [
"Set",
"the",
"selected",
"position",
"of",
"this",
"Spinner",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/Spinner.java#L377-L389 |
23,241 | rey5137/material | material/src/main/java/com/rey/material/widget/Spinner.java | Spinner.setAdapter | public void setAdapter(SpinnerAdapter adapter) {
if(mAdapter != null)
mAdapter.unregisterDataSetObserver(mDataSetObserver);
mRecycler.clear();
mAdapter = adapter;
mAdapter.registerDataSetObserver(mDataSetObserver);
onDataChanged();
if (mPopup != null)
mPopup.setAdapter(new DropDownAdapter(adapter));
else
mTempAdapter = new DropDownAdapter(adapter);
} | java | public void setAdapter(SpinnerAdapter adapter) {
if(mAdapter != null)
mAdapter.unregisterDataSetObserver(mDataSetObserver);
mRecycler.clear();
mAdapter = adapter;
mAdapter.registerDataSetObserver(mDataSetObserver);
onDataChanged();
if (mPopup != null)
mPopup.setAdapter(new DropDownAdapter(adapter));
else
mTempAdapter = new DropDownAdapter(adapter);
} | [
"public",
"void",
"setAdapter",
"(",
"SpinnerAdapter",
"adapter",
")",
"{",
"if",
"(",
"mAdapter",
"!=",
"null",
")",
"mAdapter",
".",
"unregisterDataSetObserver",
"(",
"mDataSetObserver",
")",
";",
"mRecycler",
".",
"clear",
"(",
")",
";",
"mAdapter",
"=",
"adapter",
";",
"mAdapter",
".",
"registerDataSetObserver",
"(",
"mDataSetObserver",
")",
";",
"onDataChanged",
"(",
")",
";",
"if",
"(",
"mPopup",
"!=",
"null",
")",
"mPopup",
".",
"setAdapter",
"(",
"new",
"DropDownAdapter",
"(",
"adapter",
")",
")",
";",
"else",
"mTempAdapter",
"=",
"new",
"DropDownAdapter",
"(",
"adapter",
")",
";",
"}"
] | Set an adapter for this Spinner.
@param adapter | [
"Set",
"an",
"adapter",
"for",
"this",
"Spinner",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/Spinner.java#L416-L430 |
23,242 | rey5137/material | material/src/main/java/com/rey/material/widget/ListPopupWindow.java | ListPopupWindow.dismiss | public void dismiss() {
mPopup.dismiss();
removePromptView();
mPopup.setContentView(null);
mDropDownList = null;
mHandler.removeCallbacks(mResizePopupRunnable);
} | java | public void dismiss() {
mPopup.dismiss();
removePromptView();
mPopup.setContentView(null);
mDropDownList = null;
mHandler.removeCallbacks(mResizePopupRunnable);
} | [
"public",
"void",
"dismiss",
"(",
")",
"{",
"mPopup",
".",
"dismiss",
"(",
")",
";",
"removePromptView",
"(",
")",
";",
"mPopup",
".",
"setContentView",
"(",
"null",
")",
";",
"mDropDownList",
"=",
"null",
";",
"mHandler",
".",
"removeCallbacks",
"(",
"mResizePopupRunnable",
")",
";",
"}"
] | Dismiss the popup window. | [
"Dismiss",
"the",
"popup",
"window",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/ListPopupWindow.java#L690-L696 |
23,243 | rey5137/material | material/src/main/java/com/rey/material/widget/ListPopupWindow.java | ListPopupWindow.performItemClick | public boolean performItemClick(int position) {
if (isShowing()) {
if (mItemClickListener != null) {
final DropDownListView list = mDropDownList;
final View child = list.getChildAt(position - list.getFirstVisiblePosition());
final ListAdapter adapter = list.getAdapter();
mItemClickListener.onItemClick(list, child, position, adapter.getItemId(position));
}
return true;
}
return false;
} | java | public boolean performItemClick(int position) {
if (isShowing()) {
if (mItemClickListener != null) {
final DropDownListView list = mDropDownList;
final View child = list.getChildAt(position - list.getFirstVisiblePosition());
final ListAdapter adapter = list.getAdapter();
mItemClickListener.onItemClick(list, child, position, adapter.getItemId(position));
}
return true;
}
return false;
} | [
"public",
"boolean",
"performItemClick",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"isShowing",
"(",
")",
")",
"{",
"if",
"(",
"mItemClickListener",
"!=",
"null",
")",
"{",
"final",
"DropDownListView",
"list",
"=",
"mDropDownList",
";",
"final",
"View",
"child",
"=",
"list",
".",
"getChildAt",
"(",
"position",
"-",
"list",
".",
"getFirstVisiblePosition",
"(",
")",
")",
";",
"final",
"ListAdapter",
"adapter",
"=",
"list",
".",
"getAdapter",
"(",
")",
";",
"mItemClickListener",
".",
"onItemClick",
"(",
"list",
",",
"child",
",",
"position",
",",
"adapter",
".",
"getItemId",
"(",
"position",
")",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Perform an item click operation on the specified list adapter position.
@param position Adapter position for performing the click
@return true if the click action could be performed, false if not.
(e.g. if the popup was not showing, this method would return false.) | [
"Perform",
"an",
"item",
"click",
"operation",
"on",
"the",
"specified",
"list",
"adapter",
"position",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/ListPopupWindow.java#L798-L809 |
23,244 | rey5137/material | material/src/main/java/com/rey/material/widget/ListPopupWindow.java | ListPopupWindow.onKeyUp | public boolean onKeyUp(int keyCode, KeyEvent event) {
if (isShowing() && mDropDownList.getSelectedItemPosition() >= 0) {
boolean consumed = mDropDownList.onKeyUp(keyCode, event);
if (consumed && isConfirmKey(keyCode)) {
// if the list accepts the key events and the key event was a click, the text view
// gets the selected item from the drop down as its content
dismiss();
}
return consumed;
}
return false;
} | java | public boolean onKeyUp(int keyCode, KeyEvent event) {
if (isShowing() && mDropDownList.getSelectedItemPosition() >= 0) {
boolean consumed = mDropDownList.onKeyUp(keyCode, event);
if (consumed && isConfirmKey(keyCode)) {
// if the list accepts the key events and the key event was a click, the text view
// gets the selected item from the drop down as its content
dismiss();
}
return consumed;
}
return false;
} | [
"public",
"boolean",
"onKeyUp",
"(",
"int",
"keyCode",
",",
"KeyEvent",
"event",
")",
"{",
"if",
"(",
"isShowing",
"(",
")",
"&&",
"mDropDownList",
".",
"getSelectedItemPosition",
"(",
")",
">=",
"0",
")",
"{",
"boolean",
"consumed",
"=",
"mDropDownList",
".",
"onKeyUp",
"(",
"keyCode",
",",
"event",
")",
";",
"if",
"(",
"consumed",
"&&",
"isConfirmKey",
"(",
"keyCode",
")",
")",
"{",
"// if the list accepts the key events and the key event was a click, the text view",
"// gets the selected item from the drop down as its content",
"dismiss",
"(",
")",
";",
"}",
"return",
"consumed",
";",
"}",
"return",
"false",
";",
"}"
] | Filter key down events. By forwarding key up events to this function,
views using non-modal ListPopupWindow can have it handle key selection of items.
@param keyCode keyCode param passed to the host view's onKeyUp
@param event event param passed to the host view's onKeyUp
@return true if the event was handled, false if it was ignored.
@see #setModal(boolean) | [
"Filter",
"key",
"down",
"events",
".",
"By",
"forwarding",
"key",
"up",
"events",
"to",
"this",
"function",
"views",
"using",
"non",
"-",
"modal",
"ListPopupWindow",
"can",
"have",
"it",
"handle",
"key",
"selection",
"of",
"items",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/ListPopupWindow.java#L987-L998 |
23,245 | rey5137/material | material/src/main/java/com/rey/material/util/ViewUtil.java | ViewUtil.applyStyle | private static void applyStyle(AutoCompleteTextView v, AttributeSet attrs, int defStyleAttr, int defStyleRes){
TypedArray a = v.getContext().obtainStyledAttributes(attrs, R.styleable.AutoCompleteTextView, defStyleAttr, defStyleRes);
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
if(attr == R.styleable.AutoCompleteTextView_android_completionHint)
v.setCompletionHint(a.getString(attr));
else if(attr == R.styleable.AutoCompleteTextView_android_completionThreshold)
v.setThreshold(a.getInteger(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownAnchor)
v.setDropDownAnchor(a.getResourceId(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHeight)
v.setDropDownHeight(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownWidth)
v.setDropDownWidth(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHorizontalOffset)
v.setDropDownHorizontalOffset(a.getDimensionPixelSize(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownVerticalOffset)
v.setDropDownVerticalOffset(a.getDimensionPixelSize(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_popupBackground)
v.setDropDownBackgroundDrawable(a.getDrawable(attr));
}
a.recycle();
} | java | private static void applyStyle(AutoCompleteTextView v, AttributeSet attrs, int defStyleAttr, int defStyleRes){
TypedArray a = v.getContext().obtainStyledAttributes(attrs, R.styleable.AutoCompleteTextView, defStyleAttr, defStyleRes);
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
if(attr == R.styleable.AutoCompleteTextView_android_completionHint)
v.setCompletionHint(a.getString(attr));
else if(attr == R.styleable.AutoCompleteTextView_android_completionThreshold)
v.setThreshold(a.getInteger(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownAnchor)
v.setDropDownAnchor(a.getResourceId(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHeight)
v.setDropDownHeight(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownWidth)
v.setDropDownWidth(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHorizontalOffset)
v.setDropDownHorizontalOffset(a.getDimensionPixelSize(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_dropDownVerticalOffset)
v.setDropDownVerticalOffset(a.getDimensionPixelSize(attr, 0));
else if(attr == R.styleable.AutoCompleteTextView_android_popupBackground)
v.setDropDownBackgroundDrawable(a.getDrawable(attr));
}
a.recycle();
} | [
"private",
"static",
"void",
"applyStyle",
"(",
"AutoCompleteTextView",
"v",
",",
"AttributeSet",
"attrs",
",",
"int",
"defStyleAttr",
",",
"int",
"defStyleRes",
")",
"{",
"TypedArray",
"a",
"=",
"v",
".",
"getContext",
"(",
")",
".",
"obtainStyledAttributes",
"(",
"attrs",
",",
"R",
".",
"styleable",
".",
"AutoCompleteTextView",
",",
"defStyleAttr",
",",
"defStyleRes",
")",
";",
"int",
"n",
"=",
"a",
".",
"getIndexCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"int",
"attr",
"=",
"a",
".",
"getIndex",
"(",
"i",
")",
";",
"if",
"(",
"attr",
"==",
"R",
".",
"styleable",
".",
"AutoCompleteTextView_android_completionHint",
")",
"v",
".",
"setCompletionHint",
"(",
"a",
".",
"getString",
"(",
"attr",
")",
")",
";",
"else",
"if",
"(",
"attr",
"==",
"R",
".",
"styleable",
".",
"AutoCompleteTextView_android_completionThreshold",
")",
"v",
".",
"setThreshold",
"(",
"a",
".",
"getInteger",
"(",
"attr",
",",
"0",
")",
")",
";",
"else",
"if",
"(",
"attr",
"==",
"R",
".",
"styleable",
".",
"AutoCompleteTextView_android_dropDownAnchor",
")",
"v",
".",
"setDropDownAnchor",
"(",
"a",
".",
"getResourceId",
"(",
"attr",
",",
"0",
")",
")",
";",
"else",
"if",
"(",
"attr",
"==",
"R",
".",
"styleable",
".",
"AutoCompleteTextView_android_dropDownHeight",
")",
"v",
".",
"setDropDownHeight",
"(",
"a",
".",
"getLayoutDimension",
"(",
"attr",
",",
"ViewGroup",
".",
"LayoutParams",
".",
"WRAP_CONTENT",
")",
")",
";",
"else",
"if",
"(",
"attr",
"==",
"R",
".",
"styleable",
".",
"AutoCompleteTextView_android_dropDownWidth",
")",
"v",
".",
"setDropDownWidth",
"(",
"a",
".",
"getLayoutDimension",
"(",
"attr",
",",
"ViewGroup",
".",
"LayoutParams",
".",
"WRAP_CONTENT",
")",
")",
";",
"else",
"if",
"(",
"attr",
"==",
"R",
".",
"styleable",
".",
"AutoCompleteTextView_android_dropDownHorizontalOffset",
")",
"v",
".",
"setDropDownHorizontalOffset",
"(",
"a",
".",
"getDimensionPixelSize",
"(",
"attr",
",",
"0",
")",
")",
";",
"else",
"if",
"(",
"attr",
"==",
"R",
".",
"styleable",
".",
"AutoCompleteTextView_android_dropDownVerticalOffset",
")",
"v",
".",
"setDropDownVerticalOffset",
"(",
"a",
".",
"getDimensionPixelSize",
"(",
"attr",
",",
"0",
")",
")",
";",
"else",
"if",
"(",
"attr",
"==",
"R",
".",
"styleable",
".",
"AutoCompleteTextView_android_popupBackground",
")",
"v",
".",
"setDropDownBackgroundDrawable",
"(",
"a",
".",
"getDrawable",
"(",
"attr",
")",
")",
";",
"}",
"a",
".",
"recycle",
"(",
")",
";",
"}"
] | Apply any AutoCompleteTextView style attributes to a view.
@param v
@param attrs
@param defStyleAttr
@param defStyleRes | [
"Apply",
"any",
"AutoCompleteTextView",
"style",
"attributes",
"to",
"a",
"view",
"."
] | 1bbcac2686a0023ef7720d3fe455bb116d115af8 | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/util/ViewUtil.java#L747-L772 |
23,246 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/LinkedBuffer.java | LinkedBuffer.allocate | public static LinkedBuffer allocate(int size, LinkedBuffer previous)
{
if (size < MIN_BUFFER_SIZE)
throw new IllegalArgumentException(MIN_BUFFER_SIZE + " is the minimum buffer size.");
return new LinkedBuffer(size, previous);
} | java | public static LinkedBuffer allocate(int size, LinkedBuffer previous)
{
if (size < MIN_BUFFER_SIZE)
throw new IllegalArgumentException(MIN_BUFFER_SIZE + " is the minimum buffer size.");
return new LinkedBuffer(size, previous);
} | [
"public",
"static",
"LinkedBuffer",
"allocate",
"(",
"int",
"size",
",",
"LinkedBuffer",
"previous",
")",
"{",
"if",
"(",
"size",
"<",
"MIN_BUFFER_SIZE",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"MIN_BUFFER_SIZE",
"+",
"\" is the minimum buffer size.\"",
")",
";",
"return",
"new",
"LinkedBuffer",
"(",
"size",
",",
"previous",
")",
";",
"}"
] | Allocates a new buffer with the specified size and appends it to the previous buffer. | [
"Allocates",
"a",
"new",
"buffer",
"with",
"the",
"specified",
"size",
"and",
"appends",
"it",
"to",
"the",
"previous",
"buffer",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/LinkedBuffer.java#L62-L68 |
23,247 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/LinkedBuffer.java | LinkedBuffer.wrap | public static LinkedBuffer wrap(byte[] array, int offset, int length)
{
return new LinkedBuffer(array, offset, offset + length);
} | java | public static LinkedBuffer wrap(byte[] array, int offset, int length)
{
return new LinkedBuffer(array, offset, offset + length);
} | [
"public",
"static",
"LinkedBuffer",
"wrap",
"(",
"byte",
"[",
"]",
"array",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"return",
"new",
"LinkedBuffer",
"(",
"array",
",",
"offset",
",",
"offset",
"+",
"length",
")",
";",
"}"
] | Wraps the byte array buffer as a read-only buffer. | [
"Wraps",
"the",
"byte",
"array",
"buffer",
"as",
"a",
"read",
"-",
"only",
"buffer",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/LinkedBuffer.java#L73-L76 |
23,248 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/LinkedBuffer.java | LinkedBuffer.use | public static LinkedBuffer use(byte[] buffer, int start)
{
assert start >= 0;
if (buffer.length - start < MIN_BUFFER_SIZE)
throw new IllegalArgumentException(MIN_BUFFER_SIZE + " is the minimum buffer size.");
return new LinkedBuffer(buffer, start, start);
} | java | public static LinkedBuffer use(byte[] buffer, int start)
{
assert start >= 0;
if (buffer.length - start < MIN_BUFFER_SIZE)
throw new IllegalArgumentException(MIN_BUFFER_SIZE + " is the minimum buffer size.");
return new LinkedBuffer(buffer, start, start);
} | [
"public",
"static",
"LinkedBuffer",
"use",
"(",
"byte",
"[",
"]",
"buffer",
",",
"int",
"start",
")",
"{",
"assert",
"start",
">=",
"0",
";",
"if",
"(",
"buffer",
".",
"length",
"-",
"start",
"<",
"MIN_BUFFER_SIZE",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"MIN_BUFFER_SIZE",
"+",
"\" is the minimum buffer size.\"",
")",
";",
"return",
"new",
"LinkedBuffer",
"(",
"buffer",
",",
"start",
",",
"start",
")",
";",
"}"
] | Uses the existing byte array as the internal buffer. | [
"Uses",
"the",
"existing",
"byte",
"array",
"as",
"the",
"internal",
"buffer",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/LinkedBuffer.java#L89-L96 |
23,249 | protostuff/protostuff | protostuff-compiler/src/main/java/io/protostuff/compiler/PluginProtoCompiler.java | PluginProtoCompiler.getTemplateFrom | public static StringTemplate getTemplateFrom(StringTemplateGroup group,
String template)
{
try
{
return group.lookupTemplate(template);
}
catch (IllegalArgumentException e)
{
return null;
}
} | java | public static StringTemplate getTemplateFrom(StringTemplateGroup group,
String template)
{
try
{
return group.lookupTemplate(template);
}
catch (IllegalArgumentException e)
{
return null;
}
} | [
"public",
"static",
"StringTemplate",
"getTemplateFrom",
"(",
"StringTemplateGroup",
"group",
",",
"String",
"template",
")",
"{",
"try",
"{",
"return",
"group",
".",
"lookupTemplate",
"(",
"template",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Returns null if template is not found. | [
"Returns",
"null",
"if",
"template",
"is",
"not",
"found",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-compiler/src/main/java/io/protostuff/compiler/PluginProtoCompiler.java#L107-L118 |
23,250 | protostuff/protostuff | protostuff-parser/src/main/java/io/protostuff/parser/DefaultProtoLoader.java | DefaultProtoLoader.loadFromClasspath | public static Proto loadFromClasspath(String path, Proto importer) throws Exception
{
URL resource = getResource(path, DefaultProtoLoader.class);
if (resource == null)
return null;
Proto proto = new Proto(resource, DEFAULT_INSTANCE, importer);
ProtoUtil.loadFrom(resource, proto);
return proto;
} | java | public static Proto loadFromClasspath(String path, Proto importer) throws Exception
{
URL resource = getResource(path, DefaultProtoLoader.class);
if (resource == null)
return null;
Proto proto = new Proto(resource, DEFAULT_INSTANCE, importer);
ProtoUtil.loadFrom(resource, proto);
return proto;
} | [
"public",
"static",
"Proto",
"loadFromClasspath",
"(",
"String",
"path",
",",
"Proto",
"importer",
")",
"throws",
"Exception",
"{",
"URL",
"resource",
"=",
"getResource",
"(",
"path",
",",
"DefaultProtoLoader",
".",
"class",
")",
";",
"if",
"(",
"resource",
"==",
"null",
")",
"return",
"null",
";",
"Proto",
"proto",
"=",
"new",
"Proto",
"(",
"resource",
",",
"DEFAULT_INSTANCE",
",",
"importer",
")",
";",
"ProtoUtil",
".",
"loadFrom",
"(",
"resource",
",",
"proto",
")",
";",
"return",
"proto",
";",
"}"
] | Loads a proto from the classpath. | [
"Loads",
"a",
"proto",
"from",
"the",
"classpath",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-parser/src/main/java/io/protostuff/parser/DefaultProtoLoader.java#L274-L283 |
23,251 | protostuff/protostuff | protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java | DefaultIdStrategy.registerPojo | public <T> boolean registerPojo(Class<T> typeClass)
{
assert typeClass != null;
final HasSchema<?> last = pojoMapping.putIfAbsent(typeClass.getName(),
new LazyRegister<T>(typeClass, this));
return last == null || (last instanceof LazyRegister);
} | java | public <T> boolean registerPojo(Class<T> typeClass)
{
assert typeClass != null;
final HasSchema<?> last = pojoMapping.putIfAbsent(typeClass.getName(),
new LazyRegister<T>(typeClass, this));
return last == null || (last instanceof LazyRegister);
} | [
"public",
"<",
"T",
">",
"boolean",
"registerPojo",
"(",
"Class",
"<",
"T",
">",
"typeClass",
")",
"{",
"assert",
"typeClass",
"!=",
"null",
";",
"final",
"HasSchema",
"<",
"?",
">",
"last",
"=",
"pojoMapping",
".",
"putIfAbsent",
"(",
"typeClass",
".",
"getName",
"(",
")",
",",
"new",
"LazyRegister",
"<",
"T",
">",
"(",
"typeClass",
",",
"this",
")",
")",
";",
"return",
"last",
"==",
"null",
"||",
"(",
"last",
"instanceof",
"LazyRegister",
")",
";",
"}"
] | Registers a pojo. Returns true if registration is successful or if the same exact schema was previously
registered. | [
"Registers",
"a",
"pojo",
".",
"Returns",
"true",
"if",
"registration",
"is",
"successful",
"or",
"if",
"the",
"same",
"exact",
"schema",
"was",
"previously",
"registered",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java#L80-L88 |
23,252 | protostuff/protostuff | protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java | DefaultIdStrategy.registerEnum | public <T extends Enum<T>> boolean registerEnum(Class<T> enumClass)
{
return null == enumMapping.putIfAbsent(enumClass.getName(),
EnumIO.newEnumIO(enumClass, this));
} | java | public <T extends Enum<T>> boolean registerEnum(Class<T> enumClass)
{
return null == enumMapping.putIfAbsent(enumClass.getName(),
EnumIO.newEnumIO(enumClass, this));
} | [
"public",
"<",
"T",
"extends",
"Enum",
"<",
"T",
">",
">",
"boolean",
"registerEnum",
"(",
"Class",
"<",
"T",
">",
"enumClass",
")",
"{",
"return",
"null",
"==",
"enumMapping",
".",
"putIfAbsent",
"(",
"enumClass",
".",
"getName",
"(",
")",
",",
"EnumIO",
".",
"newEnumIO",
"(",
"enumClass",
",",
"this",
")",
")",
";",
"}"
] | Registers an enum. Returns true if registration is successful. | [
"Registers",
"an",
"enum",
".",
"Returns",
"true",
"if",
"registration",
"is",
"successful",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java#L93-L97 |
23,253 | protostuff/protostuff | protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java | DefaultIdStrategy.registerDelegate | public <T> boolean registerDelegate(String className, Delegate<T> delegate)
{
return null == delegateMapping.putIfAbsent(className, new HasDelegate<T>(delegate, this));
} | java | public <T> boolean registerDelegate(String className, Delegate<T> delegate)
{
return null == delegateMapping.putIfAbsent(className, new HasDelegate<T>(delegate, this));
} | [
"public",
"<",
"T",
">",
"boolean",
"registerDelegate",
"(",
"String",
"className",
",",
"Delegate",
"<",
"T",
">",
"delegate",
")",
"{",
"return",
"null",
"==",
"delegateMapping",
".",
"putIfAbsent",
"(",
"className",
",",
"new",
"HasDelegate",
"<",
"T",
">",
"(",
"delegate",
",",
"this",
")",
")",
";",
"}"
] | Registers a delegate by specifying the class name. Returns true if registration is successful. | [
"Registers",
"a",
"delegate",
"by",
"specifying",
"the",
"class",
"name",
".",
"Returns",
"true",
"if",
"registration",
"is",
"successful",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java#L110-L113 |
23,254 | protostuff/protostuff | protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java | DefaultIdStrategy.registerCollection | public boolean registerCollection(CollectionSchema.MessageFactory factory)
{
return null == collectionMapping.putIfAbsent(factory.typeClass()
.getName(), factory);
} | java | public boolean registerCollection(CollectionSchema.MessageFactory factory)
{
return null == collectionMapping.putIfAbsent(factory.typeClass()
.getName(), factory);
} | [
"public",
"boolean",
"registerCollection",
"(",
"CollectionSchema",
".",
"MessageFactory",
"factory",
")",
"{",
"return",
"null",
"==",
"collectionMapping",
".",
"putIfAbsent",
"(",
"factory",
".",
"typeClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"factory",
")",
";",
"}"
] | Registers a collection. Returns true if registration is successful. | [
"Registers",
"a",
"collection",
".",
"Returns",
"true",
"if",
"registration",
"is",
"successful",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java#L118-L122 |
23,255 | protostuff/protostuff | protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java | DefaultIdStrategy.registerMap | public boolean registerMap(MapSchema.MessageFactory factory)
{
return null == mapMapping.putIfAbsent(factory.typeClass().getName(),
factory);
} | java | public boolean registerMap(MapSchema.MessageFactory factory)
{
return null == mapMapping.putIfAbsent(factory.typeClass().getName(),
factory);
} | [
"public",
"boolean",
"registerMap",
"(",
"MapSchema",
".",
"MessageFactory",
"factory",
")",
"{",
"return",
"null",
"==",
"mapMapping",
".",
"putIfAbsent",
"(",
"factory",
".",
"typeClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"factory",
")",
";",
"}"
] | Registers a map. Returns true if registration is successful. | [
"Registers",
"a",
"map",
".",
"Returns",
"true",
"if",
"registration",
"is",
"successful",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-runtime/src/main/java/io/protostuff/runtime/DefaultIdStrategy.java#L127-L131 |
23,256 | protostuff/protostuff | protostuff-msgpack/src/main/java/io/protostuff/MsgpackIOUtil.java | MsgpackIOUtil.newPipe | public static Pipe newPipe(byte[] data, int offset, int length, boolean numeric) throws IOException
{
ArrayBufferInput in = new ArrayBufferInput(data, offset, length);
return newPipe(in, numeric);
} | java | public static Pipe newPipe(byte[] data, int offset, int length, boolean numeric) throws IOException
{
ArrayBufferInput in = new ArrayBufferInput(data, offset, length);
return newPipe(in, numeric);
} | [
"public",
"static",
"Pipe",
"newPipe",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"length",
",",
"boolean",
"numeric",
")",
"throws",
"IOException",
"{",
"ArrayBufferInput",
"in",
"=",
"new",
"ArrayBufferInput",
"(",
"data",
",",
"offset",
",",
"length",
")",
";",
"return",
"newPipe",
"(",
"in",
",",
"numeric",
")",
";",
"}"
] | Creates a msgpack pipe from a byte array. | [
"Creates",
"a",
"msgpack",
"pipe",
"from",
"a",
"byte",
"array",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-msgpack/src/main/java/io/protostuff/MsgpackIOUtil.java#L56-L60 |
23,257 | protostuff/protostuff | protostuff-core/src/main/java/io/protostuff/ByteArrayInput.java | ByteArrayInput.readRawVarint32 | public int readRawVarint32() throws IOException
{
byte tmp = buffer[offset++];
if (tmp >= 0)
{
return tmp;
}
int result = tmp & 0x7f;
if ((tmp = buffer[offset++]) >= 0)
{
result |= tmp << 7;
}
else
{
result |= (tmp & 0x7f) << 7;
if ((tmp = buffer[offset++]) >= 0)
{
result |= tmp << 14;
}
else
{
result |= (tmp & 0x7f) << 14;
if ((tmp = buffer[offset++]) >= 0)
{
result |= tmp << 21;
}
else
{
result |= (tmp & 0x7f) << 21;
result |= (tmp = buffer[offset++]) << 28;
if (tmp < 0)
{
// Discard upper 32 bits.
for (int i = 0; i < 5; i++)
{
if (buffer[offset++] >= 0)
{
return result;
}
}
throw ProtobufException.malformedVarint();
}
}
}
}
return result;
} | java | public int readRawVarint32() throws IOException
{
byte tmp = buffer[offset++];
if (tmp >= 0)
{
return tmp;
}
int result = tmp & 0x7f;
if ((tmp = buffer[offset++]) >= 0)
{
result |= tmp << 7;
}
else
{
result |= (tmp & 0x7f) << 7;
if ((tmp = buffer[offset++]) >= 0)
{
result |= tmp << 14;
}
else
{
result |= (tmp & 0x7f) << 14;
if ((tmp = buffer[offset++]) >= 0)
{
result |= tmp << 21;
}
else
{
result |= (tmp & 0x7f) << 21;
result |= (tmp = buffer[offset++]) << 28;
if (tmp < 0)
{
// Discard upper 32 bits.
for (int i = 0; i < 5; i++)
{
if (buffer[offset++] >= 0)
{
return result;
}
}
throw ProtobufException.malformedVarint();
}
}
}
}
return result;
} | [
"public",
"int",
"readRawVarint32",
"(",
")",
"throws",
"IOException",
"{",
"byte",
"tmp",
"=",
"buffer",
"[",
"offset",
"++",
"]",
";",
"if",
"(",
"tmp",
">=",
"0",
")",
"{",
"return",
"tmp",
";",
"}",
"int",
"result",
"=",
"tmp",
"&",
"0x7f",
";",
"if",
"(",
"(",
"tmp",
"=",
"buffer",
"[",
"offset",
"++",
"]",
")",
">=",
"0",
")",
"{",
"result",
"|=",
"tmp",
"<<",
"7",
";",
"}",
"else",
"{",
"result",
"|=",
"(",
"tmp",
"&",
"0x7f",
")",
"<<",
"7",
";",
"if",
"(",
"(",
"tmp",
"=",
"buffer",
"[",
"offset",
"++",
"]",
")",
">=",
"0",
")",
"{",
"result",
"|=",
"tmp",
"<<",
"14",
";",
"}",
"else",
"{",
"result",
"|=",
"(",
"tmp",
"&",
"0x7f",
")",
"<<",
"14",
";",
"if",
"(",
"(",
"tmp",
"=",
"buffer",
"[",
"offset",
"++",
"]",
")",
">=",
"0",
")",
"{",
"result",
"|=",
"tmp",
"<<",
"21",
";",
"}",
"else",
"{",
"result",
"|=",
"(",
"tmp",
"&",
"0x7f",
")",
"<<",
"21",
";",
"result",
"|=",
"(",
"tmp",
"=",
"buffer",
"[",
"offset",
"++",
"]",
")",
"<<",
"28",
";",
"if",
"(",
"tmp",
"<",
"0",
")",
"{",
"// Discard upper 32 bits.\r",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"5",
";",
"i",
"++",
")",
"{",
"if",
"(",
"buffer",
"[",
"offset",
"++",
"]",
">=",
"0",
")",
"{",
"return",
"result",
";",
"}",
"}",
"throw",
"ProtobufException",
".",
"malformedVarint",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Reads a var int 32 from the internal byte buffer. | [
"Reads",
"a",
"var",
"int",
"32",
"from",
"the",
"internal",
"byte",
"buffer",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/ByteArrayInput.java#L529-L575 |
23,258 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/IntSerializer.java | IntSerializer.writeInt16LE | public static void writeInt16LE(final int value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) value;
buffer[offset] = (byte) ((value >>> 8) & 0xFF);
} | java | public static void writeInt16LE(final int value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) value;
buffer[offset] = (byte) ((value >>> 8) & 0xFF);
} | [
"public",
"static",
"void",
"writeInt16LE",
"(",
"final",
"int",
"value",
",",
"final",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
")",
"{",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"value",
";",
"buffer",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"8",
")",
"&",
"0xFF",
")",
";",
"}"
] | Writes the 16-bit int into the buffer starting with the least significant byte. | [
"Writes",
"the",
"16",
"-",
"bit",
"int",
"into",
"the",
"buffer",
"starting",
"with",
"the",
"least",
"significant",
"byte",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/IntSerializer.java#L44-L48 |
23,259 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/IntSerializer.java | IntSerializer.writeInt32 | public static void writeInt32(final int value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) ((value >>> 24) & 0xFF);
buffer[offset++] = (byte) ((value >>> 16) & 0xFF);
buffer[offset++] = (byte) ((value >>> 8) & 0xFF);
buffer[offset] = (byte) ((value >>> 0) & 0xFF);
} | java | public static void writeInt32(final int value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) ((value >>> 24) & 0xFF);
buffer[offset++] = (byte) ((value >>> 16) & 0xFF);
buffer[offset++] = (byte) ((value >>> 8) & 0xFF);
buffer[offset] = (byte) ((value >>> 0) & 0xFF);
} | [
"public",
"static",
"void",
"writeInt32",
"(",
"final",
"int",
"value",
",",
"final",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
")",
"{",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"24",
")",
"&",
"0xFF",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"16",
")",
"&",
"0xFF",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"8",
")",
"&",
"0xFF",
")",
";",
"buffer",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"0",
")",
"&",
"0xFF",
")",
";",
"}"
] | Writes the 32-bit int into the buffer starting with the most significant byte. | [
"Writes",
"the",
"32",
"-",
"bit",
"int",
"into",
"the",
"buffer",
"starting",
"with",
"the",
"most",
"significant",
"byte",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/IntSerializer.java#L59-L65 |
23,260 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/IntSerializer.java | IntSerializer.writeInt32LE | public static void writeInt32LE(final int value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) ((value >>> 0) & 0xFF);
buffer[offset++] = (byte) ((value >>> 8) & 0xFF);
buffer[offset++] = (byte) ((value >>> 16) & 0xFF);
buffer[offset] = (byte) ((value >>> 24) & 0xFF);
} | java | public static void writeInt32LE(final int value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) ((value >>> 0) & 0xFF);
buffer[offset++] = (byte) ((value >>> 8) & 0xFF);
buffer[offset++] = (byte) ((value >>> 16) & 0xFF);
buffer[offset] = (byte) ((value >>> 24) & 0xFF);
} | [
"public",
"static",
"void",
"writeInt32LE",
"(",
"final",
"int",
"value",
",",
"final",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
")",
"{",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"0",
")",
"&",
"0xFF",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"8",
")",
"&",
"0xFF",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"16",
")",
"&",
"0xFF",
")",
";",
"buffer",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"value",
">>>",
"24",
")",
"&",
"0xFF",
")",
";",
"}"
] | Writes the 32-bit int into the buffer starting with the least significant byte. | [
"Writes",
"the",
"32",
"-",
"bit",
"int",
"into",
"the",
"buffer",
"starting",
"with",
"the",
"least",
"significant",
"byte",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/IntSerializer.java#L70-L76 |
23,261 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/IntSerializer.java | IntSerializer.writeInt64 | public static void writeInt64(final long value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) (value >>> 56);
buffer[offset++] = (byte) (value >>> 48);
buffer[offset++] = (byte) (value >>> 40);
buffer[offset++] = (byte) (value >>> 32);
buffer[offset++] = (byte) (value >>> 24);
buffer[offset++] = (byte) (value >>> 16);
buffer[offset++] = (byte) (value >>> 8);
buffer[offset] = (byte) (value >>> 0);
} | java | public static void writeInt64(final long value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) (value >>> 56);
buffer[offset++] = (byte) (value >>> 48);
buffer[offset++] = (byte) (value >>> 40);
buffer[offset++] = (byte) (value >>> 32);
buffer[offset++] = (byte) (value >>> 24);
buffer[offset++] = (byte) (value >>> 16);
buffer[offset++] = (byte) (value >>> 8);
buffer[offset] = (byte) (value >>> 0);
} | [
"public",
"static",
"void",
"writeInt64",
"(",
"final",
"long",
"value",
",",
"final",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
")",
"{",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"56",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"48",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"40",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"32",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"24",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"16",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"8",
")",
";",
"buffer",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"0",
")",
";",
"}"
] | Writes the 64-bit int into the buffer starting with the most significant byte. | [
"Writes",
"the",
"64",
"-",
"bit",
"int",
"into",
"the",
"buffer",
"starting",
"with",
"the",
"most",
"significant",
"byte",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/IntSerializer.java#L89-L99 |
23,262 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/IntSerializer.java | IntSerializer.writeInt64LE | public static void writeInt64LE(final long value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) (value >>> 0);
buffer[offset++] = (byte) (value >>> 8);
buffer[offset++] = (byte) (value >>> 16);
buffer[offset++] = (byte) (value >>> 24);
buffer[offset++] = (byte) (value >>> 32);
buffer[offset++] = (byte) (value >>> 40);
buffer[offset++] = (byte) (value >>> 48);
buffer[offset] = (byte) (value >>> 56);
} | java | public static void writeInt64LE(final long value, final byte[] buffer, int offset)
{
buffer[offset++] = (byte) (value >>> 0);
buffer[offset++] = (byte) (value >>> 8);
buffer[offset++] = (byte) (value >>> 16);
buffer[offset++] = (byte) (value >>> 24);
buffer[offset++] = (byte) (value >>> 32);
buffer[offset++] = (byte) (value >>> 40);
buffer[offset++] = (byte) (value >>> 48);
buffer[offset] = (byte) (value >>> 56);
} | [
"public",
"static",
"void",
"writeInt64LE",
"(",
"final",
"long",
"value",
",",
"final",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
")",
"{",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"0",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"8",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"16",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"24",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"32",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"40",
")",
";",
"buffer",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"48",
")",
";",
"buffer",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"56",
")",
";",
"}"
] | Writes the 64-bit int into the buffer starting with the least significant byte. | [
"Writes",
"the",
"64",
"-",
"bit",
"int",
"into",
"the",
"buffer",
"starting",
"with",
"the",
"least",
"significant",
"byte",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/IntSerializer.java#L104-L114 |
23,263 | protostuff/protostuff | protostuff-msgpack/src/main/java/io/protostuff/MsgpackInput.java | MsgpackInput.use | public MsgpackParser use(MsgpackParser newParser)
{
MsgpackParser old = this.parser;
this.parser = newParser;
return old;
} | java | public MsgpackParser use(MsgpackParser newParser)
{
MsgpackParser old = this.parser;
this.parser = newParser;
return old;
} | [
"public",
"MsgpackParser",
"use",
"(",
"MsgpackParser",
"newParser",
")",
"{",
"MsgpackParser",
"old",
"=",
"this",
".",
"parser",
";",
"this",
".",
"parser",
"=",
"newParser",
";",
"return",
"old",
";",
"}"
] | Use another parser in msgpack input | [
"Use",
"another",
"parser",
"in",
"msgpack",
"input"
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-msgpack/src/main/java/io/protostuff/MsgpackInput.java#L41-L46 |
23,264 | protostuff/protostuff | protostuff-parser/src/main/java/io/protostuff/parser/Proto.java | Proto.findFullyQualifiedObject | HasName findFullyQualifiedObject(String fullyQualifiedName)
{
Message m = fullyQualifiedMessages.get(fullyQualifiedName);
if (m != null)
return m;
EnumGroup eg = fullyQualifiedEnumGroups.get(fullyQualifiedName);
if (eg != null)
return eg;
// Search imported protos as well
for (Proto proto : getImportedProtos())
{
HasName importedObj = proto.findFullyQualifiedObject(fullyQualifiedName);
if (importedObj != null)
return importedObj;
}
return null;
} | java | HasName findFullyQualifiedObject(String fullyQualifiedName)
{
Message m = fullyQualifiedMessages.get(fullyQualifiedName);
if (m != null)
return m;
EnumGroup eg = fullyQualifiedEnumGroups.get(fullyQualifiedName);
if (eg != null)
return eg;
// Search imported protos as well
for (Proto proto : getImportedProtos())
{
HasName importedObj = proto.findFullyQualifiedObject(fullyQualifiedName);
if (importedObj != null)
return importedObj;
}
return null;
} | [
"HasName",
"findFullyQualifiedObject",
"(",
"String",
"fullyQualifiedName",
")",
"{",
"Message",
"m",
"=",
"fullyQualifiedMessages",
".",
"get",
"(",
"fullyQualifiedName",
")",
";",
"if",
"(",
"m",
"!=",
"null",
")",
"return",
"m",
";",
"EnumGroup",
"eg",
"=",
"fullyQualifiedEnumGroups",
".",
"get",
"(",
"fullyQualifiedName",
")",
";",
"if",
"(",
"eg",
"!=",
"null",
")",
"return",
"eg",
";",
"// Search imported protos as well\r",
"for",
"(",
"Proto",
"proto",
":",
"getImportedProtos",
"(",
")",
")",
"{",
"HasName",
"importedObj",
"=",
"proto",
".",
"findFullyQualifiedObject",
"(",
"fullyQualifiedName",
")",
";",
"if",
"(",
"importedObj",
"!=",
"null",
")",
"return",
"importedObj",
";",
"}",
"return",
"null",
";",
"}"
] | Returns a Message or EnumGroup given its fully qualified name
@param fullyQualifiedName
The fully qualified name, without an initial dot ('.')
@return The Message or EnumGroup instance if it is defined in this Proto or one of its imports. | [
"Returns",
"a",
"Message",
"or",
"EnumGroup",
"given",
"its",
"fully",
"qualified",
"name"
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-parser/src/main/java/io/protostuff/parser/Proto.java#L583-L602 |
23,265 | protostuff/protostuff | protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeSchema.java | RuntimeSchema.getSchema | public static <T> Schema<T> getSchema(Class<T> typeClass,
IdStrategy strategy)
{
return strategy.getSchemaWrapper(typeClass, true).getSchema();
} | java | public static <T> Schema<T> getSchema(Class<T> typeClass,
IdStrategy strategy)
{
return strategy.getSchemaWrapper(typeClass, true).getSchema();
} | [
"public",
"static",
"<",
"T",
">",
"Schema",
"<",
"T",
">",
"getSchema",
"(",
"Class",
"<",
"T",
">",
"typeClass",
",",
"IdStrategy",
"strategy",
")",
"{",
"return",
"strategy",
".",
"getSchemaWrapper",
"(",
"typeClass",
",",
"true",
")",
".",
"getSchema",
"(",
")",
";",
"}"
] | Gets the schema that was either registered or lazily initialized at runtime. | [
"Gets",
"the",
"schema",
"that",
"was",
"either",
"registered",
"or",
"lazily",
"initialized",
"at",
"runtime",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeSchema.java#L146-L150 |
23,266 | protostuff/protostuff | protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeSchema.java | RuntimeSchema.getSchemaWrapper | static <T> HasSchema<T> getSchemaWrapper(Class<T> typeClass,
IdStrategy strategy)
{
return strategy.getSchemaWrapper(typeClass, true);
} | java | static <T> HasSchema<T> getSchemaWrapper(Class<T> typeClass,
IdStrategy strategy)
{
return strategy.getSchemaWrapper(typeClass, true);
} | [
"static",
"<",
"T",
">",
"HasSchema",
"<",
"T",
">",
"getSchemaWrapper",
"(",
"Class",
"<",
"T",
">",
"typeClass",
",",
"IdStrategy",
"strategy",
")",
"{",
"return",
"strategy",
".",
"getSchemaWrapper",
"(",
"typeClass",
",",
"true",
")",
";",
"}"
] | Returns the schema wrapper. | [
"Returns",
"the",
"schema",
"wrapper",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeSchema.java#L165-L169 |
23,267 | protostuff/protostuff | protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeSchema.java | RuntimeSchema.createFrom | public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass,
IdStrategy strategy)
{
return createFrom(typeClass, NO_EXCLUSIONS, strategy);
} | java | public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass,
IdStrategy strategy)
{
return createFrom(typeClass, NO_EXCLUSIONS, strategy);
} | [
"public",
"static",
"<",
"T",
">",
"RuntimeSchema",
"<",
"T",
">",
"createFrom",
"(",
"Class",
"<",
"T",
">",
"typeClass",
",",
"IdStrategy",
"strategy",
")",
"{",
"return",
"createFrom",
"(",
"typeClass",
",",
"NO_EXCLUSIONS",
",",
"strategy",
")",
";",
"}"
] | Generates a schema from the given class. | [
"Generates",
"a",
"schema",
"from",
"the",
"given",
"class",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeSchema.java#L184-L188 |
23,268 | protostuff/protostuff | protostuff-xml/src/main/java/io/protostuff/XmlIOUtil.java | XmlIOUtil.newPipe | public static Pipe newPipe(byte[] data, int offset, int length) throws IOException
{
return newPipe(new ByteArrayInputStream(data, offset, length));
} | java | public static Pipe newPipe(byte[] data, int offset, int length) throws IOException
{
return newPipe(new ByteArrayInputStream(data, offset, length));
} | [
"public",
"static",
"Pipe",
"newPipe",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"return",
"newPipe",
"(",
"new",
"ByteArrayInputStream",
"(",
"data",
",",
"offset",
",",
"length",
")",
")",
";",
"}"
] | Creates an xml pipe from a byte array. | [
"Creates",
"an",
"xml",
"pipe",
"from",
"a",
"byte",
"array",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-xml/src/main/java/io/protostuff/XmlIOUtil.java#L64-L67 |
23,269 | protostuff/protostuff | protostuff-core/src/main/java/io/protostuff/CodedInput.java | CodedInput.newInstance | public static CodedInput newInstance(final byte[] buf, final int off,
final int len)
{
return new CodedInput(buf, off, len, false);
} | java | public static CodedInput newInstance(final byte[] buf, final int off,
final int len)
{
return new CodedInput(buf, off, len, false);
} | [
"public",
"static",
"CodedInput",
"newInstance",
"(",
"final",
"byte",
"[",
"]",
"buf",
",",
"final",
"int",
"off",
",",
"final",
"int",
"len",
")",
"{",
"return",
"new",
"CodedInput",
"(",
"buf",
",",
"off",
",",
"len",
",",
"false",
")",
";",
"}"
] | Create a new CodedInput wrapping the given byte array slice. | [
"Create",
"a",
"new",
"CodedInput",
"wrapping",
"the",
"given",
"byte",
"array",
"slice",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/CodedInput.java#L94-L98 |
23,270 | protostuff/protostuff | protostuff-core/src/main/java/io/protostuff/CodedInput.java | CodedInput.skipField | public boolean skipField(final int tag) throws IOException
{
switch (WireFormat.getTagWireType(tag))
{
case WireFormat.WIRETYPE_VARINT:
readInt32();
return true;
case WireFormat.WIRETYPE_FIXED64:
readRawLittleEndian64();
return true;
case WireFormat.WIRETYPE_LENGTH_DELIMITED:
skipRawBytes(readRawVarint32());
return true;
case WireFormat.WIRETYPE_START_GROUP:
skipMessage();
checkLastTagWas(WireFormat.makeTag(WireFormat.getTagFieldNumber(tag),
WireFormat.WIRETYPE_END_GROUP));
return true;
case WireFormat.WIRETYPE_END_GROUP:
return false;
case WireFormat.WIRETYPE_FIXED32:
readRawLittleEndian32();
return true;
default:
throw ProtobufException.invalidWireType();
}
} | java | public boolean skipField(final int tag) throws IOException
{
switch (WireFormat.getTagWireType(tag))
{
case WireFormat.WIRETYPE_VARINT:
readInt32();
return true;
case WireFormat.WIRETYPE_FIXED64:
readRawLittleEndian64();
return true;
case WireFormat.WIRETYPE_LENGTH_DELIMITED:
skipRawBytes(readRawVarint32());
return true;
case WireFormat.WIRETYPE_START_GROUP:
skipMessage();
checkLastTagWas(WireFormat.makeTag(WireFormat.getTagFieldNumber(tag),
WireFormat.WIRETYPE_END_GROUP));
return true;
case WireFormat.WIRETYPE_END_GROUP:
return false;
case WireFormat.WIRETYPE_FIXED32:
readRawLittleEndian32();
return true;
default:
throw ProtobufException.invalidWireType();
}
} | [
"public",
"boolean",
"skipField",
"(",
"final",
"int",
"tag",
")",
"throws",
"IOException",
"{",
"switch",
"(",
"WireFormat",
".",
"getTagWireType",
"(",
"tag",
")",
")",
"{",
"case",
"WireFormat",
".",
"WIRETYPE_VARINT",
":",
"readInt32",
"(",
")",
";",
"return",
"true",
";",
"case",
"WireFormat",
".",
"WIRETYPE_FIXED64",
":",
"readRawLittleEndian64",
"(",
")",
";",
"return",
"true",
";",
"case",
"WireFormat",
".",
"WIRETYPE_LENGTH_DELIMITED",
":",
"skipRawBytes",
"(",
"readRawVarint32",
"(",
")",
")",
";",
"return",
"true",
";",
"case",
"WireFormat",
".",
"WIRETYPE_START_GROUP",
":",
"skipMessage",
"(",
")",
";",
"checkLastTagWas",
"(",
"WireFormat",
".",
"makeTag",
"(",
"WireFormat",
".",
"getTagFieldNumber",
"(",
"tag",
")",
",",
"WireFormat",
".",
"WIRETYPE_END_GROUP",
")",
")",
";",
"return",
"true",
";",
"case",
"WireFormat",
".",
"WIRETYPE_END_GROUP",
":",
"return",
"false",
";",
"case",
"WireFormat",
".",
"WIRETYPE_FIXED32",
":",
"readRawLittleEndian32",
"(",
")",
";",
"return",
"true",
";",
"default",
":",
"throw",
"ProtobufException",
".",
"invalidWireType",
"(",
")",
";",
"}",
"}"
] | Reads and discards a single field, given its tag value.
@return {@code false} if the tag is an endgroup tag, in which case nothing is skipped. Otherwise, returns
{@code true}. | [
"Reads",
"and",
"discards",
"a",
"single",
"field",
"given",
"its",
"tag",
"value",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/CodedInput.java#L146-L172 |
23,271 | protostuff/protostuff | protostuff-core/src/main/java/io/protostuff/CodedInput.java | CodedInput.readRawLittleEndian32 | public int readRawLittleEndian32() throws IOException
{
final byte b1 = readRawByte();
final byte b2 = readRawByte();
final byte b3 = readRawByte();
final byte b4 = readRawByte();
return (((int) b1 & 0xff)) |
(((int) b2 & 0xff) << 8) |
(((int) b3 & 0xff) << 16) |
(((int) b4 & 0xff) << 24);
} | java | public int readRawLittleEndian32() throws IOException
{
final byte b1 = readRawByte();
final byte b2 = readRawByte();
final byte b3 = readRawByte();
final byte b4 = readRawByte();
return (((int) b1 & 0xff)) |
(((int) b2 & 0xff) << 8) |
(((int) b3 & 0xff) << 16) |
(((int) b4 & 0xff) << 24);
} | [
"public",
"int",
"readRawLittleEndian32",
"(",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"b1",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b2",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b3",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b4",
"=",
"readRawByte",
"(",
")",
";",
"return",
"(",
"(",
"(",
"int",
")",
"b1",
"&",
"0xff",
")",
")",
"|",
"(",
"(",
"(",
"int",
")",
"b2",
"&",
"0xff",
")",
"<<",
"8",
")",
"|",
"(",
"(",
"(",
"int",
")",
"b3",
"&",
"0xff",
")",
"<<",
"16",
")",
"|",
"(",
"(",
"(",
"int",
")",
"b4",
"&",
"0xff",
")",
"<<",
"24",
")",
";",
"}"
] | Read a 32-bit little-endian integer from the stream. | [
"Read",
"a",
"32",
"-",
"bit",
"little",
"-",
"endian",
"integer",
"from",
"the",
"stream",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/CodedInput.java#L634-L644 |
23,272 | protostuff/protostuff | protostuff-core/src/main/java/io/protostuff/CodedInput.java | CodedInput.readRawLittleEndian64 | public long readRawLittleEndian64() throws IOException
{
final byte b1 = readRawByte();
final byte b2 = readRawByte();
final byte b3 = readRawByte();
final byte b4 = readRawByte();
final byte b5 = readRawByte();
final byte b6 = readRawByte();
final byte b7 = readRawByte();
final byte b8 = readRawByte();
return (((long) b1 & 0xff)) |
(((long) b2 & 0xff) << 8) |
(((long) b3 & 0xff) << 16) |
(((long) b4 & 0xff) << 24) |
(((long) b5 & 0xff) << 32) |
(((long) b6 & 0xff) << 40) |
(((long) b7 & 0xff) << 48) |
(((long) b8 & 0xff) << 56);
} | java | public long readRawLittleEndian64() throws IOException
{
final byte b1 = readRawByte();
final byte b2 = readRawByte();
final byte b3 = readRawByte();
final byte b4 = readRawByte();
final byte b5 = readRawByte();
final byte b6 = readRawByte();
final byte b7 = readRawByte();
final byte b8 = readRawByte();
return (((long) b1 & 0xff)) |
(((long) b2 & 0xff) << 8) |
(((long) b3 & 0xff) << 16) |
(((long) b4 & 0xff) << 24) |
(((long) b5 & 0xff) << 32) |
(((long) b6 & 0xff) << 40) |
(((long) b7 & 0xff) << 48) |
(((long) b8 & 0xff) << 56);
} | [
"public",
"long",
"readRawLittleEndian64",
"(",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"b1",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b2",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b3",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b4",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b5",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b6",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b7",
"=",
"readRawByte",
"(",
")",
";",
"final",
"byte",
"b8",
"=",
"readRawByte",
"(",
")",
";",
"return",
"(",
"(",
"(",
"long",
")",
"b1",
"&",
"0xff",
")",
")",
"|",
"(",
"(",
"(",
"long",
")",
"b2",
"&",
"0xff",
")",
"<<",
"8",
")",
"|",
"(",
"(",
"(",
"long",
")",
"b3",
"&",
"0xff",
")",
"<<",
"16",
")",
"|",
"(",
"(",
"(",
"long",
")",
"b4",
"&",
"0xff",
")",
"<<",
"24",
")",
"|",
"(",
"(",
"(",
"long",
")",
"b5",
"&",
"0xff",
")",
"<<",
"32",
")",
"|",
"(",
"(",
"(",
"long",
")",
"b6",
"&",
"0xff",
")",
"<<",
"40",
")",
"|",
"(",
"(",
"(",
"long",
")",
"b7",
"&",
"0xff",
")",
"<<",
"48",
")",
"|",
"(",
"(",
"(",
"long",
")",
"b8",
"&",
"0xff",
")",
"<<",
"56",
")",
";",
"}"
] | Read a 64-bit little-endian integer from the stream. | [
"Read",
"a",
"64",
"-",
"bit",
"little",
"-",
"endian",
"integer",
"from",
"the",
"stream",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/CodedInput.java#L649-L667 |
23,273 | protostuff/protostuff | protostuff-core/src/main/java/io/protostuff/CodedInput.java | CodedInput.reset | public void reset()
{
this.bufferSize = 0;
this.bufferPos = 0;
this.bufferSizeAfterLimit = 0;
this.currentLimit = Integer.MAX_VALUE;
this.lastTag = 0;
this.packedLimit = 0;
this.sizeLimit = DEFAULT_SIZE_LIMIT;
resetSizeCounter();
} | java | public void reset()
{
this.bufferSize = 0;
this.bufferPos = 0;
this.bufferSizeAfterLimit = 0;
this.currentLimit = Integer.MAX_VALUE;
this.lastTag = 0;
this.packedLimit = 0;
this.sizeLimit = DEFAULT_SIZE_LIMIT;
resetSizeCounter();
} | [
"public",
"void",
"reset",
"(",
")",
"{",
"this",
".",
"bufferSize",
"=",
"0",
";",
"this",
".",
"bufferPos",
"=",
"0",
";",
"this",
".",
"bufferSizeAfterLimit",
"=",
"0",
";",
"this",
".",
"currentLimit",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"this",
".",
"lastTag",
"=",
"0",
";",
"this",
".",
"packedLimit",
"=",
"0",
";",
"this",
".",
"sizeLimit",
"=",
"DEFAULT_SIZE_LIMIT",
";",
"resetSizeCounter",
"(",
")",
";",
"}"
] | Resets the buffer position and limit to re-use this CodedInput object. | [
"Resets",
"the",
"buffer",
"position",
"and",
"limit",
"to",
"re",
"-",
"use",
"this",
"CodedInput",
"object",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/CodedInput.java#L816-L826 |
23,274 | protostuff/protostuff | protostuff-core/src/main/java/io/protostuff/CodedInput.java | CodedInput.readRawBytes | public byte[] readRawBytes(final int size) throws IOException
{
if (size < 0)
{
throw ProtobufException.negativeSize();
}
if (totalBytesRetired + bufferPos + size > currentLimit)
{
// Read to the end of the stream anyway.
skipRawBytes(currentLimit - totalBytesRetired - bufferPos);
// Then fail.
throw ProtobufException.truncatedMessage();
}
if (size <= bufferSize - bufferPos)
{
// We have all the bytes we need already.
final byte[] bytes = new byte[size];
System.arraycopy(buffer, bufferPos, bytes, 0, size);
bufferPos += size;
return bytes;
}
else if (size < buffer.length)
{
// Reading more bytes than are in the buffer, but not an excessive number
// of bytes. We can safely allocate the resulting array ahead of time.
// First copy what we have.
final byte[] bytes = new byte[size];
int pos = bufferSize - bufferPos;
System.arraycopy(buffer, bufferPos, bytes, 0, pos);
bufferPos = bufferSize;
// We want to use refillBuffer() and then copy from the buffer into our
// byte array rather than reading directly into our byte array because
// the input may be unbuffered.
refillBuffer(true);
while (size - pos > bufferSize)
{
System.arraycopy(buffer, 0, bytes, pos, bufferSize);
pos += bufferSize;
bufferPos = bufferSize;
refillBuffer(true);
}
System.arraycopy(buffer, 0, bytes, pos, size - pos);
bufferPos = size - pos;
return bytes;
}
else
{
// The size is very large. For security reasons, we can't allocate the
// entire byte array yet. The size comes directly from the input, so a
// maliciously-crafted message could provide a bogus very large size in
// order to trick the app into allocating a lot of memory. We avoid this
// by allocating and reading only a small chunk at a time, so that the
// malicious message must actually *be* extremely large to cause
// problems. Meanwhile, we limit the allowed size of a message elsewhere.
// Remember the buffer markers since we'll have to copy the bytes out of
// it later.
final int originalBufferPos = bufferPos;
final int originalBufferSize = bufferSize;
// Mark the current buffer consumed.
totalBytesRetired += bufferSize;
bufferPos = 0;
bufferSize = 0;
// Read all the rest of the bytes we need.
int sizeLeft = size - (originalBufferSize - originalBufferPos);
final List<byte[]> chunks = new ArrayList<byte[]>();
while (sizeLeft > 0)
{
final byte[] chunk = new byte[Math.min(sizeLeft, buffer.length)];
int pos = 0;
while (pos < chunk.length)
{
final int n = (input == null) ? -1 :
input.read(chunk, pos, chunk.length - pos);
if (n == -1)
{
throw ProtobufException.truncatedMessage();
}
totalBytesRetired += n;
pos += n;
}
sizeLeft -= chunk.length;
chunks.add(chunk);
}
// OK, got everything. Now concatenate it all into one buffer.
final byte[] bytes = new byte[size];
// Start by copying the leftover bytes from this.buffer.
int pos = originalBufferSize - originalBufferPos;
System.arraycopy(buffer, originalBufferPos, bytes, 0, pos);
// And now all the chunks.
for (final byte[] chunk : chunks)
{
System.arraycopy(chunk, 0, bytes, pos, chunk.length);
pos += chunk.length;
}
// Done.
return bytes;
}
} | java | public byte[] readRawBytes(final int size) throws IOException
{
if (size < 0)
{
throw ProtobufException.negativeSize();
}
if (totalBytesRetired + bufferPos + size > currentLimit)
{
// Read to the end of the stream anyway.
skipRawBytes(currentLimit - totalBytesRetired - bufferPos);
// Then fail.
throw ProtobufException.truncatedMessage();
}
if (size <= bufferSize - bufferPos)
{
// We have all the bytes we need already.
final byte[] bytes = new byte[size];
System.arraycopy(buffer, bufferPos, bytes, 0, size);
bufferPos += size;
return bytes;
}
else if (size < buffer.length)
{
// Reading more bytes than are in the buffer, but not an excessive number
// of bytes. We can safely allocate the resulting array ahead of time.
// First copy what we have.
final byte[] bytes = new byte[size];
int pos = bufferSize - bufferPos;
System.arraycopy(buffer, bufferPos, bytes, 0, pos);
bufferPos = bufferSize;
// We want to use refillBuffer() and then copy from the buffer into our
// byte array rather than reading directly into our byte array because
// the input may be unbuffered.
refillBuffer(true);
while (size - pos > bufferSize)
{
System.arraycopy(buffer, 0, bytes, pos, bufferSize);
pos += bufferSize;
bufferPos = bufferSize;
refillBuffer(true);
}
System.arraycopy(buffer, 0, bytes, pos, size - pos);
bufferPos = size - pos;
return bytes;
}
else
{
// The size is very large. For security reasons, we can't allocate the
// entire byte array yet. The size comes directly from the input, so a
// maliciously-crafted message could provide a bogus very large size in
// order to trick the app into allocating a lot of memory. We avoid this
// by allocating and reading only a small chunk at a time, so that the
// malicious message must actually *be* extremely large to cause
// problems. Meanwhile, we limit the allowed size of a message elsewhere.
// Remember the buffer markers since we'll have to copy the bytes out of
// it later.
final int originalBufferPos = bufferPos;
final int originalBufferSize = bufferSize;
// Mark the current buffer consumed.
totalBytesRetired += bufferSize;
bufferPos = 0;
bufferSize = 0;
// Read all the rest of the bytes we need.
int sizeLeft = size - (originalBufferSize - originalBufferPos);
final List<byte[]> chunks = new ArrayList<byte[]>();
while (sizeLeft > 0)
{
final byte[] chunk = new byte[Math.min(sizeLeft, buffer.length)];
int pos = 0;
while (pos < chunk.length)
{
final int n = (input == null) ? -1 :
input.read(chunk, pos, chunk.length - pos);
if (n == -1)
{
throw ProtobufException.truncatedMessage();
}
totalBytesRetired += n;
pos += n;
}
sizeLeft -= chunk.length;
chunks.add(chunk);
}
// OK, got everything. Now concatenate it all into one buffer.
final byte[] bytes = new byte[size];
// Start by copying the leftover bytes from this.buffer.
int pos = originalBufferSize - originalBufferPos;
System.arraycopy(buffer, originalBufferPos, bytes, 0, pos);
// And now all the chunks.
for (final byte[] chunk : chunks)
{
System.arraycopy(chunk, 0, bytes, pos, chunk.length);
pos += chunk.length;
}
// Done.
return bytes;
}
} | [
"public",
"byte",
"[",
"]",
"readRawBytes",
"(",
"final",
"int",
"size",
")",
"throws",
"IOException",
"{",
"if",
"(",
"size",
"<",
"0",
")",
"{",
"throw",
"ProtobufException",
".",
"negativeSize",
"(",
")",
";",
"}",
"if",
"(",
"totalBytesRetired",
"+",
"bufferPos",
"+",
"size",
">",
"currentLimit",
")",
"{",
"// Read to the end of the stream anyway.",
"skipRawBytes",
"(",
"currentLimit",
"-",
"totalBytesRetired",
"-",
"bufferPos",
")",
";",
"// Then fail.",
"throw",
"ProtobufException",
".",
"truncatedMessage",
"(",
")",
";",
"}",
"if",
"(",
"size",
"<=",
"bufferSize",
"-",
"bufferPos",
")",
"{",
"// We have all the bytes we need already.",
"final",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"size",
"]",
";",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"bufferPos",
",",
"bytes",
",",
"0",
",",
"size",
")",
";",
"bufferPos",
"+=",
"size",
";",
"return",
"bytes",
";",
"}",
"else",
"if",
"(",
"size",
"<",
"buffer",
".",
"length",
")",
"{",
"// Reading more bytes than are in the buffer, but not an excessive number",
"// of bytes. We can safely allocate the resulting array ahead of time.",
"// First copy what we have.",
"final",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"size",
"]",
";",
"int",
"pos",
"=",
"bufferSize",
"-",
"bufferPos",
";",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"bufferPos",
",",
"bytes",
",",
"0",
",",
"pos",
")",
";",
"bufferPos",
"=",
"bufferSize",
";",
"// We want to use refillBuffer() and then copy from the buffer into our",
"// byte array rather than reading directly into our byte array because",
"// the input may be unbuffered.",
"refillBuffer",
"(",
"true",
")",
";",
"while",
"(",
"size",
"-",
"pos",
">",
"bufferSize",
")",
"{",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"0",
",",
"bytes",
",",
"pos",
",",
"bufferSize",
")",
";",
"pos",
"+=",
"bufferSize",
";",
"bufferPos",
"=",
"bufferSize",
";",
"refillBuffer",
"(",
"true",
")",
";",
"}",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"0",
",",
"bytes",
",",
"pos",
",",
"size",
"-",
"pos",
")",
";",
"bufferPos",
"=",
"size",
"-",
"pos",
";",
"return",
"bytes",
";",
"}",
"else",
"{",
"// The size is very large. For security reasons, we can't allocate the",
"// entire byte array yet. The size comes directly from the input, so a",
"// maliciously-crafted message could provide a bogus very large size in",
"// order to trick the app into allocating a lot of memory. We avoid this",
"// by allocating and reading only a small chunk at a time, so that the",
"// malicious message must actually *be* extremely large to cause",
"// problems. Meanwhile, we limit the allowed size of a message elsewhere.",
"// Remember the buffer markers since we'll have to copy the bytes out of",
"// it later.",
"final",
"int",
"originalBufferPos",
"=",
"bufferPos",
";",
"final",
"int",
"originalBufferSize",
"=",
"bufferSize",
";",
"// Mark the current buffer consumed.",
"totalBytesRetired",
"+=",
"bufferSize",
";",
"bufferPos",
"=",
"0",
";",
"bufferSize",
"=",
"0",
";",
"// Read all the rest of the bytes we need.",
"int",
"sizeLeft",
"=",
"size",
"-",
"(",
"originalBufferSize",
"-",
"originalBufferPos",
")",
";",
"final",
"List",
"<",
"byte",
"[",
"]",
">",
"chunks",
"=",
"new",
"ArrayList",
"<",
"byte",
"[",
"]",
">",
"(",
")",
";",
"while",
"(",
"sizeLeft",
">",
"0",
")",
"{",
"final",
"byte",
"[",
"]",
"chunk",
"=",
"new",
"byte",
"[",
"Math",
".",
"min",
"(",
"sizeLeft",
",",
"buffer",
".",
"length",
")",
"]",
";",
"int",
"pos",
"=",
"0",
";",
"while",
"(",
"pos",
"<",
"chunk",
".",
"length",
")",
"{",
"final",
"int",
"n",
"=",
"(",
"input",
"==",
"null",
")",
"?",
"-",
"1",
":",
"input",
".",
"read",
"(",
"chunk",
",",
"pos",
",",
"chunk",
".",
"length",
"-",
"pos",
")",
";",
"if",
"(",
"n",
"==",
"-",
"1",
")",
"{",
"throw",
"ProtobufException",
".",
"truncatedMessage",
"(",
")",
";",
"}",
"totalBytesRetired",
"+=",
"n",
";",
"pos",
"+=",
"n",
";",
"}",
"sizeLeft",
"-=",
"chunk",
".",
"length",
";",
"chunks",
".",
"add",
"(",
"chunk",
")",
";",
"}",
"// OK, got everything. Now concatenate it all into one buffer.",
"final",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"size",
"]",
";",
"// Start by copying the leftover bytes from this.buffer.",
"int",
"pos",
"=",
"originalBufferSize",
"-",
"originalBufferPos",
";",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"originalBufferPos",
",",
"bytes",
",",
"0",
",",
"pos",
")",
";",
"// And now all the chunks.",
"for",
"(",
"final",
"byte",
"[",
"]",
"chunk",
":",
"chunks",
")",
"{",
"System",
".",
"arraycopy",
"(",
"chunk",
",",
"0",
",",
"bytes",
",",
"pos",
",",
"chunk",
".",
"length",
")",
";",
"pos",
"+=",
"chunk",
".",
"length",
";",
"}",
"// Done.",
"return",
"bytes",
";",
"}",
"}"
] | Read a fixed size of bytes from the input.
@throws ProtobufException
The end of the stream or the current limit was reached. | [
"Read",
"a",
"fixed",
"size",
"of",
"bytes",
"from",
"the",
"input",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/CodedInput.java#L1006-L1118 |
23,275 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/NumberParser.java | NumberParser.parseInt | public static int parseInt(final byte[] buffer, final int start, final int length,
final int radix) throws NumberFormatException
{
if (length == 0)
throw new NumberFormatException(STRING.deser(buffer, start, length));
if (buffer[start] == '-')
{
if (length == 1)
throw new NumberFormatException(STRING.deser(buffer, start, length));
return parseInt(buffer, start + 1, length - 1, radix, false);
}
return parseInt(buffer, start, length, radix, true);
} | java | public static int parseInt(final byte[] buffer, final int start, final int length,
final int radix) throws NumberFormatException
{
if (length == 0)
throw new NumberFormatException(STRING.deser(buffer, start, length));
if (buffer[start] == '-')
{
if (length == 1)
throw new NumberFormatException(STRING.deser(buffer, start, length));
return parseInt(buffer, start + 1, length - 1, radix, false);
}
return parseInt(buffer, start, length, radix, true);
} | [
"public",
"static",
"int",
"parseInt",
"(",
"final",
"byte",
"[",
"]",
"buffer",
",",
"final",
"int",
"start",
",",
"final",
"int",
"length",
",",
"final",
"int",
"radix",
")",
"throws",
"NumberFormatException",
"{",
"if",
"(",
"length",
"==",
"0",
")",
"throw",
"new",
"NumberFormatException",
"(",
"STRING",
".",
"deser",
"(",
"buffer",
",",
"start",
",",
"length",
")",
")",
";",
"if",
"(",
"buffer",
"[",
"start",
"]",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"length",
"==",
"1",
")",
"throw",
"new",
"NumberFormatException",
"(",
"STRING",
".",
"deser",
"(",
"buffer",
",",
"start",
",",
"length",
")",
")",
";",
"return",
"parseInt",
"(",
"buffer",
",",
"start",
"+",
"1",
",",
"length",
"-",
"1",
",",
"radix",
",",
"false",
")",
";",
"}",
"return",
"parseInt",
"(",
"buffer",
",",
"start",
",",
"length",
",",
"radix",
",",
"true",
")",
";",
"}"
] | Parse an ascii int from a raw buffer. | [
"Parse",
"an",
"ascii",
"int",
"from",
"a",
"raw",
"buffer",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/NumberParser.java#L35-L50 |
23,276 | protostuff/protostuff | protostuff-api/src/main/java/io/protostuff/UnsignedNumberUtil.java | UnsignedNumberUtil.remainder | private static long remainder(long dividend, long divisor)
{
if (divisor < 0)
{ // i.e., divisor >= 2^63:
if (compareUnsigned(dividend, divisor) < 0)
{
return dividend; // dividend < divisor
}
else
{
return dividend - divisor; // dividend >= divisor
}
}
// Optimization - use signed modulus if dividend < 2^63
if (dividend >= 0)
{
return dividend % divisor;
}
/*
* Otherwise, approximate the quotient, check, and correct if necessary. Our approximation is guaranteed to be
* either exact or one less than the correct value. This follows from fact that floor(floor(x)/i) == floor(x/i)
* for any real x and integer i != 0. The proof is not quite trivial.
*/
long quotient = ((dividend >>> 1) / divisor) << 1;
long rem = dividend - quotient * divisor;
return rem - (compareUnsigned(rem, divisor) >= 0 ? divisor : 0);
} | java | private static long remainder(long dividend, long divisor)
{
if (divisor < 0)
{ // i.e., divisor >= 2^63:
if (compareUnsigned(dividend, divisor) < 0)
{
return dividend; // dividend < divisor
}
else
{
return dividend - divisor; // dividend >= divisor
}
}
// Optimization - use signed modulus if dividend < 2^63
if (dividend >= 0)
{
return dividend % divisor;
}
/*
* Otherwise, approximate the quotient, check, and correct if necessary. Our approximation is guaranteed to be
* either exact or one less than the correct value. This follows from fact that floor(floor(x)/i) == floor(x/i)
* for any real x and integer i != 0. The proof is not quite trivial.
*/
long quotient = ((dividend >>> 1) / divisor) << 1;
long rem = dividend - quotient * divisor;
return rem - (compareUnsigned(rem, divisor) >= 0 ? divisor : 0);
} | [
"private",
"static",
"long",
"remainder",
"(",
"long",
"dividend",
",",
"long",
"divisor",
")",
"{",
"if",
"(",
"divisor",
"<",
"0",
")",
"{",
"// i.e., divisor >= 2^63:",
"if",
"(",
"compareUnsigned",
"(",
"dividend",
",",
"divisor",
")",
"<",
"0",
")",
"{",
"return",
"dividend",
";",
"// dividend < divisor",
"}",
"else",
"{",
"return",
"dividend",
"-",
"divisor",
";",
"// dividend >= divisor",
"}",
"}",
"// Optimization - use signed modulus if dividend < 2^63",
"if",
"(",
"dividend",
">=",
"0",
")",
"{",
"return",
"dividend",
"%",
"divisor",
";",
"}",
"/*\n * Otherwise, approximate the quotient, check, and correct if necessary. Our approximation is guaranteed to be\n * either exact or one less than the correct value. This follows from fact that floor(floor(x)/i) == floor(x/i)\n * for any real x and integer i != 0. The proof is not quite trivial.\n */",
"long",
"quotient",
"=",
"(",
"(",
"dividend",
">>>",
"1",
")",
"/",
"divisor",
")",
"<<",
"1",
";",
"long",
"rem",
"=",
"dividend",
"-",
"quotient",
"*",
"divisor",
";",
"return",
"rem",
"-",
"(",
"compareUnsigned",
"(",
"rem",
",",
"divisor",
")",
">=",
"0",
"?",
"divisor",
":",
"0",
")",
";",
"}"
] | Returns dividend % divisor, where the dividend and divisor are treated as unsigned 64-bit quantities.
@param dividend
the dividend (numerator)
@param divisor
the divisor (denominator)
@throws ArithmeticException
if divisor is 0
@since 11.0 | [
"Returns",
"dividend",
"%",
"divisor",
"where",
"the",
"dividend",
"and",
"divisor",
"are",
"treated",
"as",
"unsigned",
"64",
"-",
"bit",
"quantities",
"."
] | af669cf089057d0ec83220266131ce411854af7b | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-api/src/main/java/io/protostuff/UnsignedNumberUtil.java#L227-L255 |
23,277 | romannurik/muzei | gl-wallpaper/src/main/java/com/google/android/apps/muzei/render/GLTextureView.java | GLTextureView.onAttachedToWindow | @Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (LOG_ATTACH_DETACH) {
Log.d(TAG, "onAttachedToWindow reattach =" + mDetached);
}
if (mDetached && (mRenderer != null)) {
int renderMode = RENDERMODE_CONTINUOUSLY;
if (mGLThread != null) {
renderMode = mGLThread.getRenderMode();
}
mGLThread = new GLThread(mThisWeakRef);
if (renderMode != RENDERMODE_CONTINUOUSLY) {
mGLThread.setRenderMode(renderMode);
}
mGLThread.start();
}
mDetached = false;
} | java | @Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (LOG_ATTACH_DETACH) {
Log.d(TAG, "onAttachedToWindow reattach =" + mDetached);
}
if (mDetached && (mRenderer != null)) {
int renderMode = RENDERMODE_CONTINUOUSLY;
if (mGLThread != null) {
renderMode = mGLThread.getRenderMode();
}
mGLThread = new GLThread(mThisWeakRef);
if (renderMode != RENDERMODE_CONTINUOUSLY) {
mGLThread.setRenderMode(renderMode);
}
mGLThread.start();
}
mDetached = false;
} | [
"@",
"Override",
"protected",
"void",
"onAttachedToWindow",
"(",
")",
"{",
"super",
".",
"onAttachedToWindow",
"(",
")",
";",
"if",
"(",
"LOG_ATTACH_DETACH",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"onAttachedToWindow reattach =\"",
"+",
"mDetached",
")",
";",
"}",
"if",
"(",
"mDetached",
"&&",
"(",
"mRenderer",
"!=",
"null",
")",
")",
"{",
"int",
"renderMode",
"=",
"RENDERMODE_CONTINUOUSLY",
";",
"if",
"(",
"mGLThread",
"!=",
"null",
")",
"{",
"renderMode",
"=",
"mGLThread",
".",
"getRenderMode",
"(",
")",
";",
"}",
"mGLThread",
"=",
"new",
"GLThread",
"(",
"mThisWeakRef",
")",
";",
"if",
"(",
"renderMode",
"!=",
"RENDERMODE_CONTINUOUSLY",
")",
"{",
"mGLThread",
".",
"setRenderMode",
"(",
"renderMode",
")",
";",
"}",
"mGLThread",
".",
"start",
"(",
")",
";",
"}",
"mDetached",
"=",
"false",
";",
"}"
] | This method is used as part of the View class and is not normally
called or subclassed by clients of GLSurfaceView. | [
"This",
"method",
"is",
"used",
"as",
"part",
"of",
"the",
"View",
"class",
"and",
"is",
"not",
"normally",
"called",
"or",
"subclassed",
"by",
"clients",
"of",
"GLSurfaceView",
"."
] | d00777a5fc59f34471be338c814ea85ddcbde304 | https://github.com/romannurik/muzei/blob/d00777a5fc59f34471be338c814ea85ddcbde304/gl-wallpaper/src/main/java/com/google/android/apps/muzei/render/GLTextureView.java#L459-L477 |
23,278 | romannurik/muzei | gl-wallpaper/src/main/java/com/google/android/apps/muzei/render/GLTextureView.java | GLTextureView.onDetachedFromWindow | @Override
protected void onDetachedFromWindow() {
if (LOG_ATTACH_DETACH) {
Log.d(TAG, "onDetachedFromWindow");
}
if (mGLThread != null) {
mGLThread.requestExitAndWait();
}
mDetached = true;
super.onDetachedFromWindow();
} | java | @Override
protected void onDetachedFromWindow() {
if (LOG_ATTACH_DETACH) {
Log.d(TAG, "onDetachedFromWindow");
}
if (mGLThread != null) {
mGLThread.requestExitAndWait();
}
mDetached = true;
super.onDetachedFromWindow();
} | [
"@",
"Override",
"protected",
"void",
"onDetachedFromWindow",
"(",
")",
"{",
"if",
"(",
"LOG_ATTACH_DETACH",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"onDetachedFromWindow\"",
")",
";",
"}",
"if",
"(",
"mGLThread",
"!=",
"null",
")",
"{",
"mGLThread",
".",
"requestExitAndWait",
"(",
")",
";",
"}",
"mDetached",
"=",
"true",
";",
"super",
".",
"onDetachedFromWindow",
"(",
")",
";",
"}"
] | This method is used as part of the View class and is not normally
called or subclassed by clients of GLSurfaceView.
Must not be called before a renderer has been set. | [
"This",
"method",
"is",
"used",
"as",
"part",
"of",
"the",
"View",
"class",
"and",
"is",
"not",
"normally",
"called",
"or",
"subclassed",
"by",
"clients",
"of",
"GLSurfaceView",
".",
"Must",
"not",
"be",
"called",
"before",
"a",
"renderer",
"has",
"been",
"set",
"."
] | d00777a5fc59f34471be338c814ea85ddcbde304 | https://github.com/romannurik/muzei/blob/d00777a5fc59f34471be338c814ea85ddcbde304/gl-wallpaper/src/main/java/com/google/android/apps/muzei/render/GLTextureView.java#L484-L494 |
23,279 | romannurik/muzei | main/src/main/java/com/google/android/apps/muzei/sources/OkHttpClientFactory.java | OkHttpClientFactory.getNewOkHttpClient | @NonNull
private static OkHttpClient getNewOkHttpClient(boolean enableTLS) {
OkHttpClient.Builder client = new OkHttpClient.Builder()
.connectTimeout(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS)
.readTimeout(DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS);
if (enableTLS) {
client = enableTls12(client);
}
return client.build();
} | java | @NonNull
private static OkHttpClient getNewOkHttpClient(boolean enableTLS) {
OkHttpClient.Builder client = new OkHttpClient.Builder()
.connectTimeout(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS)
.readTimeout(DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS);
if (enableTLS) {
client = enableTls12(client);
}
return client.build();
} | [
"@",
"NonNull",
"private",
"static",
"OkHttpClient",
"getNewOkHttpClient",
"(",
"boolean",
"enableTLS",
")",
"{",
"OkHttpClient",
".",
"Builder",
"client",
"=",
"new",
"OkHttpClient",
".",
"Builder",
"(",
")",
".",
"connectTimeout",
"(",
"DEFAULT_CONNECT_TIMEOUT",
",",
"TimeUnit",
".",
"SECONDS",
")",
".",
"readTimeout",
"(",
"DEFAULT_READ_TIMEOUT",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"if",
"(",
"enableTLS",
")",
"{",
"client",
"=",
"enableTls12",
"(",
"client",
")",
";",
"}",
"return",
"client",
".",
"build",
"(",
")",
";",
"}"
] | Creates an OkHttpClient optionally enabling TLS
@param enableTLS Whether TLS should be enabled
@return a valid OkHttpClient | [
"Creates",
"an",
"OkHttpClient",
"optionally",
"enabling",
"TLS"
] | d00777a5fc59f34471be338c814ea85ddcbde304 | https://github.com/romannurik/muzei/blob/d00777a5fc59f34471be338c814ea85ddcbde304/main/src/main/java/com/google/android/apps/muzei/sources/OkHttpClientFactory.java#L49-L58 |
23,280 | romannurik/muzei | main/src/main/java/com/google/android/apps/muzei/sources/OkHttpClientFactory.java | OkHttpClientFactory.enableTls12 | private static OkHttpClient.Builder enableTls12(OkHttpClient.Builder client) {
try {
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init((KeyStore) null);
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
throw new IllegalStateException("Unexpected default trust managers:"
+ Arrays.toString(trustManagers));
}
X509TrustManager trustManager = (X509TrustManager) trustManagers[0];
client.sslSocketFactory(new TLSSocketFactory(), trustManager);
ConnectionSpec cs = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.tlsVersions(TlsVersion.TLS_1_2, TlsVersion.TLS_1_1)
.build();
List<ConnectionSpec> specs = new ArrayList<>();
specs.add(cs);
specs.add(ConnectionSpec.COMPATIBLE_TLS);
specs.add(ConnectionSpec.CLEARTEXT);
client.connectionSpecs(specs);
} catch (Exception exc) {
Log.e(TAG, "Error while setting TLS", exc);
}
return client;
} | java | private static OkHttpClient.Builder enableTls12(OkHttpClient.Builder client) {
try {
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init((KeyStore) null);
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
throw new IllegalStateException("Unexpected default trust managers:"
+ Arrays.toString(trustManagers));
}
X509TrustManager trustManager = (X509TrustManager) trustManagers[0];
client.sslSocketFactory(new TLSSocketFactory(), trustManager);
ConnectionSpec cs = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.tlsVersions(TlsVersion.TLS_1_2, TlsVersion.TLS_1_1)
.build();
List<ConnectionSpec> specs = new ArrayList<>();
specs.add(cs);
specs.add(ConnectionSpec.COMPATIBLE_TLS);
specs.add(ConnectionSpec.CLEARTEXT);
client.connectionSpecs(specs);
} catch (Exception exc) {
Log.e(TAG, "Error while setting TLS", exc);
}
return client;
} | [
"private",
"static",
"OkHttpClient",
".",
"Builder",
"enableTls12",
"(",
"OkHttpClient",
".",
"Builder",
"client",
")",
"{",
"try",
"{",
"TrustManagerFactory",
"trustManagerFactory",
"=",
"TrustManagerFactory",
".",
"getInstance",
"(",
"TrustManagerFactory",
".",
"getDefaultAlgorithm",
"(",
")",
")",
";",
"trustManagerFactory",
".",
"init",
"(",
"(",
"KeyStore",
")",
"null",
")",
";",
"TrustManager",
"[",
"]",
"trustManagers",
"=",
"trustManagerFactory",
".",
"getTrustManagers",
"(",
")",
";",
"if",
"(",
"trustManagers",
".",
"length",
"!=",
"1",
"||",
"!",
"(",
"trustManagers",
"[",
"0",
"]",
"instanceof",
"X509TrustManager",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unexpected default trust managers:\"",
"+",
"Arrays",
".",
"toString",
"(",
"trustManagers",
")",
")",
";",
"}",
"X509TrustManager",
"trustManager",
"=",
"(",
"X509TrustManager",
")",
"trustManagers",
"[",
"0",
"]",
";",
"client",
".",
"sslSocketFactory",
"(",
"new",
"TLSSocketFactory",
"(",
")",
",",
"trustManager",
")",
";",
"ConnectionSpec",
"cs",
"=",
"new",
"ConnectionSpec",
".",
"Builder",
"(",
"ConnectionSpec",
".",
"MODERN_TLS",
")",
".",
"tlsVersions",
"(",
"TlsVersion",
".",
"TLS_1_2",
",",
"TlsVersion",
".",
"TLS_1_1",
")",
".",
"build",
"(",
")",
";",
"List",
"<",
"ConnectionSpec",
">",
"specs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"specs",
".",
"add",
"(",
"cs",
")",
";",
"specs",
".",
"add",
"(",
"ConnectionSpec",
".",
"COMPATIBLE_TLS",
")",
";",
"specs",
".",
"add",
"(",
"ConnectionSpec",
".",
"CLEARTEXT",
")",
";",
"client",
".",
"connectionSpecs",
"(",
"specs",
")",
";",
"}",
"catch",
"(",
"Exception",
"exc",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Error while setting TLS\"",
",",
"exc",
")",
";",
"}",
"return",
"client",
";",
"}"
] | Enable TLS on the OKHttp builder by setting a custom SocketFactory
@param client the client to enable TLS
@return an OkhttpClient.Builder with TLS enabled | [
"Enable",
"TLS",
"on",
"the",
"OKHttp",
"builder",
"by",
"setting",
"a",
"custom",
"SocketFactory"
] | d00777a5fc59f34471be338c814ea85ddcbde304 | https://github.com/romannurik/muzei/blob/d00777a5fc59f34471be338c814ea85ddcbde304/main/src/main/java/com/google/android/apps/muzei/sources/OkHttpClientFactory.java#L81-L105 |
23,281 | romannurik/muzei | gl-wallpaper/src/main/java/net/rbgrn/android/glwallpaperservice/GLWallpaperService.java | EglHelper.start | public void start() {
// Log.d("EglHelper" + instanceId, "start()");
if (mEgl == null) {
// Log.d("EglHelper" + instanceId, "getting new EGL");
/*
* Get an EGL instance
*/
mEgl = (EGL10) EGLContext.getEGL();
} else {
// Log.d("EglHelper" + instanceId, "reusing EGL");
}
if (mEglDisplay == null) {
// Log.d("EglHelper" + instanceId, "getting new display");
/*
* Get to the default display.
*/
mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
} else {
// Log.d("EglHelper" + instanceId, "reusing display");
}
if (mEglConfig == null) {
// Log.d("EglHelper" + instanceId, "getting new config");
/*
* We can now initialize EGL for that display
*/
int[] version = new int[2];
mEgl.eglInitialize(mEglDisplay, version);
mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);
} else {
// Log.d("EglHelper" + instanceId, "reusing config");
}
if (mEglContext == null) {
// Log.d("EglHelper" + instanceId, "creating new context");
/*
* Create an OpenGL ES context. This must be done only once, an OpenGL context is a somewhat heavy object.
*/
mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
throw new RuntimeException("createContext failed");
}
} else {
// Log.d("EglHelper" + instanceId, "reusing context");
}
mEglSurface = null;
} | java | public void start() {
// Log.d("EglHelper" + instanceId, "start()");
if (mEgl == null) {
// Log.d("EglHelper" + instanceId, "getting new EGL");
/*
* Get an EGL instance
*/
mEgl = (EGL10) EGLContext.getEGL();
} else {
// Log.d("EglHelper" + instanceId, "reusing EGL");
}
if (mEglDisplay == null) {
// Log.d("EglHelper" + instanceId, "getting new display");
/*
* Get to the default display.
*/
mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
} else {
// Log.d("EglHelper" + instanceId, "reusing display");
}
if (mEglConfig == null) {
// Log.d("EglHelper" + instanceId, "getting new config");
/*
* We can now initialize EGL for that display
*/
int[] version = new int[2];
mEgl.eglInitialize(mEglDisplay, version);
mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);
} else {
// Log.d("EglHelper" + instanceId, "reusing config");
}
if (mEglContext == null) {
// Log.d("EglHelper" + instanceId, "creating new context");
/*
* Create an OpenGL ES context. This must be done only once, an OpenGL context is a somewhat heavy object.
*/
mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
throw new RuntimeException("createContext failed");
}
} else {
// Log.d("EglHelper" + instanceId, "reusing context");
}
mEglSurface = null;
} | [
"public",
"void",
"start",
"(",
")",
"{",
"// Log.d(\"EglHelper\" + instanceId, \"start()\");",
"if",
"(",
"mEgl",
"==",
"null",
")",
"{",
"// Log.d(\"EglHelper\" + instanceId, \"getting new EGL\");",
"/*\n * Get an EGL instance\n */",
"mEgl",
"=",
"(",
"EGL10",
")",
"EGLContext",
".",
"getEGL",
"(",
")",
";",
"}",
"else",
"{",
"// Log.d(\"EglHelper\" + instanceId, \"reusing EGL\");",
"}",
"if",
"(",
"mEglDisplay",
"==",
"null",
")",
"{",
"// Log.d(\"EglHelper\" + instanceId, \"getting new display\");",
"/*\n * Get to the default display.\n */",
"mEglDisplay",
"=",
"mEgl",
".",
"eglGetDisplay",
"(",
"EGL10",
".",
"EGL_DEFAULT_DISPLAY",
")",
";",
"}",
"else",
"{",
"// Log.d(\"EglHelper\" + instanceId, \"reusing display\");",
"}",
"if",
"(",
"mEglConfig",
"==",
"null",
")",
"{",
"// Log.d(\"EglHelper\" + instanceId, \"getting new config\");",
"/*\n * We can now initialize EGL for that display\n */",
"int",
"[",
"]",
"version",
"=",
"new",
"int",
"[",
"2",
"]",
";",
"mEgl",
".",
"eglInitialize",
"(",
"mEglDisplay",
",",
"version",
")",
";",
"mEglConfig",
"=",
"mEGLConfigChooser",
".",
"chooseConfig",
"(",
"mEgl",
",",
"mEglDisplay",
")",
";",
"}",
"else",
"{",
"// Log.d(\"EglHelper\" + instanceId, \"reusing config\");",
"}",
"if",
"(",
"mEglContext",
"==",
"null",
")",
"{",
"// Log.d(\"EglHelper\" + instanceId, \"creating new context\");",
"/*\n * Create an OpenGL ES context. This must be done only once, an OpenGL context is a somewhat heavy object.\n */",
"mEglContext",
"=",
"mEGLContextFactory",
".",
"createContext",
"(",
"mEgl",
",",
"mEglDisplay",
",",
"mEglConfig",
")",
";",
"if",
"(",
"mEglContext",
"==",
"null",
"||",
"mEglContext",
"==",
"EGL10",
".",
"EGL_NO_CONTEXT",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"createContext failed\"",
")",
";",
"}",
"}",
"else",
"{",
"// Log.d(\"EglHelper\" + instanceId, \"reusing context\");",
"}",
"mEglSurface",
"=",
"null",
";",
"}"
] | Initialize EGL for a given configuration spec.
@param configSpec | [
"Initialize",
"EGL",
"for",
"a",
"given",
"configuration",
"spec",
"."
] | d00777a5fc59f34471be338c814ea85ddcbde304 | https://github.com/romannurik/muzei/blob/d00777a5fc59f34471be338c814ea85ddcbde304/gl-wallpaper/src/main/java/net/rbgrn/android/glwallpaperservice/GLWallpaperService.java#L347-L395 |
23,282 | romannurik/muzei | gl-wallpaper/src/main/java/net/rbgrn/android/glwallpaperservice/GLWallpaperService.java | GLThread.queueEvent | public void queueEvent(Runnable r) {
synchronized (this) {
mEventQueue.add(r);
synchronized (sGLThreadManager) {
mEventsWaiting = true;
sGLThreadManager.notifyAll();
}
}
} | java | public void queueEvent(Runnable r) {
synchronized (this) {
mEventQueue.add(r);
synchronized (sGLThreadManager) {
mEventsWaiting = true;
sGLThreadManager.notifyAll();
}
}
} | [
"public",
"void",
"queueEvent",
"(",
"Runnable",
"r",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"mEventQueue",
".",
"add",
"(",
"r",
")",
";",
"synchronized",
"(",
"sGLThreadManager",
")",
"{",
"mEventsWaiting",
"=",
"true",
";",
"sGLThreadManager",
".",
"notifyAll",
"(",
")",
";",
"}",
"}",
"}"
] | Queue an "event" to be run on the GL rendering thread.
@param r
the runnable to be run on the GL rendering thread. | [
"Queue",
"an",
"event",
"to",
"be",
"run",
"on",
"the",
"GL",
"rendering",
"thread",
"."
] | d00777a5fc59f34471be338c814ea85ddcbde304 | https://github.com/romannurik/muzei/blob/d00777a5fc59f34471be338c814ea85ddcbde304/gl-wallpaper/src/main/java/net/rbgrn/android/glwallpaperservice/GLWallpaperService.java#L795-L803 |
23,283 | romannurik/muzei | muzei-api/src/main/java/com/google/android/apps/muzei/api/UserCommand.java | UserCommand.deserialize | public static UserCommand deserialize(String serialized) {
int id = -1;
if (TextUtils.isEmpty(serialized)) {
return new UserCommand(id, null);
}
String[] arr = serialized.split(":", 2);
try {
id = Integer.parseInt(arr[0]);
} catch (NumberFormatException ignored) {
}
String title = null;
if (arr.length > 1) {
title = arr[1];
}
return new UserCommand(id, title);
} | java | public static UserCommand deserialize(String serialized) {
int id = -1;
if (TextUtils.isEmpty(serialized)) {
return new UserCommand(id, null);
}
String[] arr = serialized.split(":", 2);
try {
id = Integer.parseInt(arr[0]);
} catch (NumberFormatException ignored) {
}
String title = null;
if (arr.length > 1) {
title = arr[1];
}
return new UserCommand(id, title);
} | [
"public",
"static",
"UserCommand",
"deserialize",
"(",
"String",
"serialized",
")",
"{",
"int",
"id",
"=",
"-",
"1",
";",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"serialized",
")",
")",
"{",
"return",
"new",
"UserCommand",
"(",
"id",
",",
"null",
")",
";",
"}",
"String",
"[",
"]",
"arr",
"=",
"serialized",
".",
"split",
"(",
"\":\"",
",",
"2",
")",
";",
"try",
"{",
"id",
"=",
"Integer",
".",
"parseInt",
"(",
"arr",
"[",
"0",
"]",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"ignored",
")",
"{",
"}",
"String",
"title",
"=",
"null",
";",
"if",
"(",
"arr",
".",
"length",
">",
"1",
")",
"{",
"title",
"=",
"arr",
"[",
"1",
"]",
";",
"}",
"return",
"new",
"UserCommand",
"(",
"id",
",",
"title",
")",
";",
"}"
] | Deserializes a user command from the given string.
@param serialized the string generated by {@link #serialize} to deserialize.
@return the deserialized {@link UserCommand} from the given string. | [
"Deserializes",
"a",
"user",
"command",
"from",
"the",
"given",
"string",
"."
] | d00777a5fc59f34471be338c814ea85ddcbde304 | https://github.com/romannurik/muzei/blob/d00777a5fc59f34471be338c814ea85ddcbde304/muzei-api/src/main/java/com/google/android/apps/muzei/api/UserCommand.java#L111-L129 |
23,284 | romannurik/muzei | muzei-api/src/main/java/com/google/android/apps/muzei/api/provider/MuzeiArtProvider.java | MuzeiArtProvider.buildAllArtworkColumnProjectionMap | private static HashMap<String, String> buildAllArtworkColumnProjectionMap() {
final HashMap<String, String> allColumnProjectionMap = new HashMap<>();
allColumnProjectionMap.put(BaseColumns._ID, BaseColumns._ID);
allColumnProjectionMap.put(ProviderContract.Artwork.TOKEN,
ProviderContract.Artwork.TOKEN);
allColumnProjectionMap.put(ProviderContract.Artwork.TITLE,
ProviderContract.Artwork.TITLE);
allColumnProjectionMap.put(ProviderContract.Artwork.BYLINE,
ProviderContract.Artwork.BYLINE);
allColumnProjectionMap.put(ProviderContract.Artwork.ATTRIBUTION,
ProviderContract.Artwork.ATTRIBUTION);
allColumnProjectionMap.put(ProviderContract.Artwork.PERSISTENT_URI,
ProviderContract.Artwork.PERSISTENT_URI);
allColumnProjectionMap.put(ProviderContract.Artwork.WEB_URI,
ProviderContract.Artwork.WEB_URI);
allColumnProjectionMap.put(ProviderContract.Artwork.METADATA,
ProviderContract.Artwork.METADATA);
allColumnProjectionMap.put(ProviderContract.Artwork.DATA,
ProviderContract.Artwork.DATA);
allColumnProjectionMap.put(ProviderContract.Artwork.DATE_ADDED,
ProviderContract.Artwork.DATE_ADDED);
allColumnProjectionMap.put(ProviderContract.Artwork.DATE_MODIFIED,
ProviderContract.Artwork.DATE_MODIFIED);
return allColumnProjectionMap;
} | java | private static HashMap<String, String> buildAllArtworkColumnProjectionMap() {
final HashMap<String, String> allColumnProjectionMap = new HashMap<>();
allColumnProjectionMap.put(BaseColumns._ID, BaseColumns._ID);
allColumnProjectionMap.put(ProviderContract.Artwork.TOKEN,
ProviderContract.Artwork.TOKEN);
allColumnProjectionMap.put(ProviderContract.Artwork.TITLE,
ProviderContract.Artwork.TITLE);
allColumnProjectionMap.put(ProviderContract.Artwork.BYLINE,
ProviderContract.Artwork.BYLINE);
allColumnProjectionMap.put(ProviderContract.Artwork.ATTRIBUTION,
ProviderContract.Artwork.ATTRIBUTION);
allColumnProjectionMap.put(ProviderContract.Artwork.PERSISTENT_URI,
ProviderContract.Artwork.PERSISTENT_URI);
allColumnProjectionMap.put(ProviderContract.Artwork.WEB_URI,
ProviderContract.Artwork.WEB_URI);
allColumnProjectionMap.put(ProviderContract.Artwork.METADATA,
ProviderContract.Artwork.METADATA);
allColumnProjectionMap.put(ProviderContract.Artwork.DATA,
ProviderContract.Artwork.DATA);
allColumnProjectionMap.put(ProviderContract.Artwork.DATE_ADDED,
ProviderContract.Artwork.DATE_ADDED);
allColumnProjectionMap.put(ProviderContract.Artwork.DATE_MODIFIED,
ProviderContract.Artwork.DATE_MODIFIED);
return allColumnProjectionMap;
} | [
"private",
"static",
"HashMap",
"<",
"String",
",",
"String",
">",
"buildAllArtworkColumnProjectionMap",
"(",
")",
"{",
"final",
"HashMap",
"<",
"String",
",",
"String",
">",
"allColumnProjectionMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"BaseColumns",
".",
"_ID",
",",
"BaseColumns",
".",
"_ID",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"TOKEN",
",",
"ProviderContract",
".",
"Artwork",
".",
"TOKEN",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"TITLE",
",",
"ProviderContract",
".",
"Artwork",
".",
"TITLE",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"BYLINE",
",",
"ProviderContract",
".",
"Artwork",
".",
"BYLINE",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"ATTRIBUTION",
",",
"ProviderContract",
".",
"Artwork",
".",
"ATTRIBUTION",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"PERSISTENT_URI",
",",
"ProviderContract",
".",
"Artwork",
".",
"PERSISTENT_URI",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"WEB_URI",
",",
"ProviderContract",
".",
"Artwork",
".",
"WEB_URI",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"METADATA",
",",
"ProviderContract",
".",
"Artwork",
".",
"METADATA",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"DATA",
",",
"ProviderContract",
".",
"Artwork",
".",
"DATA",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"DATE_ADDED",
",",
"ProviderContract",
".",
"Artwork",
".",
"DATE_ADDED",
")",
";",
"allColumnProjectionMap",
".",
"put",
"(",
"ProviderContract",
".",
"Artwork",
".",
"DATE_MODIFIED",
",",
"ProviderContract",
".",
"Artwork",
".",
"DATE_MODIFIED",
")",
";",
"return",
"allColumnProjectionMap",
";",
"}"
] | Creates and initializes a column project for all columns for artwork
@return The all column projection map for artwork | [
"Creates",
"and",
"initializes",
"a",
"column",
"project",
"for",
"all",
"columns",
"for",
"artwork"
] | d00777a5fc59f34471be338c814ea85ddcbde304 | https://github.com/romannurik/muzei/blob/d00777a5fc59f34471be338c814ea85ddcbde304/muzei-api/src/main/java/com/google/android/apps/muzei/api/provider/MuzeiArtProvider.java#L237-L261 |
23,285 | romannurik/muzei | muzei-api/src/main/java/com/google/android/apps/muzei/api/MuzeiArtSource.java | MuzeiArtSource.removeAllUserCommands | protected final void removeAllUserCommands() {
mCurrentState.setUserCommands((int[]) null);
mServiceHandler.removeCallbacks(mPublishStateRunnable);
mServiceHandler.post(mPublishStateRunnable);
} | java | protected final void removeAllUserCommands() {
mCurrentState.setUserCommands((int[]) null);
mServiceHandler.removeCallbacks(mPublishStateRunnable);
mServiceHandler.post(mPublishStateRunnable);
} | [
"protected",
"final",
"void",
"removeAllUserCommands",
"(",
")",
"{",
"mCurrentState",
".",
"setUserCommands",
"(",
"(",
"int",
"[",
"]",
")",
"null",
")",
";",
"mServiceHandler",
".",
"removeCallbacks",
"(",
"mPublishStateRunnable",
")",
";",
"mServiceHandler",
".",
"post",
"(",
"mPublishStateRunnable",
")",
";",
"}"
] | Clears the list of available user commands.
@see #setUserCommands(UserCommand...) | [
"Clears",
"the",
"list",
"of",
"available",
"user",
"commands",
"."
] | d00777a5fc59f34471be338c814ea85ddcbde304 | https://github.com/romannurik/muzei/blob/d00777a5fc59f34471be338c814ea85ddcbde304/muzei-api/src/main/java/com/google/android/apps/muzei/api/MuzeiArtSource.java#L564-L568 |
23,286 | borball/weixin-sdk | weixin-pay/src/main/java/com/riversoft/weixin/pay/payment/Payments.java | Payments.checkSignature | public boolean checkSignature(PaymentNotification notification) {
SortedMap<String, Object> notificationMap = JsonMapper.nonEmptyMapper().getMapper().convertValue(notification, SortedMap.class);
notificationMap.putAll(notification.getOthers());
notificationMap.remove("sign");
return notification.getSign().equals(SignatureUtil.sign(notificationMap, paySetting.getKey()));
} | java | public boolean checkSignature(PaymentNotification notification) {
SortedMap<String, Object> notificationMap = JsonMapper.nonEmptyMapper().getMapper().convertValue(notification, SortedMap.class);
notificationMap.putAll(notification.getOthers());
notificationMap.remove("sign");
return notification.getSign().equals(SignatureUtil.sign(notificationMap, paySetting.getKey()));
} | [
"public",
"boolean",
"checkSignature",
"(",
"PaymentNotification",
"notification",
")",
"{",
"SortedMap",
"<",
"String",
",",
"Object",
">",
"notificationMap",
"=",
"JsonMapper",
".",
"nonEmptyMapper",
"(",
")",
".",
"getMapper",
"(",
")",
".",
"convertValue",
"(",
"notification",
",",
"SortedMap",
".",
"class",
")",
";",
"notificationMap",
".",
"putAll",
"(",
"notification",
".",
"getOthers",
"(",
")",
")",
";",
"notificationMap",
".",
"remove",
"(",
"\"sign\"",
")",
";",
"return",
"notification",
".",
"getSign",
"(",
")",
".",
"equals",
"(",
"SignatureUtil",
".",
"sign",
"(",
"notificationMap",
",",
"paySetting",
".",
"getKey",
"(",
")",
")",
")",
";",
"}"
] | check if sign is valid
@param notification
@return | [
"check",
"if",
"sign",
"is",
"valid"
] | 32bf5e45cdd8d0d28074e83954e1ec62dcf25cb7 | https://github.com/borball/weixin-sdk/blob/32bf5e45cdd8d0d28074e83954e1ec62dcf25cb7/weixin-pay/src/main/java/com/riversoft/weixin/pay/payment/Payments.java#L142-L147 |
23,287 | Netflix/EVCache | evcache-client/src/main/java/com/netflix/evcache/util/ZoneFallbackIterator.java | ZoneFallbackIterator.next | public String next() {
if (entry == null) return null;
entry = entry.next;
return entry.element;
} | java | public String next() {
if (entry == null) return null;
entry = entry.next;
return entry.element;
} | [
"public",
"String",
"next",
"(",
")",
"{",
"if",
"(",
"entry",
"==",
"null",
")",
"return",
"null",
";",
"entry",
"=",
"entry",
".",
"next",
";",
"return",
"entry",
".",
"element",
";",
"}"
] | Returns the next zone from the set which should get the request.
@return - the next zone in the iterator. If there are none then null is
returned. | [
"Returns",
"the",
"next",
"zone",
"from",
"the",
"set",
"which",
"should",
"get",
"the",
"request",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client/src/main/java/com/netflix/evcache/util/ZoneFallbackIterator.java#L63-L67 |
23,288 | Netflix/EVCache | evcache-client/src/main/java/com/netflix/evcache/util/ZoneFallbackIterator.java | ZoneFallbackIterator.next | public String next(String ignoreZone) {
if (entry == null) return null;
entry = entry.next;
if (entry.element.equals(ignoreZone)) {
return entry.next.element;
} else {
return entry.element;
}
} | java | public String next(String ignoreZone) {
if (entry == null) return null;
entry = entry.next;
if (entry.element.equals(ignoreZone)) {
return entry.next.element;
} else {
return entry.element;
}
} | [
"public",
"String",
"next",
"(",
"String",
"ignoreZone",
")",
"{",
"if",
"(",
"entry",
"==",
"null",
")",
"return",
"null",
";",
"entry",
"=",
"entry",
".",
"next",
";",
"if",
"(",
"entry",
".",
"element",
".",
"equals",
"(",
"ignoreZone",
")",
")",
"{",
"return",
"entry",
".",
"next",
".",
"element",
";",
"}",
"else",
"{",
"return",
"entry",
".",
"element",
";",
"}",
"}"
] | Returns the next zone from the set excluding the given zone which should
get the request.
@return - the next zone in the iterator. If there are none then null is
returned. | [
"Returns",
"the",
"next",
"zone",
"from",
"the",
"set",
"excluding",
"the",
"given",
"zone",
"which",
"should",
"get",
"the",
"request",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client/src/main/java/com/netflix/evcache/util/ZoneFallbackIterator.java#L76-L84 |
23,289 | Netflix/EVCache | evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheKetamaNodeLocatorConfiguration.java | EVCacheKetamaNodeLocatorConfiguration.getSocketAddressForNode | @Override
protected String getSocketAddressForNode(MemcachedNode node) {
String result = socketAddresses.get(node);
if(result == null) {
final SocketAddress socketAddress = node.getSocketAddress();
if(socketAddress instanceof InetSocketAddress) {
final InetSocketAddress isa = (InetSocketAddress)socketAddress;
if(poolManager.getDiscoveryClient() != null ) {
final DiscoveryClient mgr = poolManager.getDiscoveryClient();
final Application app = mgr.getApplication(appId);
if(app != null) {
final List<InstanceInfo> instances = app.getInstances();
for(InstanceInfo info : instances) {
final String hostName = info.getHostName();
if(hostName.equalsIgnoreCase(isa.getHostName())) {
final String ip = info.getIPAddr();
String port = info.getMetadata().get("evcache.port");
if(port == null) port = "11211";
result = hostName + '/' + ip + ':' + port;
break;
}
}
} else {
result = ((InetSocketAddress)socketAddress).getHostName() + '/' + ((InetSocketAddress)socketAddress).getAddress().getHostAddress() + ":11211";
}
} else {
result = ((InetSocketAddress)socketAddress).getHostName() + '/' + ((InetSocketAddress)socketAddress).getAddress().getHostAddress() + ":11211";
}
} else {
result=String.valueOf(socketAddress);
if (result.startsWith("/")) {
result = result.substring(1);
}
}
socketAddresses.put(node, result);
}
return result;
} | java | @Override
protected String getSocketAddressForNode(MemcachedNode node) {
String result = socketAddresses.get(node);
if(result == null) {
final SocketAddress socketAddress = node.getSocketAddress();
if(socketAddress instanceof InetSocketAddress) {
final InetSocketAddress isa = (InetSocketAddress)socketAddress;
if(poolManager.getDiscoveryClient() != null ) {
final DiscoveryClient mgr = poolManager.getDiscoveryClient();
final Application app = mgr.getApplication(appId);
if(app != null) {
final List<InstanceInfo> instances = app.getInstances();
for(InstanceInfo info : instances) {
final String hostName = info.getHostName();
if(hostName.equalsIgnoreCase(isa.getHostName())) {
final String ip = info.getIPAddr();
String port = info.getMetadata().get("evcache.port");
if(port == null) port = "11211";
result = hostName + '/' + ip + ':' + port;
break;
}
}
} else {
result = ((InetSocketAddress)socketAddress).getHostName() + '/' + ((InetSocketAddress)socketAddress).getAddress().getHostAddress() + ":11211";
}
} else {
result = ((InetSocketAddress)socketAddress).getHostName() + '/' + ((InetSocketAddress)socketAddress).getAddress().getHostAddress() + ":11211";
}
} else {
result=String.valueOf(socketAddress);
if (result.startsWith("/")) {
result = result.substring(1);
}
}
socketAddresses.put(node, result);
}
return result;
} | [
"@",
"Override",
"protected",
"String",
"getSocketAddressForNode",
"(",
"MemcachedNode",
"node",
")",
"{",
"String",
"result",
"=",
"socketAddresses",
".",
"get",
"(",
"node",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"final",
"SocketAddress",
"socketAddress",
"=",
"node",
".",
"getSocketAddress",
"(",
")",
";",
"if",
"(",
"socketAddress",
"instanceof",
"InetSocketAddress",
")",
"{",
"final",
"InetSocketAddress",
"isa",
"=",
"(",
"InetSocketAddress",
")",
"socketAddress",
";",
"if",
"(",
"poolManager",
".",
"getDiscoveryClient",
"(",
")",
"!=",
"null",
")",
"{",
"final",
"DiscoveryClient",
"mgr",
"=",
"poolManager",
".",
"getDiscoveryClient",
"(",
")",
";",
"final",
"Application",
"app",
"=",
"mgr",
".",
"getApplication",
"(",
"appId",
")",
";",
"if",
"(",
"app",
"!=",
"null",
")",
"{",
"final",
"List",
"<",
"InstanceInfo",
">",
"instances",
"=",
"app",
".",
"getInstances",
"(",
")",
";",
"for",
"(",
"InstanceInfo",
"info",
":",
"instances",
")",
"{",
"final",
"String",
"hostName",
"=",
"info",
".",
"getHostName",
"(",
")",
";",
"if",
"(",
"hostName",
".",
"equalsIgnoreCase",
"(",
"isa",
".",
"getHostName",
"(",
")",
")",
")",
"{",
"final",
"String",
"ip",
"=",
"info",
".",
"getIPAddr",
"(",
")",
";",
"String",
"port",
"=",
"info",
".",
"getMetadata",
"(",
")",
".",
"get",
"(",
"\"evcache.port\"",
")",
";",
"if",
"(",
"port",
"==",
"null",
")",
"port",
"=",
"\"11211\"",
";",
"result",
"=",
"hostName",
"+",
"'",
"'",
"+",
"ip",
"+",
"'",
"'",
"+",
"port",
";",
"break",
";",
"}",
"}",
"}",
"else",
"{",
"result",
"=",
"(",
"(",
"InetSocketAddress",
")",
"socketAddress",
")",
".",
"getHostName",
"(",
")",
"+",
"'",
"'",
"+",
"(",
"(",
"InetSocketAddress",
")",
"socketAddress",
")",
".",
"getAddress",
"(",
")",
".",
"getHostAddress",
"(",
")",
"+",
"\":11211\"",
";",
"}",
"}",
"else",
"{",
"result",
"=",
"(",
"(",
"InetSocketAddress",
")",
"socketAddress",
")",
".",
"getHostName",
"(",
")",
"+",
"'",
"'",
"+",
"(",
"(",
"InetSocketAddress",
")",
"socketAddress",
")",
".",
"getAddress",
"(",
")",
".",
"getHostAddress",
"(",
")",
"+",
"\":11211\"",
";",
"}",
"}",
"else",
"{",
"result",
"=",
"String",
".",
"valueOf",
"(",
"socketAddress",
")",
";",
"if",
"(",
"result",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"result",
"=",
"result",
".",
"substring",
"(",
"1",
")",
";",
"}",
"}",
"socketAddresses",
".",
"put",
"(",
"node",
",",
"result",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Returns the socket address of a given MemcachedNode.
@param node - The MemcachedNode which we're interested in
@return The socket address of the given node format is of the following
format "publicHostname/privateIp:port" (ex -
ec2-174-129-159-31.compute-1.amazonaws.com/10.125.47.114:11211) | [
"Returns",
"the",
"socket",
"address",
"of",
"a",
"given",
"MemcachedNode",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheKetamaNodeLocatorConfiguration.java#L49-L86 |
23,290 | Netflix/EVCache | evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheClientPoolManager.java | EVCacheClientPoolManager.initEVCache | public final synchronized void initEVCache(String app) {
if (app == null || (app = app.trim()).length() == 0) throw new IllegalArgumentException(
"param app name null or space");
final String APP = getAppName(app);
if (poolMap.containsKey(APP)) return;
final EVCacheNodeList provider;
if (EVCacheConfig.getInstance().getChainedBooleanProperty(APP + ".use.simple.node.list.provider", "evcache.use.simple.node.list.provider", Boolean.FALSE, null).get()) {
provider = new SimpleNodeListProvider();
} else {
provider = new DiscoveryNodeListProvider(applicationInfoManager, discoveryClient, APP);
}
final EVCacheClientPool pool = new EVCacheClientPool(APP, provider, asyncExecutor, this);
scheduleRefresh(pool);
poolMap.put(APP, pool);
} | java | public final synchronized void initEVCache(String app) {
if (app == null || (app = app.trim()).length() == 0) throw new IllegalArgumentException(
"param app name null or space");
final String APP = getAppName(app);
if (poolMap.containsKey(APP)) return;
final EVCacheNodeList provider;
if (EVCacheConfig.getInstance().getChainedBooleanProperty(APP + ".use.simple.node.list.provider", "evcache.use.simple.node.list.provider", Boolean.FALSE, null).get()) {
provider = new SimpleNodeListProvider();
} else {
provider = new DiscoveryNodeListProvider(applicationInfoManager, discoveryClient, APP);
}
final EVCacheClientPool pool = new EVCacheClientPool(APP, provider, asyncExecutor, this);
scheduleRefresh(pool);
poolMap.put(APP, pool);
} | [
"public",
"final",
"synchronized",
"void",
"initEVCache",
"(",
"String",
"app",
")",
"{",
"if",
"(",
"app",
"==",
"null",
"||",
"(",
"app",
"=",
"app",
".",
"trim",
"(",
")",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"param app name null or space\"",
")",
";",
"final",
"String",
"APP",
"=",
"getAppName",
"(",
"app",
")",
";",
"if",
"(",
"poolMap",
".",
"containsKey",
"(",
"APP",
")",
")",
"return",
";",
"final",
"EVCacheNodeList",
"provider",
";",
"if",
"(",
"EVCacheConfig",
".",
"getInstance",
"(",
")",
".",
"getChainedBooleanProperty",
"(",
"APP",
"+",
"\".use.simple.node.list.provider\"",
",",
"\"evcache.use.simple.node.list.provider\"",
",",
"Boolean",
".",
"FALSE",
",",
"null",
")",
".",
"get",
"(",
")",
")",
"{",
"provider",
"=",
"new",
"SimpleNodeListProvider",
"(",
")",
";",
"}",
"else",
"{",
"provider",
"=",
"new",
"DiscoveryNodeListProvider",
"(",
"applicationInfoManager",
",",
"discoveryClient",
",",
"APP",
")",
";",
"}",
"final",
"EVCacheClientPool",
"pool",
"=",
"new",
"EVCacheClientPool",
"(",
"APP",
",",
"provider",
",",
"asyncExecutor",
",",
"this",
")",
";",
"scheduleRefresh",
"(",
"pool",
")",
";",
"poolMap",
".",
"put",
"(",
"APP",
",",
"pool",
")",
";",
"}"
] | Will init the given EVCache app call. If one is already initialized for
the given app method returns without doing anything.
@param app
- name of the evcache app | [
"Will",
"init",
"the",
"given",
"EVCache",
"app",
"call",
".",
"If",
"one",
"is",
"already",
"initialized",
"for",
"the",
"given",
"app",
"method",
"returns",
"without",
"doing",
"anything",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheClientPoolManager.java#L170-L185 |
23,291 | Netflix/EVCache | evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheClientPoolManager.java | EVCacheClientPoolManager.getEVCacheClientPool | public EVCacheClientPool getEVCacheClientPool(String _app) {
final String app = getAppName(_app);
final EVCacheClientPool evcacheClientPool = poolMap.get(app);
if (evcacheClientPool != null) return evcacheClientPool;
initEVCache(app);
return poolMap.get(app);
} | java | public EVCacheClientPool getEVCacheClientPool(String _app) {
final String app = getAppName(_app);
final EVCacheClientPool evcacheClientPool = poolMap.get(app);
if (evcacheClientPool != null) return evcacheClientPool;
initEVCache(app);
return poolMap.get(app);
} | [
"public",
"EVCacheClientPool",
"getEVCacheClientPool",
"(",
"String",
"_app",
")",
"{",
"final",
"String",
"app",
"=",
"getAppName",
"(",
"_app",
")",
";",
"final",
"EVCacheClientPool",
"evcacheClientPool",
"=",
"poolMap",
".",
"get",
"(",
"app",
")",
";",
"if",
"(",
"evcacheClientPool",
"!=",
"null",
")",
"return",
"evcacheClientPool",
";",
"initEVCache",
"(",
"app",
")",
";",
"return",
"poolMap",
".",
"get",
"(",
"app",
")",
";",
"}"
] | Given the appName get the EVCacheClientPool. If the app is already
created then will return the existing instance. If not one will be
created and returned.
@param _app
- name of the evcache app
@return the Pool for the give app.
@throws IOException | [
"Given",
"the",
"appName",
"get",
"the",
"EVCacheClientPool",
".",
"If",
"the",
"app",
"is",
"already",
"created",
"then",
"will",
"return",
"the",
"existing",
"instance",
".",
"If",
"not",
"one",
"will",
"be",
"created",
"and",
"returned",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheClientPoolManager.java#L202-L208 |
23,292 | Netflix/EVCache | evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheClientPool.java | EVCacheClientPool.updateMemcachedReadInstancesByZone | private void updateMemcachedReadInstancesByZone() {
for (ServerGroup serverGroup : memcachedInstancesByServerGroup.keySet()) {
final BooleanProperty isZoneInWriteOnlyMode = writeOnlyFastPropertyMap.get(serverGroup);
if (isZoneInWriteOnlyMode.get().booleanValue()) {
if (memcachedReadInstancesByServerGroup.containsKey(serverGroup)) {
EVCacheMetricsFactory.increment(_appName, null, serverGroup.getName(), _appName + "-" + serverGroup.getName() + "-WRITE_ONLY");
memcachedReadInstancesByServerGroup.remove(serverGroup);
}
} else {
if (!memcachedReadInstancesByServerGroup.containsKey(serverGroup)) {
EVCacheMetricsFactory.increment(_appName, null, serverGroup.getName(), _appName + "-" + serverGroup.getName() + "-READ_ENABLED");
memcachedReadInstancesByServerGroup.put(serverGroup, memcachedInstancesByServerGroup.get(serverGroup));
}
}
// if we lose over 50% of instances put that zone in writeonly mode.
final List<EVCacheClient> clients = memcachedReadInstancesByServerGroup.get(serverGroup);
if (clients != null && !clients.isEmpty()) {
final EVCacheClient client = clients.get(0);
if (client != null) {
final EVCacheConnectionObserver connectionObserver = client.getConnectionObserver();
if (connectionObserver != null) {
final int activeServerCount = connectionObserver.getActiveServerCount();
final int inActiveServerCount = connectionObserver.getInActiveServerCount();
if (inActiveServerCount > activeServerCount) {
memcachedReadInstancesByServerGroup.remove(serverGroup);
}
}
}
}
}
if (memcachedReadInstancesByServerGroup.size() != memcachedFallbackReadInstances.getSize()) {
memcachedFallbackReadInstances = new ServerGroupCircularIterator(memcachedReadInstancesByServerGroup.keySet());
Map<String, Set<ServerGroup>> readServerGroupByZoneMap = new ConcurrentHashMap<String, Set<ServerGroup>>();
for (ServerGroup serverGroup : memcachedReadInstancesByServerGroup.keySet()) {
Set<ServerGroup> serverGroupList = readServerGroupByZoneMap.get(serverGroup.getZone());
if (serverGroupList == null) {
serverGroupList = new HashSet<ServerGroup>();
readServerGroupByZoneMap.put(serverGroup.getZone(), serverGroupList);
}
serverGroupList.add(serverGroup);
}
Map<String, ServerGroupCircularIterator> _readServerGroupByZone = new ConcurrentHashMap<String, ServerGroupCircularIterator>();
for (Entry<String, Set<ServerGroup>> readServerGroupByZoneEntry : readServerGroupByZoneMap.entrySet()) {
_readServerGroupByZone.put(readServerGroupByZoneEntry.getKey(), new ServerGroupCircularIterator(
readServerGroupByZoneEntry.getValue()));
}
this.readServerGroupByZone = _readServerGroupByZone;
localServerGroupIterator = readServerGroupByZone.get(_zone);
}
} | java | private void updateMemcachedReadInstancesByZone() {
for (ServerGroup serverGroup : memcachedInstancesByServerGroup.keySet()) {
final BooleanProperty isZoneInWriteOnlyMode = writeOnlyFastPropertyMap.get(serverGroup);
if (isZoneInWriteOnlyMode.get().booleanValue()) {
if (memcachedReadInstancesByServerGroup.containsKey(serverGroup)) {
EVCacheMetricsFactory.increment(_appName, null, serverGroup.getName(), _appName + "-" + serverGroup.getName() + "-WRITE_ONLY");
memcachedReadInstancesByServerGroup.remove(serverGroup);
}
} else {
if (!memcachedReadInstancesByServerGroup.containsKey(serverGroup)) {
EVCacheMetricsFactory.increment(_appName, null, serverGroup.getName(), _appName + "-" + serverGroup.getName() + "-READ_ENABLED");
memcachedReadInstancesByServerGroup.put(serverGroup, memcachedInstancesByServerGroup.get(serverGroup));
}
}
// if we lose over 50% of instances put that zone in writeonly mode.
final List<EVCacheClient> clients = memcachedReadInstancesByServerGroup.get(serverGroup);
if (clients != null && !clients.isEmpty()) {
final EVCacheClient client = clients.get(0);
if (client != null) {
final EVCacheConnectionObserver connectionObserver = client.getConnectionObserver();
if (connectionObserver != null) {
final int activeServerCount = connectionObserver.getActiveServerCount();
final int inActiveServerCount = connectionObserver.getInActiveServerCount();
if (inActiveServerCount > activeServerCount) {
memcachedReadInstancesByServerGroup.remove(serverGroup);
}
}
}
}
}
if (memcachedReadInstancesByServerGroup.size() != memcachedFallbackReadInstances.getSize()) {
memcachedFallbackReadInstances = new ServerGroupCircularIterator(memcachedReadInstancesByServerGroup.keySet());
Map<String, Set<ServerGroup>> readServerGroupByZoneMap = new ConcurrentHashMap<String, Set<ServerGroup>>();
for (ServerGroup serverGroup : memcachedReadInstancesByServerGroup.keySet()) {
Set<ServerGroup> serverGroupList = readServerGroupByZoneMap.get(serverGroup.getZone());
if (serverGroupList == null) {
serverGroupList = new HashSet<ServerGroup>();
readServerGroupByZoneMap.put(serverGroup.getZone(), serverGroupList);
}
serverGroupList.add(serverGroup);
}
Map<String, ServerGroupCircularIterator> _readServerGroupByZone = new ConcurrentHashMap<String, ServerGroupCircularIterator>();
for (Entry<String, Set<ServerGroup>> readServerGroupByZoneEntry : readServerGroupByZoneMap.entrySet()) {
_readServerGroupByZone.put(readServerGroupByZoneEntry.getKey(), new ServerGroupCircularIterator(
readServerGroupByZoneEntry.getValue()));
}
this.readServerGroupByZone = _readServerGroupByZone;
localServerGroupIterator = readServerGroupByZone.get(_zone);
}
} | [
"private",
"void",
"updateMemcachedReadInstancesByZone",
"(",
")",
"{",
"for",
"(",
"ServerGroup",
"serverGroup",
":",
"memcachedInstancesByServerGroup",
".",
"keySet",
"(",
")",
")",
"{",
"final",
"BooleanProperty",
"isZoneInWriteOnlyMode",
"=",
"writeOnlyFastPropertyMap",
".",
"get",
"(",
"serverGroup",
")",
";",
"if",
"(",
"isZoneInWriteOnlyMode",
".",
"get",
"(",
")",
".",
"booleanValue",
"(",
")",
")",
"{",
"if",
"(",
"memcachedReadInstancesByServerGroup",
".",
"containsKey",
"(",
"serverGroup",
")",
")",
"{",
"EVCacheMetricsFactory",
".",
"increment",
"(",
"_appName",
",",
"null",
",",
"serverGroup",
".",
"getName",
"(",
")",
",",
"_appName",
"+",
"\"-\"",
"+",
"serverGroup",
".",
"getName",
"(",
")",
"+",
"\"-WRITE_ONLY\"",
")",
";",
"memcachedReadInstancesByServerGroup",
".",
"remove",
"(",
"serverGroup",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"memcachedReadInstancesByServerGroup",
".",
"containsKey",
"(",
"serverGroup",
")",
")",
"{",
"EVCacheMetricsFactory",
".",
"increment",
"(",
"_appName",
",",
"null",
",",
"serverGroup",
".",
"getName",
"(",
")",
",",
"_appName",
"+",
"\"-\"",
"+",
"serverGroup",
".",
"getName",
"(",
")",
"+",
"\"-READ_ENABLED\"",
")",
";",
"memcachedReadInstancesByServerGroup",
".",
"put",
"(",
"serverGroup",
",",
"memcachedInstancesByServerGroup",
".",
"get",
"(",
"serverGroup",
")",
")",
";",
"}",
"}",
"// if we lose over 50% of instances put that zone in writeonly mode.",
"final",
"List",
"<",
"EVCacheClient",
">",
"clients",
"=",
"memcachedReadInstancesByServerGroup",
".",
"get",
"(",
"serverGroup",
")",
";",
"if",
"(",
"clients",
"!=",
"null",
"&&",
"!",
"clients",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"EVCacheClient",
"client",
"=",
"clients",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"client",
"!=",
"null",
")",
"{",
"final",
"EVCacheConnectionObserver",
"connectionObserver",
"=",
"client",
".",
"getConnectionObserver",
"(",
")",
";",
"if",
"(",
"connectionObserver",
"!=",
"null",
")",
"{",
"final",
"int",
"activeServerCount",
"=",
"connectionObserver",
".",
"getActiveServerCount",
"(",
")",
";",
"final",
"int",
"inActiveServerCount",
"=",
"connectionObserver",
".",
"getInActiveServerCount",
"(",
")",
";",
"if",
"(",
"inActiveServerCount",
">",
"activeServerCount",
")",
"{",
"memcachedReadInstancesByServerGroup",
".",
"remove",
"(",
"serverGroup",
")",
";",
"}",
"}",
"}",
"}",
"}",
"if",
"(",
"memcachedReadInstancesByServerGroup",
".",
"size",
"(",
")",
"!=",
"memcachedFallbackReadInstances",
".",
"getSize",
"(",
")",
")",
"{",
"memcachedFallbackReadInstances",
"=",
"new",
"ServerGroupCircularIterator",
"(",
"memcachedReadInstancesByServerGroup",
".",
"keySet",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"Set",
"<",
"ServerGroup",
">",
">",
"readServerGroupByZoneMap",
"=",
"new",
"ConcurrentHashMap",
"<",
"String",
",",
"Set",
"<",
"ServerGroup",
">",
">",
"(",
")",
";",
"for",
"(",
"ServerGroup",
"serverGroup",
":",
"memcachedReadInstancesByServerGroup",
".",
"keySet",
"(",
")",
")",
"{",
"Set",
"<",
"ServerGroup",
">",
"serverGroupList",
"=",
"readServerGroupByZoneMap",
".",
"get",
"(",
"serverGroup",
".",
"getZone",
"(",
")",
")",
";",
"if",
"(",
"serverGroupList",
"==",
"null",
")",
"{",
"serverGroupList",
"=",
"new",
"HashSet",
"<",
"ServerGroup",
">",
"(",
")",
";",
"readServerGroupByZoneMap",
".",
"put",
"(",
"serverGroup",
".",
"getZone",
"(",
")",
",",
"serverGroupList",
")",
";",
"}",
"serverGroupList",
".",
"add",
"(",
"serverGroup",
")",
";",
"}",
"Map",
"<",
"String",
",",
"ServerGroupCircularIterator",
">",
"_readServerGroupByZone",
"=",
"new",
"ConcurrentHashMap",
"<",
"String",
",",
"ServerGroupCircularIterator",
">",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Set",
"<",
"ServerGroup",
">",
">",
"readServerGroupByZoneEntry",
":",
"readServerGroupByZoneMap",
".",
"entrySet",
"(",
")",
")",
"{",
"_readServerGroupByZone",
".",
"put",
"(",
"readServerGroupByZoneEntry",
".",
"getKey",
"(",
")",
",",
"new",
"ServerGroupCircularIterator",
"(",
"readServerGroupByZoneEntry",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"this",
".",
"readServerGroupByZone",
"=",
"_readServerGroupByZone",
";",
"localServerGroupIterator",
"=",
"readServerGroupByZone",
".",
"get",
"(",
"_zone",
")",
";",
"}",
"}"
] | back to the read map. | [
"back",
"to",
"the",
"read",
"map",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheClientPool.java#L650-L703 |
23,293 | Netflix/EVCache | evcache-client/src/main/java/com/netflix/evcache/pool/SimpleNodeListProvider.java | SimpleNodeListProvider.discoverInstances | @Override
public Map<ServerGroup, EVCacheServerGroupConfig> discoverInstances(String appName) throws IOException {
final String propertyName = appName + "-NODES";
final String nodeListString = EVCacheConfig.getInstance().getDynamicStringProperty(propertyName, "").get();
if (log.isDebugEnabled()) log.debug("List of Nodes = " + nodeListString);
if(nodeListString != null && nodeListString.length() > 0) return bootstrapFromSystemProperty(nodeListString);
if(env != null && region != null) return bootstrapFromEureka(appName);
return Collections.<ServerGroup, EVCacheServerGroupConfig> emptyMap();
} | java | @Override
public Map<ServerGroup, EVCacheServerGroupConfig> discoverInstances(String appName) throws IOException {
final String propertyName = appName + "-NODES";
final String nodeListString = EVCacheConfig.getInstance().getDynamicStringProperty(propertyName, "").get();
if (log.isDebugEnabled()) log.debug("List of Nodes = " + nodeListString);
if(nodeListString != null && nodeListString.length() > 0) return bootstrapFromSystemProperty(nodeListString);
if(env != null && region != null) return bootstrapFromEureka(appName);
return Collections.<ServerGroup, EVCacheServerGroupConfig> emptyMap();
} | [
"@",
"Override",
"public",
"Map",
"<",
"ServerGroup",
",",
"EVCacheServerGroupConfig",
">",
"discoverInstances",
"(",
"String",
"appName",
")",
"throws",
"IOException",
"{",
"final",
"String",
"propertyName",
"=",
"appName",
"+",
"\"-NODES\"",
";",
"final",
"String",
"nodeListString",
"=",
"EVCacheConfig",
".",
"getInstance",
"(",
")",
".",
"getDynamicStringProperty",
"(",
"propertyName",
",",
"\"\"",
")",
".",
"get",
"(",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"List of Nodes = \"",
"+",
"nodeListString",
")",
";",
"if",
"(",
"nodeListString",
"!=",
"null",
"&&",
"nodeListString",
".",
"length",
"(",
")",
">",
"0",
")",
"return",
"bootstrapFromSystemProperty",
"(",
"nodeListString",
")",
";",
"if",
"(",
"env",
"!=",
"null",
"&&",
"region",
"!=",
"null",
")",
"return",
"bootstrapFromEureka",
"(",
"appName",
")",
";",
"return",
"Collections",
".",
"<",
"ServerGroup",
",",
"EVCacheServerGroupConfig",
">",
"emptyMap",
"(",
")",
";",
"}"
] | Pass a System Property of format
<EVCACHE_APP>-NODES=setname0=instance01:port,instance02:port,
instance03:port;setname1=instance11:port,instance12:port,instance13:port;
setname2=instance21:port,instance22:port,instance23:port | [
"Pass",
"a",
"System",
"Property",
"of",
"format"
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client/src/main/java/com/netflix/evcache/pool/SimpleNodeListProvider.java#L76-L86 |
23,294 | Netflix/EVCache | evcache-client-sample/src/main/java/com/netflix/evcache/sample/EVCacheClientSample.java | EVCacheClientSample.setKey | public void setKey(String key, String value, int timeToLive) throws Exception {
try {
Future<Boolean>[] _future = evCache.set(key, value, timeToLive);
// Wait for all the Futures to complete.
// In "verbose" mode, show the status for each.
for (Future<Boolean> f : _future) {
boolean didSucceed = f.get();
if (verboseMode) {
System.out.println("per-shard set success code for key " + key + " is " + didSucceed);
}
}
if (!verboseMode) {
// Not verbose. Just give one line of output per "set," without a success code
System.out.println("finished setting key " + key);
}
} catch (EVCacheException e) {
e.printStackTrace();
}
} | java | public void setKey(String key, String value, int timeToLive) throws Exception {
try {
Future<Boolean>[] _future = evCache.set(key, value, timeToLive);
// Wait for all the Futures to complete.
// In "verbose" mode, show the status for each.
for (Future<Boolean> f : _future) {
boolean didSucceed = f.get();
if (verboseMode) {
System.out.println("per-shard set success code for key " + key + " is " + didSucceed);
}
}
if (!verboseMode) {
// Not verbose. Just give one line of output per "set," without a success code
System.out.println("finished setting key " + key);
}
} catch (EVCacheException e) {
e.printStackTrace();
}
} | [
"public",
"void",
"setKey",
"(",
"String",
"key",
",",
"String",
"value",
",",
"int",
"timeToLive",
")",
"throws",
"Exception",
"{",
"try",
"{",
"Future",
"<",
"Boolean",
">",
"[",
"]",
"_future",
"=",
"evCache",
".",
"set",
"(",
"key",
",",
"value",
",",
"timeToLive",
")",
";",
"// Wait for all the Futures to complete.",
"// In \"verbose\" mode, show the status for each.",
"for",
"(",
"Future",
"<",
"Boolean",
">",
"f",
":",
"_future",
")",
"{",
"boolean",
"didSucceed",
"=",
"f",
".",
"get",
"(",
")",
";",
"if",
"(",
"verboseMode",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"per-shard set success code for key \"",
"+",
"key",
"+",
"\" is \"",
"+",
"didSucceed",
")",
";",
"}",
"}",
"if",
"(",
"!",
"verboseMode",
")",
"{",
"// Not verbose. Just give one line of output per \"set,\" without a success code",
"System",
".",
"out",
".",
"println",
"(",
"\"finished setting key \"",
"+",
"key",
")",
";",
"}",
"}",
"catch",
"(",
"EVCacheException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | Set a key in the cache.
See the memcached documentation for what "timeToLive" means.
Zero means "never expires."
Small integers (under some threshold) mean "expires this many seconds from now."
Large integers mean "expires at this Unix timestamp" (seconds since 1/1/1970).
Warranty expires 17-Jan 2038. | [
"Set",
"a",
"key",
"in",
"the",
"cache",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client-sample/src/main/java/com/netflix/evcache/sample/EVCacheClientSample.java#L72-L91 |
23,295 | Netflix/EVCache | evcache-client-sample/src/main/java/com/netflix/evcache/sample/EVCacheClientSample.java | EVCacheClientSample.getKey | public String getKey(String key) {
try {
String _response = evCache.<String>get(key);
return _response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
} | java | public String getKey(String key) {
try {
String _response = evCache.<String>get(key);
return _response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
} | [
"public",
"String",
"getKey",
"(",
"String",
"key",
")",
"{",
"try",
"{",
"String",
"_response",
"=",
"evCache",
".",
"<",
"String",
">",
"get",
"(",
"key",
")",
";",
"return",
"_response",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Get the data for a key from the cache. Returns null if the key
could not be retrieved, whether due to a cache miss or errors. | [
"Get",
"the",
"data",
"for",
"a",
"key",
"from",
"the",
"cache",
".",
"Returns",
"null",
"if",
"the",
"key",
"could",
"not",
"be",
"retrieved",
"whether",
"due",
"to",
"a",
"cache",
"miss",
"or",
"errors",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client-sample/src/main/java/com/netflix/evcache/sample/EVCacheClientSample.java#L98-L106 |
23,296 | Netflix/EVCache | evcache-client-sample/src/main/java/com/netflix/evcache/sample/EVCacheClientSample.java | EVCacheClientSample.main | public static void main(String[] args) {
// set verboseMode based on the environment variable
verboseMode = ("true".equals(System.getenv("EVCACHE_SAMPLE_VERBOSE")));
if (verboseMode) {
System.out.println("To run this sample app without using Gradle:");
System.out.println("java -cp " + System.getProperty("java.class.path") + " com.netflix.evcache.sample.EVCacheClientSample");
}
try {
EVCacheClientSample evCacheClientSample = new EVCacheClientSample();
// Set ten keys to different values
for (int i = 0; i < 10; i++) {
String key = "key_" + i;
String value = "data_" + i;
// Set the TTL to 24 hours
int ttl = 86400;
evCacheClientSample.setKey(key, value, ttl);
}
// Do a "get" for each of those same keys
for (int i = 0; i < 10; i++) {
String key = "key_" + i;
String value = evCacheClientSample.getKey(key);
System.out.println("Get of " + key + " returned " + value);
}
} catch (Exception e) {
e.printStackTrace();
}
// We have to call System.exit() now, because some background
// threads were started without the "daemon" flag. This is
// probably a mistake somewhere, but hey, this is only a sample app.
System.exit(0);
} | java | public static void main(String[] args) {
// set verboseMode based on the environment variable
verboseMode = ("true".equals(System.getenv("EVCACHE_SAMPLE_VERBOSE")));
if (verboseMode) {
System.out.println("To run this sample app without using Gradle:");
System.out.println("java -cp " + System.getProperty("java.class.path") + " com.netflix.evcache.sample.EVCacheClientSample");
}
try {
EVCacheClientSample evCacheClientSample = new EVCacheClientSample();
// Set ten keys to different values
for (int i = 0; i < 10; i++) {
String key = "key_" + i;
String value = "data_" + i;
// Set the TTL to 24 hours
int ttl = 86400;
evCacheClientSample.setKey(key, value, ttl);
}
// Do a "get" for each of those same keys
for (int i = 0; i < 10; i++) {
String key = "key_" + i;
String value = evCacheClientSample.getKey(key);
System.out.println("Get of " + key + " returned " + value);
}
} catch (Exception e) {
e.printStackTrace();
}
// We have to call System.exit() now, because some background
// threads were started without the "daemon" flag. This is
// probably a mistake somewhere, but hey, this is only a sample app.
System.exit(0);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"// set verboseMode based on the environment variable",
"verboseMode",
"=",
"(",
"\"true\"",
".",
"equals",
"(",
"System",
".",
"getenv",
"(",
"\"EVCACHE_SAMPLE_VERBOSE\"",
")",
")",
")",
";",
"if",
"(",
"verboseMode",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"To run this sample app without using Gradle:\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"java -cp \"",
"+",
"System",
".",
"getProperty",
"(",
"\"java.class.path\"",
")",
"+",
"\" com.netflix.evcache.sample.EVCacheClientSample\"",
")",
";",
"}",
"try",
"{",
"EVCacheClientSample",
"evCacheClientSample",
"=",
"new",
"EVCacheClientSample",
"(",
")",
";",
"// Set ten keys to different values",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"String",
"key",
"=",
"\"key_\"",
"+",
"i",
";",
"String",
"value",
"=",
"\"data_\"",
"+",
"i",
";",
"// Set the TTL to 24 hours",
"int",
"ttl",
"=",
"86400",
";",
"evCacheClientSample",
".",
"setKey",
"(",
"key",
",",
"value",
",",
"ttl",
")",
";",
"}",
"// Do a \"get\" for each of those same keys",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"String",
"key",
"=",
"\"key_\"",
"+",
"i",
";",
"String",
"value",
"=",
"evCacheClientSample",
".",
"getKey",
"(",
"key",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Get of \"",
"+",
"key",
"+",
"\" returned \"",
"+",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// We have to call System.exit() now, because some background",
"// threads were started without the \"daemon\" flag. This is",
"// probably a mistake somewhere, but hey, this is only a sample app.",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}"
] | Main Program which does some simple sets and gets. | [
"Main",
"Program",
"which",
"does",
"some",
"simple",
"sets",
"and",
"gets",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client-sample/src/main/java/com/netflix/evcache/sample/EVCacheClientSample.java#L112-L147 |
23,297 | Netflix/EVCache | evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheClient.java | EVCacheClient.getAllChunks | public Map<String, CachedData> getAllChunks(String key) throws EVCacheReadQueueException, EVCacheException, Exception {
try {
final ChunkDetails<Object> cd = getChunkDetails(key);
if(log.isDebugEnabled()) log.debug("Chunkdetails " + cd);
if (cd == null) return null;
if (!cd.isChunked()) {
Map<String, CachedData> rv = new HashMap<String, CachedData>();
rv.put(key, (CachedData) cd.getData());
if(log.isDebugEnabled()) log.debug("Data : " + rv);
return rv;
} else {
final List<String> keys = cd.getChunkKeys();
if(log.isDebugEnabled()) log.debug("Keys - " + keys);
final Map<String, CachedData> dataMap = evcacheMemcachedClient.asyncGetBulk(keys, chunkingTranscoder, null, "GetAllChunksOperation")
.getSome(readTimeout.get().intValue(), TimeUnit.MILLISECONDS, false, false);
if(log.isDebugEnabled()) log.debug("Datamap " + dataMap);
return dataMap;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return null;
} | java | public Map<String, CachedData> getAllChunks(String key) throws EVCacheReadQueueException, EVCacheException, Exception {
try {
final ChunkDetails<Object> cd = getChunkDetails(key);
if(log.isDebugEnabled()) log.debug("Chunkdetails " + cd);
if (cd == null) return null;
if (!cd.isChunked()) {
Map<String, CachedData> rv = new HashMap<String, CachedData>();
rv.put(key, (CachedData) cd.getData());
if(log.isDebugEnabled()) log.debug("Data : " + rv);
return rv;
} else {
final List<String> keys = cd.getChunkKeys();
if(log.isDebugEnabled()) log.debug("Keys - " + keys);
final Map<String, CachedData> dataMap = evcacheMemcachedClient.asyncGetBulk(keys, chunkingTranscoder, null, "GetAllChunksOperation")
.getSome(readTimeout.get().intValue(), TimeUnit.MILLISECONDS, false, false);
if(log.isDebugEnabled()) log.debug("Datamap " + dataMap);
return dataMap;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return null;
} | [
"public",
"Map",
"<",
"String",
",",
"CachedData",
">",
"getAllChunks",
"(",
"String",
"key",
")",
"throws",
"EVCacheReadQueueException",
",",
"EVCacheException",
",",
"Exception",
"{",
"try",
"{",
"final",
"ChunkDetails",
"<",
"Object",
">",
"cd",
"=",
"getChunkDetails",
"(",
"key",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"Chunkdetails \"",
"+",
"cd",
")",
";",
"if",
"(",
"cd",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"!",
"cd",
".",
"isChunked",
"(",
")",
")",
"{",
"Map",
"<",
"String",
",",
"CachedData",
">",
"rv",
"=",
"new",
"HashMap",
"<",
"String",
",",
"CachedData",
">",
"(",
")",
";",
"rv",
".",
"put",
"(",
"key",
",",
"(",
"CachedData",
")",
"cd",
".",
"getData",
"(",
")",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"Data : \"",
"+",
"rv",
")",
";",
"return",
"rv",
";",
"}",
"else",
"{",
"final",
"List",
"<",
"String",
">",
"keys",
"=",
"cd",
".",
"getChunkKeys",
"(",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"Keys - \"",
"+",
"keys",
")",
";",
"final",
"Map",
"<",
"String",
",",
"CachedData",
">",
"dataMap",
"=",
"evcacheMemcachedClient",
".",
"asyncGetBulk",
"(",
"keys",
",",
"chunkingTranscoder",
",",
"null",
",",
"\"GetAllChunksOperation\"",
")",
".",
"getSome",
"(",
"readTimeout",
".",
"get",
"(",
")",
".",
"intValue",
"(",
")",
",",
"TimeUnit",
".",
"MILLISECONDS",
",",
"false",
",",
"false",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"Datamap \"",
"+",
"dataMap",
")",
";",
"return",
"dataMap",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Retrieves all the chunks as is. This is mainly used for debugging.
@param key
@return Returns all the chunks retrieved.
@throws EVCacheReadQueueException
@throws EVCacheException
@throws Exception | [
"Retrieves",
"all",
"the",
"chunks",
"as",
"is",
".",
"This",
"is",
"mainly",
"used",
"for",
"debugging",
"."
] | f46fdc22c8c52e0e06316c9889439d580c1d38a6 | https://github.com/Netflix/EVCache/blob/f46fdc22c8c52e0e06316c9889439d580c1d38a6/evcache-client/src/main/java/com/netflix/evcache/pool/EVCacheClient.java#L743-L766 |
23,298 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/VersionMessage.java | VersionMessage.isBloomFilteringSupported | public boolean isBloomFilteringSupported() {
if (clientVersion >= params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.BLOOM_FILTER)
&& clientVersion < params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.BLOOM_FILTER_BIP111))
return true;
if ((localServices & NODE_BLOOM) == NODE_BLOOM)
return true;
return false;
} | java | public boolean isBloomFilteringSupported() {
if (clientVersion >= params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.BLOOM_FILTER)
&& clientVersion < params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.BLOOM_FILTER_BIP111))
return true;
if ((localServices & NODE_BLOOM) == NODE_BLOOM)
return true;
return false;
} | [
"public",
"boolean",
"isBloomFilteringSupported",
"(",
")",
"{",
"if",
"(",
"clientVersion",
">=",
"params",
".",
"getProtocolVersionNum",
"(",
"NetworkParameters",
".",
"ProtocolVersion",
".",
"BLOOM_FILTER",
")",
"&&",
"clientVersion",
"<",
"params",
".",
"getProtocolVersionNum",
"(",
"NetworkParameters",
".",
"ProtocolVersion",
".",
"BLOOM_FILTER_BIP111",
")",
")",
"return",
"true",
";",
"if",
"(",
"(",
"localServices",
"&",
"NODE_BLOOM",
")",
"==",
"NODE_BLOOM",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Returns true if the peer supports bloom filtering according to BIP37 and BIP111. | [
"Returns",
"true",
"if",
"the",
"peer",
"supports",
"bloom",
"filtering",
"according",
"to",
"BIP37",
"and",
"BIP111",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/VersionMessage.java#L280-L287 |
23,299 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/utils/ExchangeRate.java | ExchangeRate.coinToFiat | public Fiat coinToFiat(Coin convertCoin) {
// Use BigInteger because it's much easier to maintain full precision without overflowing.
final BigInteger converted = BigInteger.valueOf(convertCoin.value).multiply(BigInteger.valueOf(fiat.value))
.divide(BigInteger.valueOf(coin.value));
if (converted.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0
|| converted.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0)
throw new ArithmeticException("Overflow");
return Fiat.valueOf(fiat.currencyCode, converted.longValue());
} | java | public Fiat coinToFiat(Coin convertCoin) {
// Use BigInteger because it's much easier to maintain full precision without overflowing.
final BigInteger converted = BigInteger.valueOf(convertCoin.value).multiply(BigInteger.valueOf(fiat.value))
.divide(BigInteger.valueOf(coin.value));
if (converted.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0
|| converted.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0)
throw new ArithmeticException("Overflow");
return Fiat.valueOf(fiat.currencyCode, converted.longValue());
} | [
"public",
"Fiat",
"coinToFiat",
"(",
"Coin",
"convertCoin",
")",
"{",
"// Use BigInteger because it's much easier to maintain full precision without overflowing.",
"final",
"BigInteger",
"converted",
"=",
"BigInteger",
".",
"valueOf",
"(",
"convertCoin",
".",
"value",
")",
".",
"multiply",
"(",
"BigInteger",
".",
"valueOf",
"(",
"fiat",
".",
"value",
")",
")",
".",
"divide",
"(",
"BigInteger",
".",
"valueOf",
"(",
"coin",
".",
"value",
")",
")",
";",
"if",
"(",
"converted",
".",
"compareTo",
"(",
"BigInteger",
".",
"valueOf",
"(",
"Long",
".",
"MAX_VALUE",
")",
")",
">",
"0",
"||",
"converted",
".",
"compareTo",
"(",
"BigInteger",
".",
"valueOf",
"(",
"Long",
".",
"MIN_VALUE",
")",
")",
"<",
"0",
")",
"throw",
"new",
"ArithmeticException",
"(",
"\"Overflow\"",
")",
";",
"return",
"Fiat",
".",
"valueOf",
"(",
"fiat",
".",
"currencyCode",
",",
"converted",
".",
"longValue",
"(",
")",
")",
";",
"}"
] | Convert a coin amount to a fiat amount using this exchange rate.
@throws ArithmeticException if the converted fiat amount is too high or too low. | [
"Convert",
"a",
"coin",
"amount",
"to",
"a",
"fiat",
"amount",
"using",
"this",
"exchange",
"rate",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java#L54-L62 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.