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
32,400
mikepenz/FastAdapter
app/src/main/java/com/mikepenz/fastadapter/app/items/RealmSampleUserItem.java
RealmSampleUserItem.generateView
@Override public View generateView(Context ctx, ViewGroup parent) { ViewHolder viewHolder = getViewHolder(LayoutInflater.from(ctx).inflate(getLayoutRes(), parent, false)); //as we already know the type of our ViewHolder cast it to our type bindView(viewHolder, Collections.EMPTY_LIST); //return the bound and generatedView return viewHolder.itemView; }
java
@Override public View generateView(Context ctx, ViewGroup parent) { ViewHolder viewHolder = getViewHolder(LayoutInflater.from(ctx).inflate(getLayoutRes(), parent, false)); //as we already know the type of our ViewHolder cast it to our type bindView(viewHolder, Collections.EMPTY_LIST); //return the bound and generatedView return viewHolder.itemView; }
[ "@", "Override", "public", "View", "generateView", "(", "Context", "ctx", ",", "ViewGroup", "parent", ")", "{", "ViewHolder", "viewHolder", "=", "getViewHolder", "(", "LayoutInflater", ".", "from", "(", "ctx", ")", ".", "inflate", "(", "getLayoutRes", "(", "...
generates a view by the defined LayoutRes and pass the LayoutParams from the parent @param ctx @param parent @return
[ "generates", "a", "view", "by", "the", "defined", "LayoutRes", "and", "pass", "the", "LayoutParams", "from", "the", "parent" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/app/src/main/java/com/mikepenz/fastadapter/app/items/RealmSampleUserItem.java#L202-L210
32,401
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/ActionModeHelper.java
ActionModeHelper.onClick
public Boolean onClick(AppCompatActivity act, IItem item) { //if we are current in CAB mode, and we remove the last selection, we want to finish the actionMode if (mActionMode != null && (mSelectExtension.getSelectedItems().size() == 1) && item.isSelected()) { mActionMode.finish(); mSelectExtension.deselect(); return true; } if (mActionMode != null) { // calculate the selection count for the action mode // because current selection is not reflecting the future state yet! int selected = mSelectExtension.getSelectedItems().size(); if (item.isSelected()) selected--; else if (item.isSelectable()) selected++; checkActionMode(act, selected); } return null; }
java
public Boolean onClick(AppCompatActivity act, IItem item) { //if we are current in CAB mode, and we remove the last selection, we want to finish the actionMode if (mActionMode != null && (mSelectExtension.getSelectedItems().size() == 1) && item.isSelected()) { mActionMode.finish(); mSelectExtension.deselect(); return true; } if (mActionMode != null) { // calculate the selection count for the action mode // because current selection is not reflecting the future state yet! int selected = mSelectExtension.getSelectedItems().size(); if (item.isSelected()) selected--; else if (item.isSelectable()) selected++; checkActionMode(act, selected); } return null; }
[ "public", "Boolean", "onClick", "(", "AppCompatActivity", "act", ",", "IItem", "item", ")", "{", "//if we are current in CAB mode, and we remove the last selection, we want to finish the actionMode", "if", "(", "mActionMode", "!=", "null", "&&", "(", "mSelectExtension", ".", ...
implements the basic behavior of a CAB and multi select behavior, including logics if the clicked item is collapsible @param act the current Activity @param item the current item @return null if nothing was done, or a boolean to inform if the event was consumed
[ "implements", "the", "basic", "behavior", "of", "a", "CAB", "and", "multi", "select", "behavior", "including", "logics", "if", "the", "clicked", "item", "is", "collapsible" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/ActionModeHelper.java#L117-L137
32,402
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/ActionModeHelper.java
ActionModeHelper.onLongClick
public ActionMode onLongClick(AppCompatActivity act, int position) { if (mActionMode == null && mFastAdapter.getItem(position).isSelectable()) { //may check if actionMode is already displayed mActionMode = act.startSupportActionMode(mInternalCallback); //we have to select this on our own as we will consume the event mSelectExtension.select(position); // update title checkActionMode(act, 1); //we consume this event so the normal onClick isn't called anymore return mActionMode; } return mActionMode; }
java
public ActionMode onLongClick(AppCompatActivity act, int position) { if (mActionMode == null && mFastAdapter.getItem(position).isSelectable()) { //may check if actionMode is already displayed mActionMode = act.startSupportActionMode(mInternalCallback); //we have to select this on our own as we will consume the event mSelectExtension.select(position); // update title checkActionMode(act, 1); //we consume this event so the normal onClick isn't called anymore return mActionMode; } return mActionMode; }
[ "public", "ActionMode", "onLongClick", "(", "AppCompatActivity", "act", ",", "int", "position", ")", "{", "if", "(", "mActionMode", "==", "null", "&&", "mFastAdapter", ".", "getItem", "(", "position", ")", ".", "isSelectable", "(", ")", ")", "{", "//may chec...
implements the basic behavior of a CAB and multi select behavior onLongClick @param act the current Activity @param position the position of the clicked item @return the initialized ActionMode or null if nothing was done
[ "implements", "the", "basic", "behavior", "of", "a", "CAB", "and", "multi", "select", "behavior", "onLongClick" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/ActionModeHelper.java#L146-L158
32,403
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/ActionModeHelper.java
ActionModeHelper.checkActionMode
public ActionMode checkActionMode(AppCompatActivity act) { int selected = mSelectExtension.getSelectedItems().size(); return checkActionMode(act, selected); }
java
public ActionMode checkActionMode(AppCompatActivity act) { int selected = mSelectExtension.getSelectedItems().size(); return checkActionMode(act, selected); }
[ "public", "ActionMode", "checkActionMode", "(", "AppCompatActivity", "act", ")", "{", "int", "selected", "=", "mSelectExtension", ".", "getSelectedItems", "(", ")", ".", "size", "(", ")", ";", "return", "checkActionMode", "(", "act", ",", "selected", ")", ";",...
check if the ActionMode should be shown or not depending on the currently selected items Additionally, it will also update the title in the CAB for you @param act the current Activity @return the initialized ActionMode or null if no ActionMode is active after calling this function
[ "check", "if", "the", "ActionMode", "should", "be", "shown", "or", "not", "depending", "on", "the", "currently", "selected", "items", "Additionally", "it", "will", "also", "update", "the", "title", "in", "the", "CAB", "for", "you" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/ActionModeHelper.java#L167-L170
32,404
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/ActionModeHelper.java
ActionModeHelper.updateTitle
private void updateTitle(int selected) { if (mActionMode != null) { if (mTitleProvider != null) mActionMode.setTitle(mTitleProvider.getTitle(selected)); else mActionMode.setTitle(String.valueOf(selected)); } }
java
private void updateTitle(int selected) { if (mActionMode != null) { if (mTitleProvider != null) mActionMode.setTitle(mTitleProvider.getTitle(selected)); else mActionMode.setTitle(String.valueOf(selected)); } }
[ "private", "void", "updateTitle", "(", "int", "selected", ")", "{", "if", "(", "mActionMode", "!=", "null", ")", "{", "if", "(", "mTitleProvider", "!=", "null", ")", "mActionMode", ".", "setTitle", "(", "mTitleProvider", ".", "getTitle", "(", "selected", "...
updates the title to reflect the current selected items or to show a user defined title @param selected number of selected items
[ "updates", "the", "title", "to", "reflect", "the", "current", "selected", "items", "or", "to", "show", "a", "user", "defined", "title" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/ActionModeHelper.java#L201-L208
32,405
mikepenz/FastAdapter
library-extensions-expandable/src/main/java/com/mikepenz/fastadapter/utils/AdapterUtil.java
AdapterUtil.restoreSubItemSelectionStatesForAlternativeStateManagement
public static <Item extends IItem> void restoreSubItemSelectionStatesForAlternativeStateManagement(Item item, List<String> selectedItems) { if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) { List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems(); for (int i = 0, size = subItems.size(); i < size; i++) { Item subItem = subItems.get(i); String id = String.valueOf(subItem.getIdentifier()); if (selectedItems != null && selectedItems.contains(id)) { subItem.withSetSelected(true); } restoreSubItemSelectionStatesForAlternativeStateManagement(subItem, selectedItems); } } }
java
public static <Item extends IItem> void restoreSubItemSelectionStatesForAlternativeStateManagement(Item item, List<String> selectedItems) { if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) { List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems(); for (int i = 0, size = subItems.size(); i < size; i++) { Item subItem = subItems.get(i); String id = String.valueOf(subItem.getIdentifier()); if (selectedItems != null && selectedItems.contains(id)) { subItem.withSetSelected(true); } restoreSubItemSelectionStatesForAlternativeStateManagement(subItem, selectedItems); } } }
[ "public", "static", "<", "Item", "extends", "IItem", ">", "void", "restoreSubItemSelectionStatesForAlternativeStateManagement", "(", "Item", "item", ",", "List", "<", "String", ">", "selectedItems", ")", "{", "if", "(", "item", "instanceof", "IExpandable", "&&", "...
internal method to restore the selection state of subItems @param item the parent item @param selectedItems the list of selectedItems from the savedInstanceState
[ "internal", "method", "to", "restore", "the", "selection", "state", "of", "subItems" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions-expandable/src/main/java/com/mikepenz/fastadapter/utils/AdapterUtil.java#L20-L32
32,406
mikepenz/FastAdapter
library-extensions-expandable/src/main/java/com/mikepenz/fastadapter/utils/AdapterUtil.java
AdapterUtil.findSubItemSelections
public static <Item extends IItem> void findSubItemSelections(Item item, List<String> selections) { if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) { List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems(); for (int i = 0, size = subItems.size(); i < size; i++) { Item subItem = subItems.get(i); String id = String.valueOf(subItem.getIdentifier()); if (subItem.isSelected()) { selections.add(id); } findSubItemSelections(subItem, selections); } } }
java
public static <Item extends IItem> void findSubItemSelections(Item item, List<String> selections) { if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) { List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems(); for (int i = 0, size = subItems.size(); i < size; i++) { Item subItem = subItems.get(i); String id = String.valueOf(subItem.getIdentifier()); if (subItem.isSelected()) { selections.add(id); } findSubItemSelections(subItem, selections); } } }
[ "public", "static", "<", "Item", "extends", "IItem", ">", "void", "findSubItemSelections", "(", "Item", "item", ",", "List", "<", "String", ">", "selections", ")", "{", "if", "(", "item", "instanceof", "IExpandable", "&&", "!", "(", "(", "IExpandable", ")"...
internal method to find all selections from subItems and sub sub items so we can save those inside our savedInstanceState @param item the parent item @param selections the ArrayList which will be stored in the savedInstanceState
[ "internal", "method", "to", "find", "all", "selections", "from", "subItems", "and", "sub", "sub", "items", "so", "we", "can", "save", "those", "inside", "our", "savedInstanceState" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions-expandable/src/main/java/com/mikepenz/fastadapter/utils/AdapterUtil.java#L40-L52
32,407
mikepenz/FastAdapter
library-extensions-expandable/src/main/java/com/mikepenz/fastadapter/utils/AdapterUtil.java
AdapterUtil.addAllSubItems
public static <Item extends IItem> void addAllSubItems(Item item, List<Item> items) { if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) { List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems(); Item subItem; for (int i = 0, size = subItems.size(); i < size; i++) { subItem = subItems.get(i); items.add(subItem); addAllSubItems(subItem, items); } } }
java
public static <Item extends IItem> void addAllSubItems(Item item, List<Item> items) { if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) { List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems(); Item subItem; for (int i = 0, size = subItems.size(); i < size; i++) { subItem = subItems.get(i); items.add(subItem); addAllSubItems(subItem, items); } } }
[ "public", "static", "<", "Item", "extends", "IItem", ">", "void", "addAllSubItems", "(", "Item", "item", ",", "List", "<", "Item", ">", "items", ")", "{", "if", "(", "item", "instanceof", "IExpandable", "&&", "!", "(", "(", "IExpandable", ")", "item", ...
Gets all subItems from a given parent item @param item the parent from which we add all items @param items the list in which we add the subItems
[ "Gets", "all", "subItems", "from", "a", "given", "parent", "item" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions-expandable/src/main/java/com/mikepenz/fastadapter/utils/AdapterUtil.java#L77-L87
32,408
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.addAdapter
public <A extends IAdapter<Item>> FastAdapter<Item> addAdapter(int index, A adapter) { mAdapters.add(index, adapter); adapter.withFastAdapter(this); adapter.mapPossibleTypes(adapter.getAdapterItems()); for (int i = 0; i < mAdapters.size(); i++) { mAdapters.get(i).setOrder(i); } cacheSizes(); return this; }
java
public <A extends IAdapter<Item>> FastAdapter<Item> addAdapter(int index, A adapter) { mAdapters.add(index, adapter); adapter.withFastAdapter(this); adapter.mapPossibleTypes(adapter.getAdapterItems()); for (int i = 0; i < mAdapters.size(); i++) { mAdapters.get(i).setOrder(i); } cacheSizes(); return this; }
[ "public", "<", "A", "extends", "IAdapter", "<", "Item", ">", ">", "FastAdapter", "<", "Item", ">", "addAdapter", "(", "int", "index", ",", "A", "adapter", ")", "{", "mAdapters", ".", "add", "(", "index", ",", "adapter", ")", ";", "adapter", ".", "wit...
add's a new adapter at the specific position @param index the index where the new adapter should be added @param adapter the new adapter to be added @return this
[ "add", "s", "a", "new", "adapter", "at", "the", "specific", "position" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L202-L211
32,409
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.adapter
@Nullable public IAdapter<Item> adapter(int order) { if (mAdapters.size() <= order) { return null; } return mAdapters.get(order); }
java
@Nullable public IAdapter<Item> adapter(int order) { if (mAdapters.size() <= order) { return null; } return mAdapters.get(order); }
[ "@", "Nullable", "public", "IAdapter", "<", "Item", ">", "adapter", "(", "int", "order", ")", "{", "if", "(", "mAdapters", ".", "size", "(", ")", "<=", "order", ")", "{", "return", "null", ";", "}", "return", "mAdapters", ".", "get", "(", "order", ...
Tries to get an adapter by a specific order @param order the order (position) to search the adapter at @return the IAdapter if found
[ "Tries", "to", "get", "an", "adapter", "by", "a", "specific", "order" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L219-L225
32,410
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.withSelectable
public FastAdapter<Item> withSelectable(boolean selectable) { if (selectable) { addExtension(mSelectExtension); } else { mExtensions.remove(mSelectExtension.getClass()); } //TODO revisit this --> false means anyways that it is not in the extension list! mSelectExtension.withSelectable(selectable); return this; }
java
public FastAdapter<Item> withSelectable(boolean selectable) { if (selectable) { addExtension(mSelectExtension); } else { mExtensions.remove(mSelectExtension.getClass()); } //TODO revisit this --> false means anyways that it is not in the extension list! mSelectExtension.withSelectable(selectable); return this; }
[ "public", "FastAdapter", "<", "Item", ">", "withSelectable", "(", "boolean", "selectable", ")", "{", "if", "(", "selectable", ")", "{", "addExtension", "(", "mSelectExtension", ")", ";", "}", "else", "{", "mExtensions", ".", "remove", "(", "mSelectExtension", ...
Set to true if you want the items to be selectable. By default, no items are selectable @param selectable true if items are selectable @return this
[ "Set", "to", "true", "if", "you", "want", "the", "items", "to", "be", "selectable", ".", "By", "default", "no", "items", "are", "selectable" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L448-L457
32,411
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.registerTypeInstance
@SuppressWarnings("unchecked") public void registerTypeInstance(Item item) { if (getTypeInstanceCache().register(item)) { //check if the item implements hookable when its added for the first time if (item instanceof IHookable) { withEventHooks(((IHookable<Item>) item).getEventHooks()); } } }
java
@SuppressWarnings("unchecked") public void registerTypeInstance(Item item) { if (getTypeInstanceCache().register(item)) { //check if the item implements hookable when its added for the first time if (item instanceof IHookable) { withEventHooks(((IHookable<Item>) item).getEventHooks()); } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "registerTypeInstance", "(", "Item", "item", ")", "{", "if", "(", "getTypeInstanceCache", "(", ")", ".", "register", "(", "item", ")", ")", "{", "//check if the item implements hookable when its a...
register a new type into the TypeInstances to be able to efficiently create thew ViewHolders @param item an IItem which will be shown in the list
[ "register", "a", "new", "type", "into", "the", "TypeInstances", "to", "be", "able", "to", "efficiently", "create", "thew", "ViewHolders" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L537-L545
32,412
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.onCreateViewHolder
@Override @SuppressWarnings("unchecked") public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (mVerbose) Log.v(TAG, "onCreateViewHolder: " + viewType); final RecyclerView.ViewHolder holder = mOnCreateViewHolderListener.onPreCreateViewHolder(this, parent, viewType); //set the adapter holder.itemView.setTag(R.id.fastadapter_item_adapter, FastAdapter.this); if (mAttachDefaultListeners) { //handle click behavior EventHookUtil.attachToView(fastAdapterViewClickListener, holder, holder.itemView); //handle long click behavior EventHookUtil.attachToView(fastAdapterViewLongClickListener, holder, holder.itemView); //handle touch behavior EventHookUtil.attachToView(fastAdapterViewTouchListener, holder, holder.itemView); } return mOnCreateViewHolderListener.onPostCreateViewHolder(this, holder); }
java
@Override @SuppressWarnings("unchecked") public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (mVerbose) Log.v(TAG, "onCreateViewHolder: " + viewType); final RecyclerView.ViewHolder holder = mOnCreateViewHolderListener.onPreCreateViewHolder(this, parent, viewType); //set the adapter holder.itemView.setTag(R.id.fastadapter_item_adapter, FastAdapter.this); if (mAttachDefaultListeners) { //handle click behavior EventHookUtil.attachToView(fastAdapterViewClickListener, holder, holder.itemView); //handle long click behavior EventHookUtil.attachToView(fastAdapterViewLongClickListener, holder, holder.itemView); //handle touch behavior EventHookUtil.attachToView(fastAdapterViewTouchListener, holder, holder.itemView); } return mOnCreateViewHolderListener.onPostCreateViewHolder(this, holder); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "RecyclerView", ".", "ViewHolder", "onCreateViewHolder", "(", "ViewGroup", "parent", ",", "int", "viewType", ")", "{", "if", "(", "mVerbose", ")", "Log", ".", "v", "(", "TAG", ","...
Creates the ViewHolder by the viewType @param parent the parent view (the RecyclerView) @param viewType the current viewType which is bound @return the ViewHolder with the bound data
[ "Creates", "the", "ViewHolder", "by", "the", "viewType" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L680-L702
32,413
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.onBindViewHolder
@Override @SuppressWarnings("unchecked") public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (mLegacyBindViewMode) { if (mVerbose) { Log.v(TAG, "onBindViewHolderLegacy: " + position + "/" + holder.getItemViewType() + " isLegacy: true"); } //set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available holder.itemView.setTag(R.id.fastadapter_item_adapter, this); //now we bind the item to this viewHolder mOnBindViewHolderListener.onBindViewHolder(holder, position, Collections.EMPTY_LIST); } }
java
@Override @SuppressWarnings("unchecked") public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (mLegacyBindViewMode) { if (mVerbose) { Log.v(TAG, "onBindViewHolderLegacy: " + position + "/" + holder.getItemViewType() + " isLegacy: true"); } //set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available holder.itemView.setTag(R.id.fastadapter_item_adapter, this); //now we bind the item to this viewHolder mOnBindViewHolderListener.onBindViewHolder(holder, position, Collections.EMPTY_LIST); } }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "onBindViewHolder", "(", "final", "RecyclerView", ".", "ViewHolder", "holder", ",", "int", "position", ")", "{", "if", "(", "mLegacyBindViewMode", ")", "{", "if", "(", "mVer...
Binds the data to the created ViewHolder and sets the listeners to the holder.itemView Note that you should use the `onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads` as it allows you to implement a more efficient adapter implementation @param holder the viewHolder we bind the data on @param position the global position
[ "Binds", "the", "data", "to", "the", "created", "ViewHolder", "and", "sets", "the", "listeners", "to", "the", "holder", ".", "itemView", "Note", "that", "you", "should", "use", "the", "onBindViewHolder", "(", "RecyclerView", ".", "ViewHolder", "holder", "int",...
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L712-L724
32,414
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.onBindViewHolder
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<Object> payloads) { //we do not want the binding to happen twice (the legacyBindViewMode if (!mLegacyBindViewMode) { if (mVerbose) Log.v(TAG, "onBindViewHolder: " + position + "/" + holder.getItemViewType() + " isLegacy: false"); //set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available holder.itemView.setTag(R.id.fastadapter_item_adapter, this); //now we bind the item to this viewHolder mOnBindViewHolderListener.onBindViewHolder(holder, position, payloads); } super.onBindViewHolder(holder, position, payloads); }
java
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<Object> payloads) { //we do not want the binding to happen twice (the legacyBindViewMode if (!mLegacyBindViewMode) { if (mVerbose) Log.v(TAG, "onBindViewHolder: " + position + "/" + holder.getItemViewType() + " isLegacy: false"); //set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available holder.itemView.setTag(R.id.fastadapter_item_adapter, this); //now we bind the item to this viewHolder mOnBindViewHolderListener.onBindViewHolder(holder, position, payloads); } super.onBindViewHolder(holder, position, payloads); }
[ "@", "Override", "public", "void", "onBindViewHolder", "(", "RecyclerView", ".", "ViewHolder", "holder", ",", "int", "position", ",", "List", "<", "Object", ">", "payloads", ")", "{", "//we do not want the binding to happen twice (the legacyBindViewMode", "if", "(", "...
Binds the data to the created ViewHolder and sets the listeners to the holder.itemView @param holder the viewHolder we bind the data on @param position the global position @param payloads the payloads for the bindViewHolder event containing data which allows to improve view animating
[ "Binds", "the", "data", "to", "the", "created", "ViewHolder", "and", "sets", "the", "listeners", "to", "the", "holder", ".", "itemView" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L733-L745
32,415
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.onViewRecycled
@Override public void onViewRecycled(RecyclerView.ViewHolder holder) { if (mVerbose) Log.v(TAG, "onViewRecycled: " + holder.getItemViewType()); super.onViewRecycled(holder); mOnBindViewHolderListener.unBindViewHolder(holder, holder.getAdapterPosition()); }
java
@Override public void onViewRecycled(RecyclerView.ViewHolder holder) { if (mVerbose) Log.v(TAG, "onViewRecycled: " + holder.getItemViewType()); super.onViewRecycled(holder); mOnBindViewHolderListener.unBindViewHolder(holder, holder.getAdapterPosition()); }
[ "@", "Override", "public", "void", "onViewRecycled", "(", "RecyclerView", ".", "ViewHolder", "holder", ")", "{", "if", "(", "mVerbose", ")", "Log", ".", "v", "(", "TAG", ",", "\"onViewRecycled: \"", "+", "holder", ".", "getItemViewType", "(", ")", ")", ";"...
Unbinds the data to the already existing ViewHolder and removes the listeners from the holder.itemView @param holder the viewHolder we unbind the data from
[ "Unbinds", "the", "data", "to", "the", "already", "existing", "ViewHolder", "and", "removes", "the", "listeners", "from", "the", "holder", ".", "itemView" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L752-L757
32,416
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.getItem
public Item getItem(int position) { //if we are out of range just return null if (position < 0 || position >= mGlobalSize) { return null; } //now get the adapter which is responsible for the given position int index = floorIndex(mAdapterSizes, position); return mAdapterSizes.valueAt(index).getAdapterItem(position - mAdapterSizes.keyAt(index)); }
java
public Item getItem(int position) { //if we are out of range just return null if (position < 0 || position >= mGlobalSize) { return null; } //now get the adapter which is responsible for the given position int index = floorIndex(mAdapterSizes, position); return mAdapterSizes.valueAt(index).getAdapterItem(position - mAdapterSizes.keyAt(index)); }
[ "public", "Item", "getItem", "(", "int", "position", ")", "{", "//if we are out of range just return null", "if", "(", "position", "<", "0", "||", "position", ">=", "mGlobalSize", ")", "{", "return", "null", ";", "}", "//now get the adapter which is responsible for th...
gets the IItem by a position, from all registered adapters @param position the global position @return the found IItem or null
[ "gets", "the", "IItem", "by", "a", "position", "from", "all", "registered", "adapters" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L851-L859
32,417
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.getRelativeInfo
public RelativeInfo<Item> getRelativeInfo(int position) { if (position < 0 || position >= getItemCount()) { return new RelativeInfo<>(); } RelativeInfo<Item> relativeInfo = new RelativeInfo<>(); int index = floorIndex(mAdapterSizes, position); if (index != -1) { relativeInfo.item = mAdapterSizes.valueAt(index).getAdapterItem(position - mAdapterSizes.keyAt(index)); relativeInfo.adapter = mAdapterSizes.valueAt(index); relativeInfo.position = position; } return relativeInfo; }
java
public RelativeInfo<Item> getRelativeInfo(int position) { if (position < 0 || position >= getItemCount()) { return new RelativeInfo<>(); } RelativeInfo<Item> relativeInfo = new RelativeInfo<>(); int index = floorIndex(mAdapterSizes, position); if (index != -1) { relativeInfo.item = mAdapterSizes.valueAt(index).getAdapterItem(position - mAdapterSizes.keyAt(index)); relativeInfo.adapter = mAdapterSizes.valueAt(index); relativeInfo.position = position; } return relativeInfo; }
[ "public", "RelativeInfo", "<", "Item", ">", "getRelativeInfo", "(", "int", "position", ")", "{", "if", "(", "position", "<", "0", "||", "position", ">=", "getItemCount", "(", ")", ")", "{", "return", "new", "RelativeInfo", "<>", "(", ")", ";", "}", "Re...
Internal method to get the Item as ItemHolder which comes with the relative position within its adapter Finds the responsible adapter for the given position @param position the global position @return the adapter which is responsible for this position
[ "Internal", "method", "to", "get", "the", "Item", "as", "ItemHolder", "which", "comes", "with", "the", "relative", "position", "within", "its", "adapter", "Finds", "the", "responsible", "adapter", "for", "the", "given", "position" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L892-L905
32,418
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.getAdapter
@Nullable public IAdapter<Item> getAdapter(int position) { //if we are out of range just return null if (position < 0 || position >= mGlobalSize) { return null; } if (mVerbose) Log.v(TAG, "getAdapter"); //now get the adapter which is responsible for the given position return mAdapterSizes.valueAt(floorIndex(mAdapterSizes, position)); }
java
@Nullable public IAdapter<Item> getAdapter(int position) { //if we are out of range just return null if (position < 0 || position >= mGlobalSize) { return null; } if (mVerbose) Log.v(TAG, "getAdapter"); //now get the adapter which is responsible for the given position return mAdapterSizes.valueAt(floorIndex(mAdapterSizes, position)); }
[ "@", "Nullable", "public", "IAdapter", "<", "Item", ">", "getAdapter", "(", "int", "position", ")", "{", "//if we are out of range just return null", "if", "(", "position", "<", "0", "||", "position", ">=", "mGlobalSize", ")", "{", "return", "null", ";", "}", ...
Gets the adapter for the given position @param position the global position @return the adapter responsible for this global position
[ "Gets", "the", "adapter", "for", "the", "given", "position" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L913-L922
32,419
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.cacheSizes
protected void cacheSizes() { mAdapterSizes.clear(); int size = 0; for (IAdapter<Item> adapter : mAdapters) { if (adapter.getAdapterItemCount() > 0) { mAdapterSizes.append(size, adapter); size = size + adapter.getAdapterItemCount(); } } //we also have to add this for the first adapter otherwise the floorIndex method will return the wrong value if (size == 0 && mAdapters.size() > 0) { mAdapterSizes.append(0, mAdapters.get(0)); } mGlobalSize = size; }
java
protected void cacheSizes() { mAdapterSizes.clear(); int size = 0; for (IAdapter<Item> adapter : mAdapters) { if (adapter.getAdapterItemCount() > 0) { mAdapterSizes.append(size, adapter); size = size + adapter.getAdapterItemCount(); } } //we also have to add this for the first adapter otherwise the floorIndex method will return the wrong value if (size == 0 && mAdapters.size() > 0) { mAdapterSizes.append(0, mAdapters.get(0)); } mGlobalSize = size; }
[ "protected", "void", "cacheSizes", "(", ")", "{", "mAdapterSizes", ".", "clear", "(", ")", ";", "int", "size", "=", "0", ";", "for", "(", "IAdapter", "<", "Item", ">", "adapter", ":", "mAdapters", ")", "{", "if", "(", "adapter", ".", "getAdapterItemCou...
we cache the sizes of our adapters so get accesses are faster
[ "we", "cache", "the", "sizes", "of", "our", "adapters", "so", "get", "accesses", "are", "faster" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L1028-L1045
32,420
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.recursiveSub
@SuppressWarnings("unchecked") public static <Item extends IItem> Triple<Boolean, Item, Integer> recursiveSub(IAdapter<Item> lastParentAdapter, int lastParentPosition, IExpandable parent, AdapterPredicate<Item> predicate, boolean stopOnMatch) { //in case it's expanded it can be selected via the normal way if (!parent.isExpanded() && parent.getSubItems() != null) { for (int ii = 0; ii < parent.getSubItems().size(); ii++) { Item sub = (Item) parent.getSubItems().get(ii); if (predicate.apply(lastParentAdapter, lastParentPosition, sub, -1) && stopOnMatch) { return new Triple<>(true, sub, null); } if (sub instanceof IExpandable) { Triple<Boolean, Item, Integer> res = FastAdapter.recursiveSub(lastParentAdapter, lastParentPosition, (IExpandable) sub, predicate, stopOnMatch); if (res.first) { return res; } } } } return new Triple<>(false, null, null); }
java
@SuppressWarnings("unchecked") public static <Item extends IItem> Triple<Boolean, Item, Integer> recursiveSub(IAdapter<Item> lastParentAdapter, int lastParentPosition, IExpandable parent, AdapterPredicate<Item> predicate, boolean stopOnMatch) { //in case it's expanded it can be selected via the normal way if (!parent.isExpanded() && parent.getSubItems() != null) { for (int ii = 0; ii < parent.getSubItems().size(); ii++) { Item sub = (Item) parent.getSubItems().get(ii); if (predicate.apply(lastParentAdapter, lastParentPosition, sub, -1) && stopOnMatch) { return new Triple<>(true, sub, null); } if (sub instanceof IExpandable) { Triple<Boolean, Item, Integer> res = FastAdapter.recursiveSub(lastParentAdapter, lastParentPosition, (IExpandable) sub, predicate, stopOnMatch); if (res.first) { return res; } } } } return new Triple<>(false, null, null); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "Item", "extends", "IItem", ">", "Triple", "<", "Boolean", ",", "Item", ",", "Integer", ">", "recursiveSub", "(", "IAdapter", "<", "Item", ">", "lastParentAdapter", ",", "int", "las...
Util function which recursively iterates over all items of a `IExpandable` parent if and only if it is `expanded` and has `subItems` This is usually only used in @param lastParentAdapter the last `IAdapter` managing the last (visible) parent item (that might also be a parent of a parent, ..) @param lastParentPosition the global position of the last (visible) parent item, holding this sub item (that might also be a parent of a parent, ..) @param parent the `IExpandableParent` to start from @param predicate the predicate to run on every item, to check for a match or do some changes (e.g. select) @param stopOnMatch defines if we should stop iterating after the first match @param <Item> the type of the `Item` @return Triple&lt;Boolean, IItem, Integer&gt; The first value is true (it is always not null), the second contains the item and the third the position (if the item is visible) if we had a match, (always false and null and null in case of stopOnMatch == false)
[ "Util", "function", "which", "recursively", "iterates", "over", "all", "items", "of", "a", "IExpandable", "parent", "if", "and", "only", "if", "it", "is", "expanded", "and", "has", "subItems", "This", "is", "usually", "only", "used", "in" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L1487-L1507
32,421
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/listeners/CustomEventHook.java
CustomEventHook.getFastAdapter
@Nullable public FastAdapter<Item> getFastAdapter(RecyclerView.ViewHolder viewHolder) { Object tag = viewHolder.itemView.getTag(R.id.fastadapter_item_adapter); if (tag instanceof FastAdapter) { return (FastAdapter<Item>) tag; } return null; }
java
@Nullable public FastAdapter<Item> getFastAdapter(RecyclerView.ViewHolder viewHolder) { Object tag = viewHolder.itemView.getTag(R.id.fastadapter_item_adapter); if (tag instanceof FastAdapter) { return (FastAdapter<Item>) tag; } return null; }
[ "@", "Nullable", "public", "FastAdapter", "<", "Item", ">", "getFastAdapter", "(", "RecyclerView", ".", "ViewHolder", "viewHolder", ")", "{", "Object", "tag", "=", "viewHolder", ".", "itemView", ".", "getTag", "(", "R", ".", "id", ".", "fastadapter_item_adapte...
Helper method to get the FastAdapter from this ViewHolder @param viewHolder @return
[ "Helper", "method", "to", "get", "the", "FastAdapter", "from", "this", "ViewHolder" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/listeners/CustomEventHook.java#L29-L36
32,422
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/listeners/CustomEventHook.java
CustomEventHook.getItem
@Nullable public Item getItem(RecyclerView.ViewHolder viewHolder) { FastAdapter<Item> adapter = getFastAdapter(viewHolder); if (adapter == null) { return null; } //we get the adapterPosition from the viewHolder int pos = adapter.getHolderAdapterPosition(viewHolder); //make sure the click was done on a valid item if (pos != RecyclerView.NO_POSITION) { //we update our item with the changed property return adapter.getItem(pos); } return null; }
java
@Nullable public Item getItem(RecyclerView.ViewHolder viewHolder) { FastAdapter<Item> adapter = getFastAdapter(viewHolder); if (adapter == null) { return null; } //we get the adapterPosition from the viewHolder int pos = adapter.getHolderAdapterPosition(viewHolder); //make sure the click was done on a valid item if (pos != RecyclerView.NO_POSITION) { //we update our item with the changed property return adapter.getItem(pos); } return null; }
[ "@", "Nullable", "public", "Item", "getItem", "(", "RecyclerView", ".", "ViewHolder", "viewHolder", ")", "{", "FastAdapter", "<", "Item", ">", "adapter", "=", "getFastAdapter", "(", "viewHolder", ")", ";", "if", "(", "adapter", "==", "null", ")", "{", "ret...
helper method to get the item for this ViewHolder @param viewHolder @return
[ "helper", "method", "to", "get", "the", "item", "for", "this", "ViewHolder" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/listeners/CustomEventHook.java#L44-L58
32,423
mikepenz/FastAdapter
library/src/main/java/com/mikepenz/fastadapter/commons/utils/FastAdapterUIUtils.java
FastAdapterUIUtils.getRippleMask
private static Drawable getRippleMask(int color, int radius) { float[] outerRadius = new float[8]; Arrays.fill(outerRadius, radius); RoundRectShape r = new RoundRectShape(outerRadius, null, null); ShapeDrawable shapeDrawable = new ShapeDrawable(r); shapeDrawable.getPaint().setColor(color); return shapeDrawable; }
java
private static Drawable getRippleMask(int color, int radius) { float[] outerRadius = new float[8]; Arrays.fill(outerRadius, radius); RoundRectShape r = new RoundRectShape(outerRadius, null, null); ShapeDrawable shapeDrawable = new ShapeDrawable(r); shapeDrawable.getPaint().setColor(color); return shapeDrawable; }
[ "private", "static", "Drawable", "getRippleMask", "(", "int", "color", ",", "int", "radius", ")", "{", "float", "[", "]", "outerRadius", "=", "new", "float", "[", "8", "]", ";", "Arrays", ".", "fill", "(", "outerRadius", ",", "radius", ")", ";", "Round...
helper to create an ripple mask with the given color and radius @param color the color @param radius the radius @return the mask drawable
[ "helper", "to", "create", "an", "ripple", "mask", "with", "the", "given", "color", "and", "radius" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library/src/main/java/com/mikepenz/fastadapter/commons/utils/FastAdapterUIUtils.java#L117-L124
32,424
mikepenz/FastAdapter
library/src/main/java/com/mikepenz/fastadapter/commons/utils/FastAdapterUIUtils.java
FastAdapterUIUtils.getStateListDrawable
private static StateListDrawable getStateListDrawable( int normalColor, int pressedColor) { StateListDrawable states = new StateListDrawable(); states.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(pressedColor)); states.addState(new int[]{android.R.attr.state_focused}, new ColorDrawable(pressedColor)); states.addState(new int[]{android.R.attr.state_activated}, new ColorDrawable(pressedColor)); states.addState(new int[]{}, new ColorDrawable(normalColor)); return states; }
java
private static StateListDrawable getStateListDrawable( int normalColor, int pressedColor) { StateListDrawable states = new StateListDrawable(); states.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(pressedColor)); states.addState(new int[]{android.R.attr.state_focused}, new ColorDrawable(pressedColor)); states.addState(new int[]{android.R.attr.state_activated}, new ColorDrawable(pressedColor)); states.addState(new int[]{}, new ColorDrawable(normalColor)); return states; }
[ "private", "static", "StateListDrawable", "getStateListDrawable", "(", "int", "normalColor", ",", "int", "pressedColor", ")", "{", "StateListDrawable", "states", "=", "new", "StateListDrawable", "(", ")", ";", "states", ".", "addState", "(", "new", "int", "[", "...
helper to create an StateListDrawable for the given normal and pressed color @param normalColor the normal color @param pressedColor the pressed color @return the StateListDrawable
[ "helper", "to", "create", "an", "StateListDrawable", "for", "the", "given", "normal", "and", "pressed", "color" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library/src/main/java/com/mikepenz/fastadapter/commons/utils/FastAdapterUIUtils.java#L133-L145
32,425
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java
SubItemUtil.getSelectedItems
@Deprecated public static Set<IItem> getSelectedItems(FastAdapter adapter) { Set<IItem> selections = new HashSet<>(); int length = adapter.getItemCount(); List<IItem> items = new ArrayList<>(); for (int i = 0; i < length; i++) { items.add(adapter.getItem(i)); } updateSelectedItemsWithCollapsed(selections, items); return selections; }
java
@Deprecated public static Set<IItem> getSelectedItems(FastAdapter adapter) { Set<IItem> selections = new HashSet<>(); int length = adapter.getItemCount(); List<IItem> items = new ArrayList<>(); for (int i = 0; i < length; i++) { items.add(adapter.getItem(i)); } updateSelectedItemsWithCollapsed(selections, items); return selections; }
[ "@", "Deprecated", "public", "static", "Set", "<", "IItem", ">", "getSelectedItems", "(", "FastAdapter", "adapter", ")", "{", "Set", "<", "IItem", ">", "selections", "=", "new", "HashSet", "<>", "(", ")", ";", "int", "length", "=", "adapter", ".", "getIt...
returns a set of selected items, regardless of their visibility @param adapter the adapter instance @return a set of all selected items and subitems @deprecated See {@link FastAdapter#getSelectedItems()} ()} ()}
[ "returns", "a", "set", "of", "selected", "items", "regardless", "of", "their", "visibility" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java#L36-L46
32,426
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java
SubItemUtil.getAllItems
public static List<IItem> getAllItems(List<IItem> items, boolean countHeaders, IPredicate predicate) { return getAllItems(items, countHeaders, false, predicate); }
java
public static List<IItem> getAllItems(List<IItem> items, boolean countHeaders, IPredicate predicate) { return getAllItems(items, countHeaders, false, predicate); }
[ "public", "static", "List", "<", "IItem", ">", "getAllItems", "(", "List", "<", "IItem", ">", "items", ",", "boolean", "countHeaders", ",", "IPredicate", "predicate", ")", "{", "return", "getAllItems", "(", "items", ",", "countHeaders", ",", "false", ",", ...
retrieves a flat list of the items in the provided list, respecting subitems regardless of there current visibility @param items the list of items to process @param countHeaders if true, headers will be counted as well @return list of items in the adapter
[ "retrieves", "a", "flat", "list", "of", "the", "items", "in", "the", "provided", "list", "respecting", "subitems", "regardless", "of", "there", "current", "visibility" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java#L115-L117
32,427
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java
SubItemUtil.countSelectedSubItems
public static <T extends IItem & IExpandable> int countSelectedSubItems(final FastAdapter adapter, T header) { SelectExtension extension = (SelectExtension) adapter.getExtension(SelectExtension.class); if (extension != null) { Set<IItem> selections = extension.getSelectedItems(); return countSelectedSubItems(selections, header); } return 0; }
java
public static <T extends IItem & IExpandable> int countSelectedSubItems(final FastAdapter adapter, T header) { SelectExtension extension = (SelectExtension) adapter.getExtension(SelectExtension.class); if (extension != null) { Set<IItem> selections = extension.getSelectedItems(); return countSelectedSubItems(selections, header); } return 0; }
[ "public", "static", "<", "T", "extends", "IItem", "&", "IExpandable", ">", "int", "countSelectedSubItems", "(", "final", "FastAdapter", "adapter", ",", "T", "header", ")", "{", "SelectExtension", "extension", "=", "(", "SelectExtension", ")", "adapter", ".", "...
counts the selected items in the adapter underneath an expandable item, recursively @param adapter the adapter instance @param header the header who's selected children should be counted @return number of selected items underneath the header
[ "counts", "the", "selected", "items", "in", "the", "adapter", "underneath", "an", "expandable", "item", "recursively" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java#L179-L186
32,428
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java
SubItemUtil.deleteSelected
public static List<IItem> deleteSelected(final FastAdapter fastAdapter, final ExpandableExtension expandableExtension, boolean notifyParent, boolean deleteEmptyHeaders) { List<IItem> deleted = new ArrayList<>(); // we use a LinkedList, because this has performance advantages when modifying the listIterator during iteration! // Modifying list is O(1) LinkedList<IItem> selectedItems = new LinkedList<>(getSelectedItems(fastAdapter)); // Log.d("DELETE", "selectedItems: " + selectedItems.size()); // we delete item per item from the adapter directly or from the parent // if keepEmptyHeaders is false, we add empty headers to the selected items set via the iterator, so that they are processed in the loop as well IItem item, parent; int pos, parentPos; boolean expanded; ListIterator<IItem> it = selectedItems.listIterator(); while (it.hasNext()) { item = it.next(); pos = fastAdapter.getPosition(item); // search for parent - if we find one, we remove the item from the parent's subitems directly parent = getParent(item); if (parent != null) { parentPos = fastAdapter.getPosition(parent); boolean success = ((IExpandable) parent).getSubItems().remove(item); // Log.d("DELETE", "success=" + success + " | deletedId=" + item.getIdentifier() + " | parentId=" + parent.getIdentifier() + " (sub items: " + ((IExpandable) parent).getSubItems().size() + ") | parentPos=" + parentPos); // check if parent is expanded and notify the adapter about the removed item, if necessary (only if parent is visible) if (parentPos != -1 && ((IExpandable) parent).isExpanded()) { expandableExtension.notifyAdapterSubItemsChanged(parentPos, ((IExpandable) parent).getSubItems().size() + 1); } // if desired, notify the parent about its changed items (only if parent is visible!) if (parentPos != -1 && notifyParent) { expanded = ((IExpandable) parent).isExpanded(); fastAdapter.notifyAdapterItemChanged(parentPos); // expand the item again if it was expanded before calling notifyAdapterItemChanged if (expanded) { expandableExtension.expand(parentPos); } } deleted.add(item); if (deleteEmptyHeaders && ((IExpandable) parent).getSubItems().size() == 0) { it.add(parent); it.previous(); } } else if (pos != -1) { // if we did not find a parent, we remove the item from the adapter IAdapter adapter = fastAdapter.getAdapter(pos); boolean success = false; if (adapter instanceof IItemAdapter) { success = ((IItemAdapter) adapter).remove(pos) != null; } boolean isHeader = item instanceof IExpandable && ((IExpandable) item).getSubItems() != null; // Log.d("DELETE", "success=" + success + " | deletedId=" + item.getIdentifier() + "(" + (isHeader ? "EMPTY HEADER" : "ITEM WITHOUT HEADER") + ")"); deleted.add(item); } } // Log.d("DELETE", "deleted (incl. empty headers): " + deleted.size()); return deleted; }
java
public static List<IItem> deleteSelected(final FastAdapter fastAdapter, final ExpandableExtension expandableExtension, boolean notifyParent, boolean deleteEmptyHeaders) { List<IItem> deleted = new ArrayList<>(); // we use a LinkedList, because this has performance advantages when modifying the listIterator during iteration! // Modifying list is O(1) LinkedList<IItem> selectedItems = new LinkedList<>(getSelectedItems(fastAdapter)); // Log.d("DELETE", "selectedItems: " + selectedItems.size()); // we delete item per item from the adapter directly or from the parent // if keepEmptyHeaders is false, we add empty headers to the selected items set via the iterator, so that they are processed in the loop as well IItem item, parent; int pos, parentPos; boolean expanded; ListIterator<IItem> it = selectedItems.listIterator(); while (it.hasNext()) { item = it.next(); pos = fastAdapter.getPosition(item); // search for parent - if we find one, we remove the item from the parent's subitems directly parent = getParent(item); if (parent != null) { parentPos = fastAdapter.getPosition(parent); boolean success = ((IExpandable) parent).getSubItems().remove(item); // Log.d("DELETE", "success=" + success + " | deletedId=" + item.getIdentifier() + " | parentId=" + parent.getIdentifier() + " (sub items: " + ((IExpandable) parent).getSubItems().size() + ") | parentPos=" + parentPos); // check if parent is expanded and notify the adapter about the removed item, if necessary (only if parent is visible) if (parentPos != -1 && ((IExpandable) parent).isExpanded()) { expandableExtension.notifyAdapterSubItemsChanged(parentPos, ((IExpandable) parent).getSubItems().size() + 1); } // if desired, notify the parent about its changed items (only if parent is visible!) if (parentPos != -1 && notifyParent) { expanded = ((IExpandable) parent).isExpanded(); fastAdapter.notifyAdapterItemChanged(parentPos); // expand the item again if it was expanded before calling notifyAdapterItemChanged if (expanded) { expandableExtension.expand(parentPos); } } deleted.add(item); if (deleteEmptyHeaders && ((IExpandable) parent).getSubItems().size() == 0) { it.add(parent); it.previous(); } } else if (pos != -1) { // if we did not find a parent, we remove the item from the adapter IAdapter adapter = fastAdapter.getAdapter(pos); boolean success = false; if (adapter instanceof IItemAdapter) { success = ((IItemAdapter) adapter).remove(pos) != null; } boolean isHeader = item instanceof IExpandable && ((IExpandable) item).getSubItems() != null; // Log.d("DELETE", "success=" + success + " | deletedId=" + item.getIdentifier() + "(" + (isHeader ? "EMPTY HEADER" : "ITEM WITHOUT HEADER") + ")"); deleted.add(item); } } // Log.d("DELETE", "deleted (incl. empty headers): " + deleted.size()); return deleted; }
[ "public", "static", "List", "<", "IItem", ">", "deleteSelected", "(", "final", "FastAdapter", "fastAdapter", ",", "final", "ExpandableExtension", "expandableExtension", ",", "boolean", "notifyParent", ",", "boolean", "deleteEmptyHeaders", ")", "{", "List", "<", "IIt...
deletes all selected items from the adapter respecting if the are sub items or not subitems are removed from their parents sublists, main items are directly removed Alternatively you might consider also looking at: {@link SelectExtension#deleteAllSelectedItems()} @param deleteEmptyHeaders if true, empty headers will be removed from the adapter @return List of items that have been removed from the adapter
[ "deletes", "all", "selected", "items", "from", "the", "adapter", "respecting", "if", "the", "are", "sub", "items", "or", "not", "subitems", "are", "removed", "from", "their", "parents", "sublists", "main", "items", "are", "directly", "removed" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java#L335-L399
32,429
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java
SubItemUtil.delete
public static List<IItem> delete(final FastAdapter fastAdapter, final ExpandableExtension expandableExtension, Collection<Long> identifiersToDelete, boolean notifyParent, boolean deleteEmptyHeaders) { List<IItem> deleted = new ArrayList<>(); if (identifiersToDelete == null || identifiersToDelete.size() == 0) { return deleted; } // we use a LinkedList, because this has performance advantages when modifying the listIterator during iteration! // Modifying list is O(1) LinkedList<Long> identifiers = new LinkedList<>(identifiersToDelete); // we delete item per item from the adapter directly or from the parent // if keepEmptyHeaders is false, we add empty headers to the selected items set via the iterator, so that they are processed in the loop as well IItem item, parent; int pos, parentPos; boolean expanded; Long identifier; ListIterator<Long> it = identifiers.listIterator(); while (it.hasNext()) { identifier = it.next(); pos = fastAdapter.getPosition(identifier); item = fastAdapter.getItem(pos); // search for parent - if we find one, we remove the item from the parent's subitems directly parent = getParent(item); if (parent != null) { parentPos = fastAdapter.getPosition(parent); boolean success = ((IExpandable) parent).getSubItems().remove(item); // Log.d("DELETE", "success=" + success + " | deletedId=" + item.getIdentifier() + " | parentId=" + parent.getIdentifier() + " (sub items: " + ((IExpandable) parent).getSubItems().size() + ") | parentPos=" + parentPos); // check if parent is expanded and notify the adapter about the removed item, if necessary (only if parent is visible) if (parentPos != -1 && ((IExpandable) parent).isExpanded()) { expandableExtension.notifyAdapterSubItemsChanged(parentPos, ((IExpandable) parent).getSubItems().size() + 1); } // if desired, notify the parent about it's changed items (only if parent is visible!) if (parentPos != -1 && notifyParent) { expanded = ((IExpandable) parent).isExpanded(); fastAdapter.notifyAdapterItemChanged(parentPos); // expand the item again if it was expanded before calling notifyAdapterItemChanged if (expanded) { expandableExtension.expand(parentPos); } } deleted.add(item); if (deleteEmptyHeaders && ((IExpandable) parent).getSubItems().size() == 0) { it.add(parent.getIdentifier()); it.previous(); } } else if (pos != -1) { // if we did not find a parent, we remove the item from the adapter IAdapter adapter = fastAdapter.getAdapter(pos); boolean success = false; if (adapter instanceof IItemAdapter) { success = ((IItemAdapter) adapter).remove(pos) != null; if (success) { fastAdapter.notifyAdapterItemRemoved(pos); } } boolean isHeader = item instanceof IExpandable && ((IExpandable) item).getSubItems() != null; // Log.d("DELETE", "success=" + success + " | deletedId=" + item.getIdentifier() + "(" + (isHeader ? "EMPTY HEADER" : "ITEM WITHOUT HEADER") + ")"); deleted.add(item); } } // Log.d("DELETE", "deleted (incl. empty headers): " + deleted.size()); return deleted; }
java
public static List<IItem> delete(final FastAdapter fastAdapter, final ExpandableExtension expandableExtension, Collection<Long> identifiersToDelete, boolean notifyParent, boolean deleteEmptyHeaders) { List<IItem> deleted = new ArrayList<>(); if (identifiersToDelete == null || identifiersToDelete.size() == 0) { return deleted; } // we use a LinkedList, because this has performance advantages when modifying the listIterator during iteration! // Modifying list is O(1) LinkedList<Long> identifiers = new LinkedList<>(identifiersToDelete); // we delete item per item from the adapter directly or from the parent // if keepEmptyHeaders is false, we add empty headers to the selected items set via the iterator, so that they are processed in the loop as well IItem item, parent; int pos, parentPos; boolean expanded; Long identifier; ListIterator<Long> it = identifiers.listIterator(); while (it.hasNext()) { identifier = it.next(); pos = fastAdapter.getPosition(identifier); item = fastAdapter.getItem(pos); // search for parent - if we find one, we remove the item from the parent's subitems directly parent = getParent(item); if (parent != null) { parentPos = fastAdapter.getPosition(parent); boolean success = ((IExpandable) parent).getSubItems().remove(item); // Log.d("DELETE", "success=" + success + " | deletedId=" + item.getIdentifier() + " | parentId=" + parent.getIdentifier() + " (sub items: " + ((IExpandable) parent).getSubItems().size() + ") | parentPos=" + parentPos); // check if parent is expanded and notify the adapter about the removed item, if necessary (only if parent is visible) if (parentPos != -1 && ((IExpandable) parent).isExpanded()) { expandableExtension.notifyAdapterSubItemsChanged(parentPos, ((IExpandable) parent).getSubItems().size() + 1); } // if desired, notify the parent about it's changed items (only if parent is visible!) if (parentPos != -1 && notifyParent) { expanded = ((IExpandable) parent).isExpanded(); fastAdapter.notifyAdapterItemChanged(parentPos); // expand the item again if it was expanded before calling notifyAdapterItemChanged if (expanded) { expandableExtension.expand(parentPos); } } deleted.add(item); if (deleteEmptyHeaders && ((IExpandable) parent).getSubItems().size() == 0) { it.add(parent.getIdentifier()); it.previous(); } } else if (pos != -1) { // if we did not find a parent, we remove the item from the adapter IAdapter adapter = fastAdapter.getAdapter(pos); boolean success = false; if (adapter instanceof IItemAdapter) { success = ((IItemAdapter) adapter).remove(pos) != null; if (success) { fastAdapter.notifyAdapterItemRemoved(pos); } } boolean isHeader = item instanceof IExpandable && ((IExpandable) item).getSubItems() != null; // Log.d("DELETE", "success=" + success + " | deletedId=" + item.getIdentifier() + "(" + (isHeader ? "EMPTY HEADER" : "ITEM WITHOUT HEADER") + ")"); deleted.add(item); } } // Log.d("DELETE", "deleted (incl. empty headers): " + deleted.size()); return deleted; }
[ "public", "static", "List", "<", "IItem", ">", "delete", "(", "final", "FastAdapter", "fastAdapter", ",", "final", "ExpandableExtension", "expandableExtension", ",", "Collection", "<", "Long", ">", "identifiersToDelete", ",", "boolean", "notifyParent", ",", "boolean...
deletes all items in identifiersToDelete collection from the adapter respecting if there are sub items or not subitems are removed from their parents sublists, main items are directly removed @param fastAdapter the adapter to remove the items from @param identifiersToDelete ids of items to remove @param notifyParent if true, headers of removed items will be notified about the change of their child items @param deleteEmptyHeaders if true, empty headers will be removed from the adapter @return List of items that have been removed from the adapter
[ "deletes", "all", "items", "in", "identifiersToDelete", "collection", "from", "the", "adapter", "respecting", "if", "there", "are", "sub", "items", "or", "not", "subitems", "are", "removed", "from", "their", "parents", "sublists", "main", "items", "are", "direct...
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/utilities/SubItemUtil.java#L411-L481
32,430
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/dialog/FastAdapterBottomSheetDialog.java
FastAdapterBottomSheetDialog.createRecyclerView
private RecyclerView createRecyclerView() { RecyclerView recyclerView = new RecyclerView(getContext()); RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); recyclerView.setLayoutParams(params); setContentView(recyclerView); return recyclerView; }
java
private RecyclerView createRecyclerView() { RecyclerView recyclerView = new RecyclerView(getContext()); RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); recyclerView.setLayoutParams(params); setContentView(recyclerView); return recyclerView; }
[ "private", "RecyclerView", "createRecyclerView", "(", ")", "{", "RecyclerView", "recyclerView", "=", "new", "RecyclerView", "(", "getContext", "(", ")", ")", ";", "RecyclerView", ".", "LayoutParams", "params", "=", "new", "RecyclerView", ".", "LayoutParams", "(", ...
Create the RecyclerView and set it as the dialog view. @return the created RecyclerView
[ "Create", "the", "RecyclerView", "and", "set", "it", "as", "the", "dialog", "view", "." ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/dialog/FastAdapterBottomSheetDialog.java#L44-L51
32,431
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/dialog/FastAdapterBottomSheetDialog.java
FastAdapterBottomSheetDialog.withOnPreClickListener
public FastAdapterBottomSheetDialog<Item> withOnPreClickListener(com.mikepenz.fastadapter.listeners.OnClickListener<Item> onPreClickListener) { this.mFastAdapter.withOnPreClickListener(onPreClickListener); return this; }
java
public FastAdapterBottomSheetDialog<Item> withOnPreClickListener(com.mikepenz.fastadapter.listeners.OnClickListener<Item> onPreClickListener) { this.mFastAdapter.withOnPreClickListener(onPreClickListener); return this; }
[ "public", "FastAdapterBottomSheetDialog", "<", "Item", ">", "withOnPreClickListener", "(", "com", ".", "mikepenz", ".", "fastadapter", ".", "listeners", ".", "OnClickListener", "<", "Item", ">", "onPreClickListener", ")", "{", "this", ".", "mFastAdapter", ".", "wi...
Define the OnPreClickListener which will be used for a single item and is called after all internal methods are done @param onPreClickListener the OnPreClickListener which will be called after a single item was clicked and all internal methods are done @return this
[ "Define", "the", "OnPreClickListener", "which", "will", "be", "used", "for", "a", "single", "item", "and", "is", "called", "after", "all", "internal", "methods", "are", "done" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/dialog/FastAdapterBottomSheetDialog.java#L142-L145
32,432
mikepenz/FastAdapter
app/src/main/java/com/mikepenz/fastadapter/app/helpers/HeaderPositionCalculator.java
HeaderPositionCalculator.getFirstViewUnobscuredByHeader
private View getFirstViewUnobscuredByHeader(RecyclerView parent, View firstHeader) { boolean isReverseLayout = mOrientationProvider.isReverseLayout(parent); int step = isReverseLayout ? -1 : 1; int from = isReverseLayout ? parent.getChildCount() - 1 : 0; for (int i = from; i >= 0 && i <= parent.getChildCount() - 1; i += step) { View child = parent.getChildAt(i); if (!itemIsObscuredByHeader(parent, child, firstHeader, mOrientationProvider.getOrientation(parent))) { return child; } } return null; }
java
private View getFirstViewUnobscuredByHeader(RecyclerView parent, View firstHeader) { boolean isReverseLayout = mOrientationProvider.isReverseLayout(parent); int step = isReverseLayout ? -1 : 1; int from = isReverseLayout ? parent.getChildCount() - 1 : 0; for (int i = from; i >= 0 && i <= parent.getChildCount() - 1; i += step) { View child = parent.getChildAt(i); if (!itemIsObscuredByHeader(parent, child, firstHeader, mOrientationProvider.getOrientation(parent))) { return child; } } return null; }
[ "private", "View", "getFirstViewUnobscuredByHeader", "(", "RecyclerView", "parent", ",", "View", "firstHeader", ")", "{", "boolean", "isReverseLayout", "=", "mOrientationProvider", ".", "isReverseLayout", "(", "parent", ")", ";", "int", "step", "=", "isReverseLayout",...
Returns the first item currently in the RecyclerView that is not obscured by a header. @param parent Recyclerview containing all the list items @return first item that is fully beneath a header
[ "Returns", "the", "first", "item", "currently", "in", "the", "RecyclerView", "that", "is", "not", "obscured", "by", "a", "header", "." ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/app/src/main/java/com/mikepenz/fastadapter/app/helpers/HeaderPositionCalculator.java#L209-L220
32,433
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/utils/DefaultIdDistributor.java
DefaultIdDistributor.checkId
@Override public Identifiable checkId(Identifiable item) { if (item.getIdentifier() == -1) { item.withIdentifier(nextId(item)); } return item; }
java
@Override public Identifiable checkId(Identifiable item) { if (item.getIdentifier() == -1) { item.withIdentifier(nextId(item)); } return item; }
[ "@", "Override", "public", "Identifiable", "checkId", "(", "Identifiable", "item", ")", "{", "if", "(", "item", ".", "getIdentifier", "(", ")", "==", "-", "1", ")", "{", "item", ".", "withIdentifier", "(", "nextId", "(", "item", ")", ")", ";", "}", "...
set an unique identifier for the item which do not have one set already @param item @return
[ "set", "an", "unique", "identifier", "for", "the", "item", "which", "do", "not", "have", "one", "set", "already" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/utils/DefaultIdDistributor.java#L47-L53
32,434
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/select/SelectExtension.java
SelectExtension.toggleSelection
public void toggleSelection(int position) { if (mFastAdapter.getItem(position).isSelected()) { deselect(position); } else { select(position); } }
java
public void toggleSelection(int position) { if (mFastAdapter.getItem(position).isSelected()) { deselect(position); } else { select(position); } }
[ "public", "void", "toggleSelection", "(", "int", "position", ")", "{", "if", "(", "mFastAdapter", ".", "getItem", "(", "position", ")", ".", "isSelected", "(", ")", ")", "{", "deselect", "(", "position", ")", ";", "}", "else", "{", "select", "(", "posi...
toggles the selection of the item at the given position @param position the global position
[ "toggles", "the", "selection", "of", "the", "item", "at", "the", "given", "position" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/select/SelectExtension.java#L259-L265
32,435
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/select/SelectExtension.java
SelectExtension.select
public void select(Item item, boolean considerSelectableFlag) { if (considerSelectableFlag && !item.isSelectable()) { return; } item.withSetSelected(true); if (mSelectionListener != null) { mSelectionListener.onSelectionChanged(item, true); } }
java
public void select(Item item, boolean considerSelectableFlag) { if (considerSelectableFlag && !item.isSelectable()) { return; } item.withSetSelected(true); if (mSelectionListener != null) { mSelectionListener.onSelectionChanged(item, true); } }
[ "public", "void", "select", "(", "Item", "item", ",", "boolean", "considerSelectableFlag", ")", "{", "if", "(", "considerSelectableFlag", "&&", "!", "item", ".", "isSelectable", "(", ")", ")", "{", "return", ";", "}", "item", ".", "withSetSelected", "(", "...
select's a provided item, this won't notify the adapter @param item the item to select @param considerSelectableFlag true if the select method should not select an item if its not selectable
[ "select", "s", "a", "provided", "item", "this", "won", "t", "notify", "the", "adapter" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/select/SelectExtension.java#L342-L350
32,436
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/select/SelectExtension.java
SelectExtension.deselect
public void deselect(Iterable<Integer> positions) { Iterator<Integer> entries = positions.iterator(); while (entries.hasNext()) { deselect(entries.next(), entries); } }
java
public void deselect(Iterable<Integer> positions) { Iterator<Integer> entries = positions.iterator(); while (entries.hasNext()) { deselect(entries.next(), entries); } }
[ "public", "void", "deselect", "(", "Iterable", "<", "Integer", ">", "positions", ")", "{", "Iterator", "<", "Integer", ">", "entries", "=", "positions", ".", "iterator", "(", ")", ";", "while", "(", "entries", ".", "hasNext", "(", ")", ")", "{", "desel...
deselects all items at the positions in the iteratable @param positions the global positions to deselect
[ "deselects", "all", "items", "at", "the", "positions", "in", "the", "iteratable" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/select/SelectExtension.java#L488-L493
32,437
mikepenz/FastAdapter
app/src/main/java/com/mikepenz/fastadapter/app/items/ImageItem.java
ImageItem.style
private void style(View view, int value) { view.setScaleX(value); view.setScaleY(value); view.setAlpha(value); }
java
private void style(View view, int value) { view.setScaleX(value); view.setScaleY(value); view.setAlpha(value); }
[ "private", "void", "style", "(", "View", "view", ",", "int", "value", ")", "{", "view", ".", "setScaleX", "(", "value", ")", ";", "view", ".", "setScaleY", "(", "value", ")", ";", "view", ".", "setAlpha", "(", "value", ")", ";", "}" ]
helper method to style the heart view @param view @param value
[ "helper", "method", "to", "style", "the", "heart", "view" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/app/src/main/java/com/mikepenz/fastadapter/app/items/ImageItem.java#L123-L127
32,438
mikepenz/FastAdapter
app/src/main/java/com/mikepenz/fastadapter/app/items/ImageItem.java
ImageItem.animateHeart
public void animateHeart(View imageLovedOn, View imageLovedOff, boolean on) { imageLovedOn.setVisibility(View.VISIBLE); imageLovedOff.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { viewPropertyStartCompat(imageLovedOff.animate().scaleX(on ? 0 : 1).scaleY(on ? 0 : 1).alpha(on ? 0 : 1)); viewPropertyStartCompat(imageLovedOn.animate().scaleX(on ? 1 : 0).scaleY(on ? 1 : 0).alpha(on ? 1 : 0)); } }
java
public void animateHeart(View imageLovedOn, View imageLovedOff, boolean on) { imageLovedOn.setVisibility(View.VISIBLE); imageLovedOff.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { viewPropertyStartCompat(imageLovedOff.animate().scaleX(on ? 0 : 1).scaleY(on ? 0 : 1).alpha(on ? 0 : 1)); viewPropertyStartCompat(imageLovedOn.animate().scaleX(on ? 1 : 0).scaleY(on ? 1 : 0).alpha(on ? 1 : 0)); } }
[ "public", "void", "animateHeart", "(", "View", "imageLovedOn", ",", "View", "imageLovedOff", ",", "boolean", "on", ")", "{", "imageLovedOn", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "imageLovedOff", ".", "setVisibility", "(", "View", ".", ...
helper method to animate the heart view @param imageLovedOn @param imageLovedOff @param on
[ "helper", "method", "to", "animate", "the", "heart", "view" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/app/src/main/java/com/mikepenz/fastadapter/app/items/ImageItem.java#L136-L144
32,439
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/HeaderHelper.java
HeaderHelper.apply
public void apply(List items) { //If the list is empty avoid sorting and adding headers. int size = items.size(); if (size > 0) { //sort beforehand if (comparator != null) { Collections.sort(items, comparator); } //we have to get the list size each time, as we will add the headers to it for (int i = -1; i < size; i++) { HeaderItem headerItem; if (i == -1) { headerItem = groupingFunction.group(null, (Item) items.get(i + 1), i); } else if (i == size - 1) { headerItem = groupingFunction.group((Item) items.get(i), null, i); } else { headerItem = groupingFunction.group((Item) items.get(i), (Item) items.get(i + 1), i); } if (headerItem != null) { items.add(i + 1, headerItem); i = i + 1; size = size + 1; } } } /** * set the sorted list to the modelAdapter if provided */ if (modelAdapter != null) { modelAdapter.set(items); } }
java
public void apply(List items) { //If the list is empty avoid sorting and adding headers. int size = items.size(); if (size > 0) { //sort beforehand if (comparator != null) { Collections.sort(items, comparator); } //we have to get the list size each time, as we will add the headers to it for (int i = -1; i < size; i++) { HeaderItem headerItem; if (i == -1) { headerItem = groupingFunction.group(null, (Item) items.get(i + 1), i); } else if (i == size - 1) { headerItem = groupingFunction.group((Item) items.get(i), null, i); } else { headerItem = groupingFunction.group((Item) items.get(i), (Item) items.get(i + 1), i); } if (headerItem != null) { items.add(i + 1, headerItem); i = i + 1; size = size + 1; } } } /** * set the sorted list to the modelAdapter if provided */ if (modelAdapter != null) { modelAdapter.set(items); } }
[ "public", "void", "apply", "(", "List", "items", ")", "{", "//If the list is empty avoid sorting and adding headers.", "int", "size", "=", "items", ".", "size", "(", ")", ";", "if", "(", "size", ">", "0", ")", "{", "//sort beforehand", "if", "(", "comparator",...
call this when your list order has changed or was updated, and you have to readd the headres @param items the list which will get the headers added inbetween
[ "call", "this", "when", "your", "list", "order", "has", "changed", "or", "was", "updated", "and", "you", "have", "to", "readd", "the", "headres" ]
3b2412abe001ba58422e0125846b704d4dba4ae9
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/HeaderHelper.java#L39-L73
32,440
aaberg/sql2o
core/src/main/java/org/sql2o/ArrayParameters.java
ArrayParameters.updateQueryAndParametersIndexes
static String updateQueryAndParametersIndexes(String parsedQuery, Map<String, List<Integer>> parameterNamesToIndexes, Map<String, Query.ParameterSetter> parameters, boolean allowArrayParameters) { List<ArrayParameter> arrayParametersSortedAsc = arrayParametersSortedAsc(parameterNamesToIndexes, parameters, allowArrayParameters); if(arrayParametersSortedAsc.isEmpty()) { return parsedQuery; } updateParameterNamesToIndexes(parameterNamesToIndexes, arrayParametersSortedAsc); return updateQueryWithArrayParameters(parsedQuery, arrayParametersSortedAsc); }
java
static String updateQueryAndParametersIndexes(String parsedQuery, Map<String, List<Integer>> parameterNamesToIndexes, Map<String, Query.ParameterSetter> parameters, boolean allowArrayParameters) { List<ArrayParameter> arrayParametersSortedAsc = arrayParametersSortedAsc(parameterNamesToIndexes, parameters, allowArrayParameters); if(arrayParametersSortedAsc.isEmpty()) { return parsedQuery; } updateParameterNamesToIndexes(parameterNamesToIndexes, arrayParametersSortedAsc); return updateQueryWithArrayParameters(parsedQuery, arrayParametersSortedAsc); }
[ "static", "String", "updateQueryAndParametersIndexes", "(", "String", "parsedQuery", ",", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "parameterNamesToIndexes", ",", "Map", "<", "String", ",", "Query", ".", "ParameterSetter", ">", "parameters", ...
Update both the query and the parameter indexes to include the array parameters.
[ "Update", "both", "the", "query", "and", "the", "parameter", "indexes", "to", "include", "the", "array", "parameters", "." ]
01d3490a6d2440cf60f973d23508ac4ed57a8e20
https://github.com/aaberg/sql2o/blob/01d3490a6d2440cf60f973d23508ac4ed57a8e20/core/src/main/java/org/sql2o/ArrayParameters.java#L32-L44
32,441
aaberg/sql2o
core/src/main/java/org/sql2o/ArrayParameters.java
ArrayParameters.updateParameterNamesToIndexes
static Map<String, List<Integer>> updateParameterNamesToIndexes(Map<String, List<Integer>> parametersNameToIndex, List<ArrayParameter> arrayParametersSortedAsc) { for(Map.Entry<String, List<Integer>> parameterNameToIndexes : parametersNameToIndex.entrySet()) { List<Integer> newParameterIndex = new ArrayList<>(parameterNameToIndexes.getValue().size()); for(Integer parameterIndex : parameterNameToIndexes.getValue()) { newParameterIndex.add(computeNewIndex(parameterIndex, arrayParametersSortedAsc)); } parameterNameToIndexes.setValue(newParameterIndex); } return parametersNameToIndex; }
java
static Map<String, List<Integer>> updateParameterNamesToIndexes(Map<String, List<Integer>> parametersNameToIndex, List<ArrayParameter> arrayParametersSortedAsc) { for(Map.Entry<String, List<Integer>> parameterNameToIndexes : parametersNameToIndex.entrySet()) { List<Integer> newParameterIndex = new ArrayList<>(parameterNameToIndexes.getValue().size()); for(Integer parameterIndex : parameterNameToIndexes.getValue()) { newParameterIndex.add(computeNewIndex(parameterIndex, arrayParametersSortedAsc)); } parameterNameToIndexes.setValue(newParameterIndex); } return parametersNameToIndex; }
[ "static", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "updateParameterNamesToIndexes", "(", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "parametersNameToIndex", ",", "List", "<", "ArrayParameter", ">", "arrayParametersSortedAsc"...
Update the indexes of each query parameter
[ "Update", "the", "indexes", "of", "each", "query", "parameter" ]
01d3490a6d2440cf60f973d23508ac4ed57a8e20
https://github.com/aaberg/sql2o/blob/01d3490a6d2440cf60f973d23508ac4ed57a8e20/core/src/main/java/org/sql2o/ArrayParameters.java#L49-L60
32,442
aaberg/sql2o
core/src/main/java/org/sql2o/ArrayParameters.java
ArrayParameters.computeNewIndex
static int computeNewIndex(int index, List<ArrayParameter> arrayParametersSortedAsc) { int newIndex = index; for(ArrayParameter arrayParameter : arrayParametersSortedAsc) { if(index > arrayParameter.parameterIndex) { newIndex = newIndex + arrayParameter.parameterCount - 1; } else { return newIndex; } } return newIndex; }
java
static int computeNewIndex(int index, List<ArrayParameter> arrayParametersSortedAsc) { int newIndex = index; for(ArrayParameter arrayParameter : arrayParametersSortedAsc) { if(index > arrayParameter.parameterIndex) { newIndex = newIndex + arrayParameter.parameterCount - 1; } else { return newIndex; } } return newIndex; }
[ "static", "int", "computeNewIndex", "(", "int", "index", ",", "List", "<", "ArrayParameter", ">", "arrayParametersSortedAsc", ")", "{", "int", "newIndex", "=", "index", ";", "for", "(", "ArrayParameter", "arrayParameter", ":", "arrayParametersSortedAsc", ")", "{",...
Compute the new index of a parameter given the index positions of the array parameters.
[ "Compute", "the", "new", "index", "of", "a", "parameter", "given", "the", "index", "positions", "of", "the", "array", "parameters", "." ]
01d3490a6d2440cf60f973d23508ac4ed57a8e20
https://github.com/aaberg/sql2o/blob/01d3490a6d2440cf60f973d23508ac4ed57a8e20/core/src/main/java/org/sql2o/ArrayParameters.java#L66-L76
32,443
aaberg/sql2o
core/src/main/java/org/sql2o/ArrayParameters.java
ArrayParameters.arrayParametersSortedAsc
private static List<ArrayParameter> arrayParametersSortedAsc(Map<String, List<Integer>> parameterNamesToIndexes, Map<String, Query.ParameterSetter> parameters, boolean allowArrayParameters) { List<ArrayParameters.ArrayParameter> arrayParameters = new ArrayList<>(); for(Map.Entry<String, Query.ParameterSetter> parameter : parameters.entrySet()) { if (parameter.getValue().parameterCount > 1) { if (!allowArrayParameters) { throw new Sql2oException("Array parameters are not allowed in batch mode"); } for(int i : parameterNamesToIndexes.get(parameter.getKey())) { arrayParameters.add(new ArrayParameters.ArrayParameter(i, parameter.getValue().parameterCount)); } } } Collections.sort(arrayParameters); return arrayParameters; }
java
private static List<ArrayParameter> arrayParametersSortedAsc(Map<String, List<Integer>> parameterNamesToIndexes, Map<String, Query.ParameterSetter> parameters, boolean allowArrayParameters) { List<ArrayParameters.ArrayParameter> arrayParameters = new ArrayList<>(); for(Map.Entry<String, Query.ParameterSetter> parameter : parameters.entrySet()) { if (parameter.getValue().parameterCount > 1) { if (!allowArrayParameters) { throw new Sql2oException("Array parameters are not allowed in batch mode"); } for(int i : parameterNamesToIndexes.get(parameter.getKey())) { arrayParameters.add(new ArrayParameters.ArrayParameter(i, parameter.getValue().parameterCount)); } } } Collections.sort(arrayParameters); return arrayParameters; }
[ "private", "static", "List", "<", "ArrayParameter", ">", "arrayParametersSortedAsc", "(", "Map", "<", "String", ",", "List", "<", "Integer", ">", ">", "parameterNamesToIndexes", ",", "Map", "<", "String", ",", "Query", ".", "ParameterSetter", ">", "parameters", ...
List all the array parameters that contains more that 1 parameters. Indeed, array parameter below 1 parameter will not change the text query nor the parameter indexes.
[ "List", "all", "the", "array", "parameters", "that", "contains", "more", "that", "1", "parameters", ".", "Indeed", "array", "parameter", "below", "1", "parameter", "will", "not", "change", "the", "text", "query", "nor", "the", "parameter", "indexes", "." ]
01d3490a6d2440cf60f973d23508ac4ed57a8e20
https://github.com/aaberg/sql2o/blob/01d3490a6d2440cf60f973d23508ac4ed57a8e20/core/src/main/java/org/sql2o/ArrayParameters.java#L82-L99
32,444
aaberg/sql2o
core/src/main/java/org/sql2o/ArrayParameters.java
ArrayParameters.updateQueryWithArrayParameters
static String updateQueryWithArrayParameters(String parsedQuery, List<ArrayParameter> arrayParametersSortedAsc) { if(arrayParametersSortedAsc.isEmpty()) { return parsedQuery; } StringBuilder sb = new StringBuilder(); Iterator<ArrayParameter> parameterToReplaceIt = arrayParametersSortedAsc.iterator(); ArrayParameter nextParameterToReplace = parameterToReplaceIt.next(); // PreparedStatement index starts at 1 int currentIndex = 1; for(char c : parsedQuery.toCharArray()) { if(nextParameterToReplace != null && c == '?') { if(currentIndex == nextParameterToReplace.parameterIndex) { sb.append("?"); for(int i = 1; i < nextParameterToReplace.parameterCount; i++) { sb.append(",?"); } if(parameterToReplaceIt.hasNext()) { nextParameterToReplace = parameterToReplaceIt.next(); } else { nextParameterToReplace = null; } } else { sb.append(c); } currentIndex++; } else { sb.append(c); } } return sb.toString(); }
java
static String updateQueryWithArrayParameters(String parsedQuery, List<ArrayParameter> arrayParametersSortedAsc) { if(arrayParametersSortedAsc.isEmpty()) { return parsedQuery; } StringBuilder sb = new StringBuilder(); Iterator<ArrayParameter> parameterToReplaceIt = arrayParametersSortedAsc.iterator(); ArrayParameter nextParameterToReplace = parameterToReplaceIt.next(); // PreparedStatement index starts at 1 int currentIndex = 1; for(char c : parsedQuery.toCharArray()) { if(nextParameterToReplace != null && c == '?') { if(currentIndex == nextParameterToReplace.parameterIndex) { sb.append("?"); for(int i = 1; i < nextParameterToReplace.parameterCount; i++) { sb.append(",?"); } if(parameterToReplaceIt.hasNext()) { nextParameterToReplace = parameterToReplaceIt.next(); } else { nextParameterToReplace = null; } } else { sb.append(c); } currentIndex++; } else { sb.append(c); } } return sb.toString(); }
[ "static", "String", "updateQueryWithArrayParameters", "(", "String", "parsedQuery", ",", "List", "<", "ArrayParameter", ">", "arrayParametersSortedAsc", ")", "{", "if", "(", "arrayParametersSortedAsc", ".", "isEmpty", "(", ")", ")", "{", "return", "parsedQuery", ";"...
Change the query to replace ? at each arrayParametersSortedAsc.parameterIndex with ?,?,?.. multiple arrayParametersSortedAsc.parameterCount
[ "Change", "the", "query", "to", "replace", "?", "at", "each", "arrayParametersSortedAsc", ".", "parameterIndex", "with", "?", "?", "?", "..", "multiple", "arrayParametersSortedAsc", ".", "parameterCount" ]
01d3490a6d2440cf60f973d23508ac4ed57a8e20
https://github.com/aaberg/sql2o/blob/01d3490a6d2440cf60f973d23508ac4ed57a8e20/core/src/main/java/org/sql2o/ArrayParameters.java#L105-L139
32,445
aaberg/sql2o
core/src/main/java/org/sql2o/ResultSetIteratorBase.java
ResultSetIteratorBase.hasNext
public boolean hasNext() { // check if we already fetched next item if (next != null) { return true; } // check if result set already finished if (resultSetFinished) { return false; } // now fetch next item next = safeReadNext(); // check if we got something if (next != null) { return true; } // no more items resultSetFinished = true; return false; }
java
public boolean hasNext() { // check if we already fetched next item if (next != null) { return true; } // check if result set already finished if (resultSetFinished) { return false; } // now fetch next item next = safeReadNext(); // check if we got something if (next != null) { return true; } // no more items resultSetFinished = true; return false; }
[ "public", "boolean", "hasNext", "(", ")", "{", "// check if we already fetched next item", "if", "(", "next", "!=", "null", ")", "{", "return", "true", ";", "}", "// check if result set already finished", "if", "(", "resultSetFinished", ")", "{", "return", "false", ...
used to note when result set exhausted
[ "used", "to", "note", "when", "result", "set", "exhausted" ]
01d3490a6d2440cf60f973d23508ac4ed57a8e20
https://github.com/aaberg/sql2o/blob/01d3490a6d2440cf60f973d23508ac4ed57a8e20/core/src/main/java/org/sql2o/ResultSetIteratorBase.java#L40-L63
32,446
grails/grails-core
grails-core/src/main/groovy/grails/beans/util/LazyMetaPropertyMap.java
LazyMetaPropertyMap.get
public Object get(Object propertyName) { if (propertyName instanceof CharSequence) { propertyName = propertyName.toString(); } if (propertyName instanceof List) { Map submap = new HashMap(); List propertyNames = (List)propertyName; for (Object currentName : propertyNames) { if (currentName != null) { currentName = currentName.toString(); if (containsKey(currentName)) { submap.put(currentName, get(currentName)); } } } return submap; } if (NameUtils.isConfigurational(propertyName.toString())) { return null; } Object val = null; MetaProperty mp = metaClass.getMetaProperty(propertyName.toString()); if (mp != null) { val = mp.getProperty(instance); } return val; }
java
public Object get(Object propertyName) { if (propertyName instanceof CharSequence) { propertyName = propertyName.toString(); } if (propertyName instanceof List) { Map submap = new HashMap(); List propertyNames = (List)propertyName; for (Object currentName : propertyNames) { if (currentName != null) { currentName = currentName.toString(); if (containsKey(currentName)) { submap.put(currentName, get(currentName)); } } } return submap; } if (NameUtils.isConfigurational(propertyName.toString())) { return null; } Object val = null; MetaProperty mp = metaClass.getMetaProperty(propertyName.toString()); if (mp != null) { val = mp.getProperty(instance); } return val; }
[ "public", "Object", "get", "(", "Object", "propertyName", ")", "{", "if", "(", "propertyName", "instanceof", "CharSequence", ")", "{", "propertyName", "=", "propertyName", ".", "toString", "(", ")", ";", "}", "if", "(", "propertyName", "instanceof", "List", ...
Obtains the value of an object's properties on demand using Groovy's MOP. @param propertyName The name of the property @return The property value or null
[ "Obtains", "the", "value", "of", "an", "object", "s", "properties", "on", "demand", "using", "Groovy", "s", "MOP", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/beans/util/LazyMetaPropertyMap.java#L100-L129
32,447
grails/grails-core
grails-spring/src/main/groovy/org/grails/spring/DefaultRuntimeSpringConfiguration.java
DefaultRuntimeSpringConfiguration.createApplicationContext
protected GenericApplicationContext createApplicationContext(ApplicationContext parentCtx) { if (parentCtx != null && beanFactory != null) { Assert.isInstanceOf(DefaultListableBeanFactory.class, beanFactory, "ListableBeanFactory set must be a subclass of DefaultListableBeanFactory"); return new GrailsApplicationContext((DefaultListableBeanFactory) beanFactory,parentCtx); } if (beanFactory != null) { Assert.isInstanceOf(DefaultListableBeanFactory.class, beanFactory, "ListableBeanFactory set must be a subclass of DefaultListableBeanFactory"); return new GrailsApplicationContext((DefaultListableBeanFactory) beanFactory); } if (parentCtx != null) { return new GrailsApplicationContext(parentCtx); } return new GrailsApplicationContext(); }
java
protected GenericApplicationContext createApplicationContext(ApplicationContext parentCtx) { if (parentCtx != null && beanFactory != null) { Assert.isInstanceOf(DefaultListableBeanFactory.class, beanFactory, "ListableBeanFactory set must be a subclass of DefaultListableBeanFactory"); return new GrailsApplicationContext((DefaultListableBeanFactory) beanFactory,parentCtx); } if (beanFactory != null) { Assert.isInstanceOf(DefaultListableBeanFactory.class, beanFactory, "ListableBeanFactory set must be a subclass of DefaultListableBeanFactory"); return new GrailsApplicationContext((DefaultListableBeanFactory) beanFactory); } if (parentCtx != null) { return new GrailsApplicationContext(parentCtx); } return new GrailsApplicationContext(); }
[ "protected", "GenericApplicationContext", "createApplicationContext", "(", "ApplicationContext", "parentCtx", ")", "{", "if", "(", "parentCtx", "!=", "null", "&&", "beanFactory", "!=", "null", ")", "{", "Assert", ".", "isInstanceOf", "(", "DefaultListableBeanFactory", ...
Creates the ApplicationContext instance. Subclasses can override to customise the used ApplicationContext @param parentCtx The parent ApplicationContext instance. Can be null. @return An instance of GenericApplicationContext
[ "Creates", "the", "ApplicationContext", "instance", ".", "Subclasses", "can", "override", "to", "customise", "the", "used", "ApplicationContext" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/org/grails/spring/DefaultRuntimeSpringConfiguration.java#L72-L92
32,448
grails/grails-core
grails-spring/src/main/groovy/org/grails/spring/DefaultRuntimeSpringConfiguration.java
DefaultRuntimeSpringConfiguration.initialiseApplicationContext
protected void initialiseApplicationContext() { if (context != null) { return; } context = createApplicationContext(parent); if (parent != null && classLoader == null) { trySettingClassLoaderOnContextIfFoundInParent(parent); } else if (classLoader != null) { setClassLoaderOnContext(classLoader); } Assert.notNull(context, "ApplicationContext cannot be null"); }
java
protected void initialiseApplicationContext() { if (context != null) { return; } context = createApplicationContext(parent); if (parent != null && classLoader == null) { trySettingClassLoaderOnContextIfFoundInParent(parent); } else if (classLoader != null) { setClassLoaderOnContext(classLoader); } Assert.notNull(context, "ApplicationContext cannot be null"); }
[ "protected", "void", "initialiseApplicationContext", "(", ")", "{", "if", "(", "context", "!=", "null", ")", "{", "return", ";", "}", "context", "=", "createApplicationContext", "(", "parent", ")", ";", "if", "(", "parent", "!=", "null", "&&", "classLoader",...
Initialises the ApplicationContext instance.
[ "Initialises", "the", "ApplicationContext", "instance", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/org/grails/spring/DefaultRuntimeSpringConfiguration.java#L124-L139
32,449
grails/grails-core
grails-web-common/src/main/groovy/grails/util/GrailsWebUtil.java
GrailsWebUtil.lookupApplication
public static GrailsApplication lookupApplication(ServletContext servletContext) { if (servletContext == null) { return null; } GrailsApplication grailsApplication = (GrailsApplication)servletContext.getAttribute(ApplicationAttributes.APPLICATION); if(grailsApplication != null) { return grailsApplication; } final WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext); if (context == null || !context.containsBean(GrailsApplication.APPLICATION_ID)) { return null; } return context.getBean(GrailsApplication.APPLICATION_ID, GrailsApplication.class); }
java
public static GrailsApplication lookupApplication(ServletContext servletContext) { if (servletContext == null) { return null; } GrailsApplication grailsApplication = (GrailsApplication)servletContext.getAttribute(ApplicationAttributes.APPLICATION); if(grailsApplication != null) { return grailsApplication; } final WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext); if (context == null || !context.containsBean(GrailsApplication.APPLICATION_ID)) { return null; } return context.getBean(GrailsApplication.APPLICATION_ID, GrailsApplication.class); }
[ "public", "static", "GrailsApplication", "lookupApplication", "(", "ServletContext", "servletContext", ")", "{", "if", "(", "servletContext", "==", "null", ")", "{", "return", "null", ";", "}", "GrailsApplication", "grailsApplication", "=", "(", "GrailsApplication", ...
Looks up a GrailsApplication instance from the ServletContext. @param servletContext The ServletContext @return A GrailsApplication or null if there isn't one
[ "Looks", "up", "a", "GrailsApplication", "instance", "from", "the", "ServletContext", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/grails/util/GrailsWebUtil.java#L59-L75
32,450
grails/grails-core
grails-core/src/main/groovy/org/grails/core/lifecycle/ShutdownOperations.java
ShutdownOperations.runOperations
public static synchronized void runOperations() { try { for (Runnable shutdownOperation : shutdownOperations) { try { shutdownOperation.run(); } catch (Exception e) { LOG.warn("Error occurred running shutdown operation: " + e.getMessage(), e); } } } finally { shutdownOperations.clear(); shutdownOperations.addAll(preservedShutdownOperations); } }
java
public static synchronized void runOperations() { try { for (Runnable shutdownOperation : shutdownOperations) { try { shutdownOperation.run(); } catch (Exception e) { LOG.warn("Error occurred running shutdown operation: " + e.getMessage(), e); } } } finally { shutdownOperations.clear(); shutdownOperations.addAll(preservedShutdownOperations); } }
[ "public", "static", "synchronized", "void", "runOperations", "(", ")", "{", "try", "{", "for", "(", "Runnable", "shutdownOperation", ":", "shutdownOperations", ")", "{", "try", "{", "shutdownOperation", ".", "run", "(", ")", ";", "}", "catch", "(", "Exceptio...
Runs the shutdown operations
[ "Runs", "the", "shutdown", "operations" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/core/lifecycle/ShutdownOperations.java#L45-L58
32,451
grails/grails-core
grails-core/src/main/groovy/org/grails/core/lifecycle/ShutdownOperations.java
ShutdownOperations.addOperation
public static synchronized void addOperation(Runnable runnable, boolean preserveForNextShutdown) { shutdownOperations.add(runnable); if(preserveForNextShutdown) { preservedShutdownOperations.add(runnable); } }
java
public static synchronized void addOperation(Runnable runnable, boolean preserveForNextShutdown) { shutdownOperations.add(runnable); if(preserveForNextShutdown) { preservedShutdownOperations.add(runnable); } }
[ "public", "static", "synchronized", "void", "addOperation", "(", "Runnable", "runnable", ",", "boolean", "preserveForNextShutdown", ")", "{", "shutdownOperations", ".", "add", "(", "runnable", ")", ";", "if", "(", "preserveForNextShutdown", ")", "{", "preservedShutd...
Adds a shutdown operation @param runnable The runnable operation @param preserveForNextShutdown should preserve the operation for subsequent shutdowns, useful in tests
[ "Adds", "a", "shutdown", "operation" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/core/lifecycle/ShutdownOperations.java#L73-L78
32,452
grails/grails-core
grails-core/src/main/groovy/org/grails/core/AbstractGrailsClass.java
AbstractGrailsClass.getStaticPropertyValue
public <T> T getStaticPropertyValue(String propName, Class<T> type) { return ClassPropertyFetcher.getStaticPropertyValue(getClazz(), propName, type); }
java
public <T> T getStaticPropertyValue(String propName, Class<T> type) { return ClassPropertyFetcher.getStaticPropertyValue(getClazz(), propName, type); }
[ "public", "<", "T", ">", "T", "getStaticPropertyValue", "(", "String", "propName", ",", "Class", "<", "T", ">", "type", ")", "{", "return", "ClassPropertyFetcher", ".", "getStaticPropertyValue", "(", "getClazz", "(", ")", ",", "propName", ",", "type", ")", ...
Get the value of the named static property. @param propName @param type @return The property value or null
[ "Get", "the", "value", "of", "the", "named", "static", "property", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/core/AbstractGrailsClass.java#L238-L240
32,453
grails/grails-core
grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/api/ControllersDomainBindingApi.java
ControllersDomainBindingApi.initialize
public static void initialize(Object instance, Map namedArgs) { PersistentEntity dc = getDomainClass(instance); if (dc == null) { DataBindingUtils.bindObjectToInstance(instance, namedArgs); } else { DataBindingUtils.bindObjectToDomainInstance(dc, instance, namedArgs); DataBindingUtils.assignBidirectionalAssociations(instance, namedArgs, dc); } autowire(instance); }
java
public static void initialize(Object instance, Map namedArgs) { PersistentEntity dc = getDomainClass(instance); if (dc == null) { DataBindingUtils.bindObjectToInstance(instance, namedArgs); } else { DataBindingUtils.bindObjectToDomainInstance(dc, instance, namedArgs); DataBindingUtils.assignBidirectionalAssociations(instance, namedArgs, dc); } autowire(instance); }
[ "public", "static", "void", "initialize", "(", "Object", "instance", ",", "Map", "namedArgs", ")", "{", "PersistentEntity", "dc", "=", "getDomainClass", "(", "instance", ")", ";", "if", "(", "dc", "==", "null", ")", "{", "DataBindingUtils", ".", "bindObjectT...
A map based constructor that binds the named arguments to the target instance @param instance The target instance @param namedArgs The named arguments
[ "A", "map", "based", "constructor", "that", "binds", "the", "named", "arguments", "to", "the", "target", "instance" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/api/ControllersDomainBindingApi.java#L58-L68
32,454
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsUtil.java
GrailsUtil.deprecated
public static void deprecated(Class<?> clazz, String methodOrPropName, String version) { if (LOG_DEPRECATED) { deprecated("Property or method [" + methodOrPropName + "] of class [" + clazz.getName() + "] is deprecated in [" + version + "] and will be removed in future releases"); } }
java
public static void deprecated(Class<?> clazz, String methodOrPropName, String version) { if (LOG_DEPRECATED) { deprecated("Property or method [" + methodOrPropName + "] of class [" + clazz.getName() + "] is deprecated in [" + version + "] and will be removed in future releases"); } }
[ "public", "static", "void", "deprecated", "(", "Class", "<", "?", ">", "clazz", ",", "String", "methodOrPropName", ",", "String", "version", ")", "{", "if", "(", "LOG_DEPRECATED", ")", "{", "deprecated", "(", "\"Property or method [\"", "+", "methodOrPropName", ...
Logs warning message about deprecation of specified property or method of some class. @param clazz A class @param methodOrPropName Name of deprecated property or method @param version Version of Grails release in which property or method were deprecated
[ "Logs", "warning", "message", "about", "deprecation", "of", "specified", "property", "or", "method", "of", "some", "class", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsUtil.java#L89-L95
32,455
grails/grails-core
buildSrc/src/main/groovy/JavadocFixTool.java
JavadocFixTool.main
public static void main(String[] args) { System.out.println(version); if (args.length < 1) { // No arguments - lazily initialize readme, print readme and usage initReadme(); if (readme != null) { System.out.println(readme); } printUsage(System.out); return; } // Last argument should be a path to the document root String name = args[args.length-1]; // Analyze the rest of parameters for (int i = 0 ; i < args.length -1; i++) { if ("-R".equalsIgnoreCase(args[i])) { recursive = true; } else if ("-C".equalsIgnoreCase(args[i])) { doPatch = false; } else { System.err.println("Unknown option passed: "+args[i]); printUsage(System.err); return; } } new JavadocFixTool().proceed(name); }
java
public static void main(String[] args) { System.out.println(version); if (args.length < 1) { // No arguments - lazily initialize readme, print readme and usage initReadme(); if (readme != null) { System.out.println(readme); } printUsage(System.out); return; } // Last argument should be a path to the document root String name = args[args.length-1]; // Analyze the rest of parameters for (int i = 0 ; i < args.length -1; i++) { if ("-R".equalsIgnoreCase(args[i])) { recursive = true; } else if ("-C".equalsIgnoreCase(args[i])) { doPatch = false; } else { System.err.println("Unknown option passed: "+args[i]); printUsage(System.err); return; } } new JavadocFixTool().proceed(name); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "System", ".", "out", ".", "println", "(", "version", ")", ";", "if", "(", "args", ".", "length", "<", "1", ")", "{", "// No arguments - lazily initialize readme, print readme and...
By default only look in the folder in parameter
[ "By", "default", "only", "look", "in", "the", "folder", "in", "parameter" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/buildSrc/src/main/groovy/JavadocFixTool.java#L151-L180
32,456
grails/grails-core
grails-encoder/src/main/groovy/org/grails/encoder/AbstractEncodedAppender.java
AbstractEncodedAppender.shouldEncode
public boolean shouldEncode(Encoder encoderToApply, EncodingState encodingState) { return ignoreEncodingState || (encoderToApply != null && (encodingState == null || shouldEncodeWith(encoderToApply, encodingState))); }
java
public boolean shouldEncode(Encoder encoderToApply, EncodingState encodingState) { return ignoreEncodingState || (encoderToApply != null && (encodingState == null || shouldEncodeWith(encoderToApply, encodingState))); }
[ "public", "boolean", "shouldEncode", "(", "Encoder", "encoderToApply", ",", "EncodingState", "encodingState", ")", "{", "return", "ignoreEncodingState", "||", "(", "encoderToApply", "!=", "null", "&&", "(", "encodingState", "==", "null", "||", "shouldEncodeWith", "(...
Check if the encoder should be used to a input with certain encodingState @param encoderToApply the encoder to apply @param encodingState the current encoding state @return true, if should encode
[ "Check", "if", "the", "encoder", "should", "be", "used", "to", "a", "input", "with", "certain", "encodingState" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/encoder/AbstractEncodedAppender.java#L170-L173
32,457
grails/grails-core
grails-encoder/src/main/groovy/org/grails/encoder/AbstractEncodedAppender.java
AbstractEncodedAppender.encodeAndWrite
protected void encodeAndWrite(Encoder encoder, EncodingState newEncodingState, CharSequence input) throws IOException { Object encoded = encoder.encode(input); if (encoded != null) { String encodedStr = String.valueOf(encoded); write(newEncodingState, encodedStr, 0, encodedStr.length()); } }
java
protected void encodeAndWrite(Encoder encoder, EncodingState newEncodingState, CharSequence input) throws IOException { Object encoded = encoder.encode(input); if (encoded != null) { String encodedStr = String.valueOf(encoded); write(newEncodingState, encodedStr, 0, encodedStr.length()); } }
[ "protected", "void", "encodeAndWrite", "(", "Encoder", "encoder", ",", "EncodingState", "newEncodingState", ",", "CharSequence", "input", ")", "throws", "IOException", "{", "Object", "encoded", "=", "encoder", ".", "encode", "(", "input", ")", ";", "if", "(", ...
Encode and write input to buffer using a non-streaming encoder @param encoder the encoder to use @param newEncodingState the new encoding state after encoder has been applied @param input the input CharSequence @throws IOException Signals that an I/O exception has occurred.
[ "Encode", "and", "write", "input", "to", "buffer", "using", "a", "non", "-", "streaming", "encoder" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/encoder/AbstractEncodedAppender.java#L192-L199
32,458
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java
GrailsWebRequest.getContextPath
@Override public String getContextPath() { final HttpServletRequest request = getCurrentRequest(); String appUri = (String) request.getAttribute(GrailsApplicationAttributes.APP_URI_ATTRIBUTE); if (appUri == null) { appUri = urlHelper.getContextPath(request); } return appUri; }
java
@Override public String getContextPath() { final HttpServletRequest request = getCurrentRequest(); String appUri = (String) request.getAttribute(GrailsApplicationAttributes.APP_URI_ATTRIBUTE); if (appUri == null) { appUri = urlHelper.getContextPath(request); } return appUri; }
[ "@", "Override", "public", "String", "getContextPath", "(", ")", "{", "final", "HttpServletRequest", "request", "=", "getCurrentRequest", "(", ")", ";", "String", "appUri", "=", "(", "String", ")", "request", ".", "getAttribute", "(", "GrailsApplicationAttributes"...
Returns the context path of the request. @return the path
[ "Returns", "the", "context", "path", "of", "the", "request", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java#L195-L203
32,459
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java
GrailsWebRequest.isFlowRequest
public boolean isFlowRequest() { GrailsApplication application = getAttributes().getGrailsApplication(); Object controllerClassObject = getControllerClass(); GrailsControllerClass controllerClass = null; if(controllerClassObject instanceof GrailsControllerClass) { controllerClass = (GrailsControllerClass) controllerClassObject; } if (controllerClass == null) return false; String actionName = getActionName(); if (actionName == null) actionName = controllerClass.getDefaultAction(); if (actionName == null) return false; return false; }
java
public boolean isFlowRequest() { GrailsApplication application = getAttributes().getGrailsApplication(); Object controllerClassObject = getControllerClass(); GrailsControllerClass controllerClass = null; if(controllerClassObject instanceof GrailsControllerClass) { controllerClass = (GrailsControllerClass) controllerClassObject; } if (controllerClass == null) return false; String actionName = getActionName(); if (actionName == null) actionName = controllerClass.getDefaultAction(); if (actionName == null) return false; return false; }
[ "public", "boolean", "isFlowRequest", "(", ")", "{", "GrailsApplication", "application", "=", "getAttributes", "(", ")", ".", "getGrailsApplication", "(", ")", ";", "Object", "controllerClassObject", "=", "getControllerClass", "(", ")", ";", "GrailsControllerClass", ...
Returns true if the current executing request is a flow request @return true if it is a flow request
[ "Returns", "true", "if", "the", "current", "executing", "request", "is", "a", "flow", "request" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java#L385-L400
32,460
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java
GrailsWebRequest.getPropertyEditorRegistry
public PropertyEditorRegistry getPropertyEditorRegistry() { final HttpServletRequest servletRequest = getCurrentRequest(); PropertyEditorRegistry registry = (PropertyEditorRegistry) servletRequest.getAttribute(GrailsApplicationAttributes.PROPERTY_REGISTRY); if (registry == null) { registry = new PropertyEditorRegistrySupport(); PropertyEditorRegistryUtils.registerCustomEditors(this, registry, RequestContextUtils.getLocale(servletRequest)); servletRequest.setAttribute(GrailsApplicationAttributes.PROPERTY_REGISTRY, registry); } return registry; }
java
public PropertyEditorRegistry getPropertyEditorRegistry() { final HttpServletRequest servletRequest = getCurrentRequest(); PropertyEditorRegistry registry = (PropertyEditorRegistry) servletRequest.getAttribute(GrailsApplicationAttributes.PROPERTY_REGISTRY); if (registry == null) { registry = new PropertyEditorRegistrySupport(); PropertyEditorRegistryUtils.registerCustomEditors(this, registry, RequestContextUtils.getLocale(servletRequest)); servletRequest.setAttribute(GrailsApplicationAttributes.PROPERTY_REGISTRY, registry); } return registry; }
[ "public", "PropertyEditorRegistry", "getPropertyEditorRegistry", "(", ")", "{", "final", "HttpServletRequest", "servletRequest", "=", "getCurrentRequest", "(", ")", ";", "PropertyEditorRegistry", "registry", "=", "(", "PropertyEditorRegistry", ")", "servletRequest", ".", ...
Obtains the PropertyEditorRegistry instance. @return The PropertyEditorRegistry
[ "Obtains", "the", "PropertyEditorRegistry", "instance", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java#L419-L428
32,461
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java
GrailsWebRequest.lookup
public static @Nullable GrailsWebRequest lookup(HttpServletRequest request) { GrailsWebRequest webRequest = (GrailsWebRequest) request.getAttribute(GrailsApplicationAttributes.WEB_REQUEST); return webRequest == null ? lookup() : webRequest; }
java
public static @Nullable GrailsWebRequest lookup(HttpServletRequest request) { GrailsWebRequest webRequest = (GrailsWebRequest) request.getAttribute(GrailsApplicationAttributes.WEB_REQUEST); return webRequest == null ? lookup() : webRequest; }
[ "public", "static", "@", "Nullable", "GrailsWebRequest", "lookup", "(", "HttpServletRequest", "request", ")", "{", "GrailsWebRequest", "webRequest", "=", "(", "GrailsWebRequest", ")", "request", ".", "getAttribute", "(", "GrailsApplicationAttributes", ".", "WEB_REQUEST"...
Looks up the GrailsWebRequest from the current request. @param request The current request @return The GrailsWebRequest
[ "Looks", "up", "the", "GrailsWebRequest", "from", "the", "current", "request", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java#L435-L438
32,462
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java
GrailsWebRequest.lookup
public static @Nullable GrailsWebRequest lookup() { GrailsWebRequest webRequest = null; RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes instanceof GrailsWebRequest) { webRequest = (GrailsWebRequest) requestAttributes; } return webRequest; }
java
public static @Nullable GrailsWebRequest lookup() { GrailsWebRequest webRequest = null; RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes instanceof GrailsWebRequest) { webRequest = (GrailsWebRequest) requestAttributes; } return webRequest; }
[ "public", "static", "@", "Nullable", "GrailsWebRequest", "lookup", "(", ")", "{", "GrailsWebRequest", "webRequest", "=", "null", ";", "RequestAttributes", "requestAttributes", "=", "RequestContextHolder", ".", "getRequestAttributes", "(", ")", ";", "if", "(", "reque...
Looks up the current Grails WebRequest instance @return The GrailsWebRequest instance
[ "Looks", "up", "the", "current", "Grails", "WebRequest", "instance" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java#L444-L451
32,463
grails/grails-core
grails-bootstrap/src/main/groovy/org/grails/exceptions/reporting/DefaultStackTraceFilterer.java
DefaultStackTraceFilterer.isApplicationClass
protected boolean isApplicationClass(String className) { for (String packageName : packagesToFilter) { if (className.startsWith(packageName)) return false; } return true; }
java
protected boolean isApplicationClass(String className) { for (String packageName : packagesToFilter) { if (className.startsWith(packageName)) return false; } return true; }
[ "protected", "boolean", "isApplicationClass", "(", "String", "className", ")", "{", "for", "(", "String", "packageName", ":", "packagesToFilter", ")", "{", "if", "(", "className", ".", "startsWith", "(", "packageName", ")", ")", "return", "false", ";", "}", ...
Whether the given class name is an internal class and should be filtered @param className The class name @return true if is internal
[ "Whether", "the", "given", "class", "name", "is", "an", "internal", "class", "and", "should", "be", "filtered" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-bootstrap/src/main/groovy/org/grails/exceptions/reporting/DefaultStackTraceFilterer.java#L134-L139
32,464
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.registerPrimitiveClassPair
private static final void registerPrimitiveClassPair(Class<?> left, Class<?> right) { PRIMITIVE_TYPE_COMPATIBLE_CLASSES.put(left, right); PRIMITIVE_TYPE_COMPATIBLE_CLASSES.put(right, left); }
java
private static final void registerPrimitiveClassPair(Class<?> left, Class<?> right) { PRIMITIVE_TYPE_COMPATIBLE_CLASSES.put(left, right); PRIMITIVE_TYPE_COMPATIBLE_CLASSES.put(right, left); }
[ "private", "static", "final", "void", "registerPrimitiveClassPair", "(", "Class", "<", "?", ">", "left", ",", "Class", "<", "?", ">", "right", ")", "{", "PRIMITIVE_TYPE_COMPATIBLE_CLASSES", ".", "put", "(", "left", ",", "right", ")", ";", "PRIMITIVE_TYPE_COMPA...
Just add two entries to the class compatibility map @param left @param right
[ "Just", "add", "two", "entries", "to", "the", "class", "compatibility", "map" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L73-L76
32,465
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.getAllInterfaces
public static Class[] getAllInterfaces(Object instance) { Assert.notNull(instance, "Instance must not be null"); return getAllInterfacesForClass(instance.getClass()); }
java
public static Class[] getAllInterfaces(Object instance) { Assert.notNull(instance, "Instance must not be null"); return getAllInterfacesForClass(instance.getClass()); }
[ "public", "static", "Class", "[", "]", "getAllInterfaces", "(", "Object", "instance", ")", "{", "Assert", ".", "notNull", "(", "instance", ",", "\"Instance must not be null\"", ")", ";", "return", "getAllInterfacesForClass", "(", "instance", ".", "getClass", "(", ...
Return all interfaces that the given instance implements as array, including ones implemented by superclasses. @param instance the instance to analyze for interfaces @return all interfaces that the given instance implements as array
[ "Return", "all", "interfaces", "that", "the", "given", "instance", "implements", "as", "array", "including", "ones", "implemented", "by", "superclasses", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L95-L98
32,466
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isPropertyOfType
public static boolean isPropertyOfType(Class<?> clazz, String propertyName, Class<?> type) { try { Class<?> propType = getPropertyType(clazz, propertyName); return propType != null && propType.equals(type); } catch (Exception e) { return false; } }
java
public static boolean isPropertyOfType(Class<?> clazz, String propertyName, Class<?> type) { try { Class<?> propType = getPropertyType(clazz, propertyName); return propType != null && propType.equals(type); } catch (Exception e) { return false; } }
[ "public", "static", "boolean", "isPropertyOfType", "(", "Class", "<", "?", ">", "clazz", ",", "String", "propertyName", ",", "Class", "<", "?", ">", "type", ")", "{", "try", "{", "Class", "<", "?", ">", "propType", "=", "getPropertyType", "(", "clazz", ...
Returns true if the specified property in the specified class is of the specified type @param clazz The class which contains the property @param propertyName The property name @param type The type to check @return A boolean value
[ "Returns", "true", "if", "the", "specified", "property", "in", "the", "specified", "class", "is", "of", "the", "specified", "type" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L201-L209
32,467
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.getPropertyValueOfNewInstance
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Object getPropertyValueOfNewInstance(Class clazz, String propertyName, Class<?> propertyType) { // validate if (clazz == null || !StringUtils.hasText(propertyName)) { return null; } try { return getPropertyOrStaticPropertyOrFieldValue(BeanUtils.instantiateClass(clazz), propertyName); } catch (BeanInstantiationException e) { return null; } }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Object getPropertyValueOfNewInstance(Class clazz, String propertyName, Class<?> propertyType) { // validate if (clazz == null || !StringUtils.hasText(propertyName)) { return null; } try { return getPropertyOrStaticPropertyOrFieldValue(BeanUtils.instantiateClass(clazz), propertyName); } catch (BeanInstantiationException e) { return null; } }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "static", "Object", "getPropertyValueOfNewInstance", "(", "Class", "clazz", ",", "String", "propertyName", ",", "Class", "<", "?", ">", "propertyType", ")", "{", "// val...
Returns the value of the specified property and type from an instance of the specified Grails class @param clazz The name of the class which contains the property @param propertyName The property name @param propertyType The property type @return The value of the property or null if none exists
[ "Returns", "the", "value", "of", "the", "specified", "property", "and", "type", "from", "an", "instance", "of", "the", "specified", "Grails", "class" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L220-L233
32,468
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.getPropertyDescriptorForValue
public static PropertyDescriptor getPropertyDescriptorForValue(Object instance, Object propertyValue) { if (instance == null || propertyValue == null) { return null; } PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(instance.getClass()); for (PropertyDescriptor pd : descriptors) { if (isAssignableOrConvertibleFrom(pd.getPropertyType(), propertyValue.getClass())) { Object value; try { ReflectionUtils.makeAccessible(pd.getReadMethod()); value = pd.getReadMethod().invoke(instance); } catch (Exception e) { throw new FatalBeanException("Problem calling readMethod of " + pd, e); } if (propertyValue.equals(value)) { return pd; } } } return null; }
java
public static PropertyDescriptor getPropertyDescriptorForValue(Object instance, Object propertyValue) { if (instance == null || propertyValue == null) { return null; } PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(instance.getClass()); for (PropertyDescriptor pd : descriptors) { if (isAssignableOrConvertibleFrom(pd.getPropertyType(), propertyValue.getClass())) { Object value; try { ReflectionUtils.makeAccessible(pd.getReadMethod()); value = pd.getReadMethod().invoke(instance); } catch (Exception e) { throw new FatalBeanException("Problem calling readMethod of " + pd, e); } if (propertyValue.equals(value)) { return pd; } } } return null; }
[ "public", "static", "PropertyDescriptor", "getPropertyDescriptorForValue", "(", "Object", "instance", ",", "Object", "propertyValue", ")", "{", "if", "(", "instance", "==", "null", "||", "propertyValue", "==", "null", ")", "{", "return", "null", ";", "}", "Prope...
Retrieves a PropertyDescriptor for the specified instance and property value @param instance The instance @param propertyValue The value of the property @return The PropertyDescriptor
[ "Retrieves", "a", "PropertyDescriptor", "for", "the", "specified", "instance", "and", "property", "value" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L264-L286
32,469
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.getPropertyType
public static Class<?> getPropertyType(Class<?> clazz, String propertyName) { if (clazz == null || !StringUtils.hasText(propertyName)) { return null; } try { PropertyDescriptor desc=BeanUtils.getPropertyDescriptor(clazz, propertyName); if (desc != null) { return desc.getPropertyType(); } return null; } catch (Exception e) { // if there are any errors in instantiating just return null for the moment return null; } }
java
public static Class<?> getPropertyType(Class<?> clazz, String propertyName) { if (clazz == null || !StringUtils.hasText(propertyName)) { return null; } try { PropertyDescriptor desc=BeanUtils.getPropertyDescriptor(clazz, propertyName); if (desc != null) { return desc.getPropertyType(); } return null; } catch (Exception e) { // if there are any errors in instantiating just return null for the moment return null; } }
[ "public", "static", "Class", "<", "?", ">", "getPropertyType", "(", "Class", "<", "?", ">", "clazz", ",", "String", "propertyName", ")", "{", "if", "(", "clazz", "==", "null", "||", "!", "StringUtils", ".", "hasText", "(", "propertyName", ")", ")", "{"...
Returns the type of the given property contained within the specified class @param clazz The class which contains the property @param propertyName The name of the property @return The property type or null if none exists
[ "Returns", "the", "type", "of", "the", "given", "property", "contained", "within", "the", "specified", "class" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L296-L312
32,470
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.getPropertiesAssignableToType
public static PropertyDescriptor[] getPropertiesAssignableToType(Class<?> clazz, Class<?> propertySuperType) { if (clazz == null || propertySuperType == null) return new PropertyDescriptor[0]; Set<PropertyDescriptor> properties = new HashSet<PropertyDescriptor>(); PropertyDescriptor descriptor = null; try { PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(clazz); for (int i = 0; i < descriptors.length; i++) { descriptor = descriptors[i]; Class<?> currentPropertyType = descriptor.getPropertyType(); if (propertySuperType.isAssignableFrom(descriptor.getPropertyType())) { properties.add(descriptor); } } } catch (Exception e) { if(descriptor == null) { LOG.error(String.format("Got exception while checking property descriptors for class %s", clazz.getName()), e); } else { LOG.error(String.format("Got exception while checking PropertyDescriptor.propertyType for field %s.%s", clazz.getName(), descriptor.getName()), e); } return new PropertyDescriptor[0]; } return properties.toArray(new PropertyDescriptor[properties.size()]); }
java
public static PropertyDescriptor[] getPropertiesAssignableToType(Class<?> clazz, Class<?> propertySuperType) { if (clazz == null || propertySuperType == null) return new PropertyDescriptor[0]; Set<PropertyDescriptor> properties = new HashSet<PropertyDescriptor>(); PropertyDescriptor descriptor = null; try { PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(clazz); for (int i = 0; i < descriptors.length; i++) { descriptor = descriptors[i]; Class<?> currentPropertyType = descriptor.getPropertyType(); if (propertySuperType.isAssignableFrom(descriptor.getPropertyType())) { properties.add(descriptor); } } } catch (Exception e) { if(descriptor == null) { LOG.error(String.format("Got exception while checking property descriptors for class %s", clazz.getName()), e); } else { LOG.error(String.format("Got exception while checking PropertyDescriptor.propertyType for field %s.%s", clazz.getName(), descriptor.getName()), e); } return new PropertyDescriptor[0]; } return properties.toArray(new PropertyDescriptor[properties.size()]); }
[ "public", "static", "PropertyDescriptor", "[", "]", "getPropertiesAssignableToType", "(", "Class", "<", "?", ">", "clazz", ",", "Class", "<", "?", ">", "propertySuperType", ")", "{", "if", "(", "clazz", "==", "null", "||", "propertySuperType", "==", "null", ...
Retrieves all the properties of the given class which are assignable to the given type @param clazz The class to retrieve the properties from @param propertySuperType The type of the properties you wish to retrieve @return An array of PropertyDescriptor instances
[ "Retrieves", "all", "the", "properties", "of", "the", "given", "class", "which", "are", "assignable", "to", "the", "given", "type" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L362-L386
32,471
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isMatchBetweenPrimativeAndWrapperTypes
@SuppressWarnings("rawtypes") public static boolean isMatchBetweenPrimativeAndWrapperTypes(Class leftType, Class rightType) { if (leftType == null) { throw new NullPointerException("Left type is null!"); } if (rightType == null) { throw new NullPointerException("Right type is null!"); } Class<?> r = PRIMITIVE_TYPE_COMPATIBLE_CLASSES.get(leftType); return r == rightType; }
java
@SuppressWarnings("rawtypes") public static boolean isMatchBetweenPrimativeAndWrapperTypes(Class leftType, Class rightType) { if (leftType == null) { throw new NullPointerException("Left type is null!"); } if (rightType == null) { throw new NullPointerException("Right type is null!"); } Class<?> r = PRIMITIVE_TYPE_COMPATIBLE_CLASSES.get(leftType); return r == rightType; }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "static", "boolean", "isMatchBetweenPrimativeAndWrapperTypes", "(", "Class", "leftType", ",", "Class", "rightType", ")", "{", "if", "(", "leftType", "==", "null", ")", "{", "throw", "new", "NullPointerEx...
Detect if left and right types are matching types. In particular, test if one is a primitive type and the other is the corresponding Java wrapper type. Primitive and wrapper classes may be passed to either arguments. @param leftType @param rightType @return true if one of the classes is a native type and the other the object representation of the same native type
[ "Detect", "if", "left", "and", "right", "types", "are", "matching", "types", ".", "In", "particular", "test", "if", "one", "is", "a", "primitive", "type", "and", "the", "other", "is", "the", "corresponding", "Java", "wrapper", "type", ".", "Primitive", "an...
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L457-L467
32,472
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isPublicStatic
public static boolean isPublicStatic(Method m) { final int modifiers = m.getModifiers(); return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers); }
java
public static boolean isPublicStatic(Method m) { final int modifiers = m.getModifiers(); return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers); }
[ "public", "static", "boolean", "isPublicStatic", "(", "Method", "m", ")", "{", "final", "int", "modifiers", "=", "m", ".", "getModifiers", "(", ")", ";", "return", "Modifier", ".", "isPublic", "(", "modifiers", ")", "&&", "Modifier", ".", "isStatic", "(", ...
Determine whether the method is declared public static @param m @return true if the method is declared public static
[ "Determine", "whether", "the", "method", "is", "declared", "public", "static" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L549-L552
32,473
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isPublicStatic
public static boolean isPublicStatic(Field f) { final int modifiers = f.getModifiers(); return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers); }
java
public static boolean isPublicStatic(Field f) { final int modifiers = f.getModifiers(); return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers); }
[ "public", "static", "boolean", "isPublicStatic", "(", "Field", "f", ")", "{", "final", "int", "modifiers", "=", "f", ".", "getModifiers", "(", ")", ";", "return", "Modifier", ".", "isPublic", "(", "modifiers", ")", "&&", "Modifier", ".", "isStatic", "(", ...
Determine whether the field is declared public static @param f @return true if the field is declared public static
[ "Determine", "whether", "the", "field", "is", "declared", "public", "static" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L559-L562
32,474
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.getFieldValue
public static Object getFieldValue(Object obj, String name) { Class<?> clazz = obj.getClass(); try { Field f = clazz.getDeclaredField(name); return f.get(obj); } catch (Exception e) { return null; } }
java
public static Object getFieldValue(Object obj, String name) { Class<?> clazz = obj.getClass(); try { Field f = clazz.getDeclaredField(name); return f.get(obj); } catch (Exception e) { return null; } }
[ "public", "static", "Object", "getFieldValue", "(", "Object", "obj", ",", "String", "name", ")", "{", "Class", "<", "?", ">", "clazz", "=", "obj", ".", "getClass", "(", ")", ";", "try", "{", "Field", "f", "=", "clazz", ".", "getDeclaredField", "(", "...
Get the value of a declared field on an object @param obj @param name @return The object value or null if there is no such field or access problems
[ "Get", "the", "value", "of", "a", "declared", "field", "on", "an", "object" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L655-L664
32,475
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isPublicField
public static boolean isPublicField(Object obj, String name) { Class<?> clazz = obj.getClass(); try { Field f = clazz.getDeclaredField(name); return Modifier.isPublic(f.getModifiers()); } catch (NoSuchFieldException e) { return false; } }
java
public static boolean isPublicField(Object obj, String name) { Class<?> clazz = obj.getClass(); try { Field f = clazz.getDeclaredField(name); return Modifier.isPublic(f.getModifiers()); } catch (NoSuchFieldException e) { return false; } }
[ "public", "static", "boolean", "isPublicField", "(", "Object", "obj", ",", "String", "name", ")", "{", "Class", "<", "?", ">", "clazz", "=", "obj", ".", "getClass", "(", ")", ";", "try", "{", "Field", "f", "=", "clazz", ".", "getDeclaredField", "(", ...
Work out if the specified object has a public field with the name supplied. @param obj @param name @return true if a public field with the name exists
[ "Work", "out", "if", "the", "specified", "object", "has", "a", "public", "field", "with", "the", "name", "supplied", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L673-L682
32,476
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isPropertyInherited
@SuppressWarnings("rawtypes") public static boolean isPropertyInherited(Class clz, String propertyName) { if (clz == null) return false; Assert.isTrue(StringUtils.hasText(propertyName), "Argument [propertyName] cannot be null or blank"); Class<?> superClass = clz.getSuperclass(); PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(superClass, propertyName); if (pd != null && pd.getReadMethod() != null) { return true; } return false; }
java
@SuppressWarnings("rawtypes") public static boolean isPropertyInherited(Class clz, String propertyName) { if (clz == null) return false; Assert.isTrue(StringUtils.hasText(propertyName), "Argument [propertyName] cannot be null or blank"); Class<?> superClass = clz.getSuperclass(); PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(superClass, propertyName); if (pd != null && pd.getReadMethod() != null) { return true; } return false; }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "static", "boolean", "isPropertyInherited", "(", "Class", "clz", ",", "String", "propertyName", ")", "{", "if", "(", "clz", "==", "null", ")", "return", "false", ";", "Assert", ".", "isTrue", "(", ...
Checks whether the specified property is inherited from a super class @param clz The class to check @param propertyName The property name @return true if the property is inherited
[ "Checks", "whether", "the", "specified", "property", "is", "inherited", "from", "a", "super", "class" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L691-L703
32,477
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isPropertyGetter
public static boolean isPropertyGetter(Method method) { return !Modifier.isStatic(method.getModifiers()) && Modifier.isPublic(method.getModifiers()) && GrailsNameUtils.isGetter(method.getName(), method.getReturnType(), method.getParameterTypes()); }
java
public static boolean isPropertyGetter(Method method) { return !Modifier.isStatic(method.getModifiers()) && Modifier.isPublic(method.getModifiers()) && GrailsNameUtils.isGetter(method.getName(), method.getReturnType(), method.getParameterTypes()); }
[ "public", "static", "boolean", "isPropertyGetter", "(", "Method", "method", ")", "{", "return", "!", "Modifier", ".", "isStatic", "(", "method", ".", "getModifiers", "(", ")", ")", "&&", "Modifier", ".", "isPublic", "(", "method", ".", "getModifiers", "(", ...
Check whether the specified method is a property getter @param method The method @return true if the method is a property getter
[ "Check", "whether", "the", "specified", "method", "is", "a", "property", "getter" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L711-L713
32,478
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.createConcreteCollection
@SuppressWarnings("rawtypes") public static Collection createConcreteCollection(Class interfaceType) { Collection elements; if (interfaceType.equals(List.class) || interfaceType.equals(Collection.class)) { elements = new ArrayList(); } else if (interfaceType.equals(SortedSet.class)) { elements = new TreeSet(); } else { elements = new HashSet(); } return elements; }
java
@SuppressWarnings("rawtypes") public static Collection createConcreteCollection(Class interfaceType) { Collection elements; if (interfaceType.equals(List.class) || interfaceType.equals(Collection.class)) { elements = new ArrayList(); } else if (interfaceType.equals(SortedSet.class)) { elements = new TreeSet(); } else { elements = new HashSet(); } return elements; }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "static", "Collection", "createConcreteCollection", "(", "Class", "interfaceType", ")", "{", "Collection", "elements", ";", "if", "(", "interfaceType", ".", "equals", "(", "List", ".", "class", ")", "|...
Creates a concrete collection for the suppied interface @param interfaceType The interface @return ArrayList for List, TreeSet for SortedSet, HashSet for Set etc.
[ "Creates", "a", "concrete", "collection", "for", "the", "suppied", "interface" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L720-L733
32,479
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isSetter
@SuppressWarnings("rawtypes") public static boolean isSetter(String name, Class[] args) { if (!StringUtils.hasText(name) || args == null)return false; if (name.startsWith("set")) { if (args.length != 1) return false; return GrailsNameUtils.isPropertyMethodSuffix(name.substring(3)); } return false; }
java
@SuppressWarnings("rawtypes") public static boolean isSetter(String name, Class[] args) { if (!StringUtils.hasText(name) || args == null)return false; if (name.startsWith("set")) { if (args.length != 1) return false; return GrailsNameUtils.isPropertyMethodSuffix(name.substring(3)); } return false; }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "static", "boolean", "isSetter", "(", "String", "name", ",", "Class", "[", "]", "args", ")", "{", "if", "(", "!", "StringUtils", ".", "hasText", "(", "name", ")", "||", "args", "==", "null", ...
Returns true if the name of the method specified and the number of arguments make it a javabean property setter. The name is assumed to be a valid Java method name, that is not verified. @param name The name of the method @param args The arguments @return true if it is a javabean property setter
[ "Returns", "true", "if", "the", "name", "of", "the", "method", "specified", "and", "the", "number", "of", "arguments", "make", "it", "a", "javabean", "property", "setter", ".", "The", "name", "is", "assumed", "to", "be", "a", "valid", "Java", "method", "...
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L743-L753
32,480
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isAssignableOrConvertibleFrom
public static boolean isAssignableOrConvertibleFrom(Class<?> clazz, Class<?> type) { if (type == null || clazz == null) { return false; } if (type.isPrimitive()) { // convert primitive type to compatible class Class<?> primitiveClass = GrailsClassUtils.PRIMITIVE_TYPE_COMPATIBLE_CLASSES.get(type); if (primitiveClass == null) { // no compatible class found for primitive type return false; } return clazz.isAssignableFrom(primitiveClass); } return clazz.isAssignableFrom(type); }
java
public static boolean isAssignableOrConvertibleFrom(Class<?> clazz, Class<?> type) { if (type == null || clazz == null) { return false; } if (type.isPrimitive()) { // convert primitive type to compatible class Class<?> primitiveClass = GrailsClassUtils.PRIMITIVE_TYPE_COMPATIBLE_CLASSES.get(type); if (primitiveClass == null) { // no compatible class found for primitive type return false; } return clazz.isAssignableFrom(primitiveClass); } return clazz.isAssignableFrom(type); }
[ "public", "static", "boolean", "isAssignableOrConvertibleFrom", "(", "Class", "<", "?", ">", "clazz", ",", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "type", "==", "null", "||", "clazz", "==", "null", ")", "{", "return", "false", ";", "}", ...
Returns true if the specified clazz parameter is either the same as, or is a superclass or superinterface of, the specified type parameter. Converts primitive types to compatible class automatically. @param clazz @param type @return true if the class is a taglib @see java.lang.Class#isAssignableFrom(Class)
[ "Returns", "true", "if", "the", "specified", "clazz", "parameter", "is", "either", "the", "same", "as", "or", "is", "a", "superclass", "or", "superinterface", "of", "the", "specified", "type", "parameter", ".", "Converts", "primitive", "types", "to", "compatib...
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L789-L803
32,481
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.findPropertyNameForValue
public static String findPropertyNameForValue(Object target, Object obj) { MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(target.getClass()); List<MetaProperty> metaProperties = mc.getProperties(); for (MetaProperty metaProperty : metaProperties) { if (isAssignableOrConvertibleFrom(metaProperty.getType(), obj.getClass())) { Object val = metaProperty.getProperty(target); if (val != null && val.equals(obj)) { return metaProperty.getName(); } } } return null; }
java
public static String findPropertyNameForValue(Object target, Object obj) { MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(target.getClass()); List<MetaProperty> metaProperties = mc.getProperties(); for (MetaProperty metaProperty : metaProperties) { if (isAssignableOrConvertibleFrom(metaProperty.getType(), obj.getClass())) { Object val = metaProperty.getProperty(target); if (val != null && val.equals(obj)) { return metaProperty.getName(); } } } return null; }
[ "public", "static", "String", "findPropertyNameForValue", "(", "Object", "target", ",", "Object", "obj", ")", "{", "MetaClass", "mc", "=", "GroovySystem", ".", "getMetaClassRegistry", "(", ")", ".", "getMetaClass", "(", "target", ".", "getClass", "(", ")", ")"...
Locates the name of a property for the given value on the target object using Groovy's meta APIs. Note that this method uses the reference so the incorrect result could be returned for two properties that refer to the same reference. Use with caution. @param target The target @param obj The property value @return The property name or null
[ "Locates", "the", "name", "of", "a", "property", "for", "the", "given", "value", "on", "the", "target", "object", "using", "Groovy", "s", "meta", "APIs", ".", "Note", "that", "this", "method", "uses", "the", "reference", "so", "the", "incorrect", "result",...
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L848-L860
32,482
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
GrailsClassUtils.isClassBelowPackage
public static boolean isClassBelowPackage(Class<?> theClass, List<?> packageList) { String classPackage = theClass.getPackage().getName(); for (Object packageName : packageList) { if (packageName != null) { if (classPackage.startsWith(packageName.toString())) { return true; } } } return false; }
java
public static boolean isClassBelowPackage(Class<?> theClass, List<?> packageList) { String classPackage = theClass.getPackage().getName(); for (Object packageName : packageList) { if (packageName != null) { if (classPackage.startsWith(packageName.toString())) { return true; } } } return false; }
[ "public", "static", "boolean", "isClassBelowPackage", "(", "Class", "<", "?", ">", "theClass", ",", "List", "<", "?", ">", "packageList", ")", "{", "String", "classPackage", "=", "theClass", ".", "getPackage", "(", ")", ".", "getName", "(", ")", ";", "fo...
Returns whether the specified class is either within one of the specified packages or within a subpackage of one of the packages @param theClass The class @param packageList The list of packages @return true if it is within the list of specified packages
[ "Returns", "whether", "the", "specified", "class", "is", "either", "within", "one", "of", "the", "specified", "packages", "or", "within", "a", "subpackage", "of", "one", "of", "the", "packages" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L952-L962
32,483
grails/grails-core
grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/AbstractUrlMappingInfo.java
AbstractUrlMappingInfo.populateParamsForMapping
protected void populateParamsForMapping(GrailsWebRequest webRequest) { Map dispatchParams = webRequest.getParams(); String encoding = webRequest.getRequest().getCharacterEncoding(); if (encoding == null) encoding = "UTF-8"; for (Map.Entry<String, Object> entry : params.entrySet()) { String name = entry.getKey(); Object param = entry.getValue(); if (param instanceof Closure) { param = evaluateNameForValue(param); } if (param instanceof CharSequence) { param = param.toString(); } dispatchParams.put(name, param); } final String viewName = getViewName(); if (viewName == null && getURI() == null) { webRequest.setControllerNamespace(getNamespace()); webRequest.setControllerName(getControllerName()); webRequest.setActionName(getActionName()); } String id = getId(); if (!GrailsStringUtils.isBlank(id)) try { dispatchParams.put(GrailsWebRequest.ID_PARAMETER, URLDecoder.decode(id, encoding)); } catch (UnsupportedEncodingException e) { dispatchParams.put(GrailsWebRequest.ID_PARAMETER, id); } }
java
protected void populateParamsForMapping(GrailsWebRequest webRequest) { Map dispatchParams = webRequest.getParams(); String encoding = webRequest.getRequest().getCharacterEncoding(); if (encoding == null) encoding = "UTF-8"; for (Map.Entry<String, Object> entry : params.entrySet()) { String name = entry.getKey(); Object param = entry.getValue(); if (param instanceof Closure) { param = evaluateNameForValue(param); } if (param instanceof CharSequence) { param = param.toString(); } dispatchParams.put(name, param); } final String viewName = getViewName(); if (viewName == null && getURI() == null) { webRequest.setControllerNamespace(getNamespace()); webRequest.setControllerName(getControllerName()); webRequest.setActionName(getActionName()); } String id = getId(); if (!GrailsStringUtils.isBlank(id)) try { dispatchParams.put(GrailsWebRequest.ID_PARAMETER, URLDecoder.decode(id, encoding)); } catch (UnsupportedEncodingException e) { dispatchParams.put(GrailsWebRequest.ID_PARAMETER, id); } }
[ "protected", "void", "populateParamsForMapping", "(", "GrailsWebRequest", "webRequest", ")", "{", "Map", "dispatchParams", "=", "webRequest", ".", "getParams", "(", ")", ";", "String", "encoding", "=", "webRequest", ".", "getRequest", "(", ")", ".", "getCharacterE...
Populates request parameters for the given UrlMappingInfo instance using the GrailsWebRequest @param webRequest The Map instance @see org.grails.web.servlet.mvc.GrailsWebRequest
[ "Populates", "request", "parameters", "for", "the", "given", "UrlMappingInfo", "instance", "using", "the", "GrailsWebRequest" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/AbstractUrlMappingInfo.java#L77-L108
32,484
grails/grails-core
grails-core/src/main/groovy/grails/util/GrailsMetaClassUtils.java
GrailsMetaClassUtils.copyExpandoMetaClass
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void copyExpandoMetaClass(Class<?> fromClass, Class<?> toClass, boolean removeSource) { MetaClassRegistry registry = getRegistry(); MetaClass oldMetaClass = registry.getMetaClass(fromClass); AdaptingMetaClass adapter = null; ExpandoMetaClass emc; if (oldMetaClass instanceof AdaptingMetaClass) { adapter = ((AdaptingMetaClass)oldMetaClass); emc = (ExpandoMetaClass)adapter.getAdaptee(); if (LOG.isDebugEnabled()) { LOG.debug("Obtained adapted MetaClass ["+emc+"] from AdapterMetaClass instance ["+adapter+"]"); } if (removeSource) { registry.removeMetaClass(fromClass); } } else { emc = (ExpandoMetaClass)oldMetaClass; if (LOG.isDebugEnabled()) { LOG.debug("No adapter MetaClass found, using original ["+emc+"]"); } } ExpandoMetaClass replacement = new ExpandoMetaClass(toClass, true, true); for (Object obj : emc.getExpandoMethods()) { if (obj instanceof ClosureInvokingMethod) { ClosureInvokingMethod cim = (ClosureInvokingMethod) obj; Closure callable = cim.getClosure(); if (!cim.isStatic()) { replacement.setProperty(cim.getName(), callable); } else { ((GroovyObject)replacement.getProperty(ExpandoMetaClass.STATIC_QUALIFIER)).setProperty(cim.getName(),callable); } } } for (Object o : emc.getExpandoProperties()) { if (o instanceof ThreadManagedMetaBeanProperty) { ThreadManagedMetaBeanProperty mbp = (ThreadManagedMetaBeanProperty)o; replacement.setProperty(mbp.getName(), mbp.getInitialValue()); } } replacement.initialize(); if (adapter == null) { if (LOG.isDebugEnabled()) { LOG.debug("Adding MetaClass for class ["+toClass+"] MetaClass ["+replacement+"]"); } registry.setMetaClass(toClass, replacement); } else { if (LOG.isDebugEnabled()) { LOG.debug("Adding MetaClass for class [" + toClass + "] MetaClass [" + replacement + "] with adapter [" + adapter + "]"); } try { Constructor c = adapter.getClass().getConstructor(new Class[]{MetaClass.class}); MetaClass newAdapter = (MetaClass) BeanUtils.instantiateClass(c,new Object[]{replacement}); registry.setMetaClass(toClass,newAdapter); } catch (NoSuchMethodException e) { if (LOG.isDebugEnabled()) { LOG.debug("Exception thrown constructing new MetaClass adapter when reloading: " + e.getMessage(),e); } } } }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void copyExpandoMetaClass(Class<?> fromClass, Class<?> toClass, boolean removeSource) { MetaClassRegistry registry = getRegistry(); MetaClass oldMetaClass = registry.getMetaClass(fromClass); AdaptingMetaClass adapter = null; ExpandoMetaClass emc; if (oldMetaClass instanceof AdaptingMetaClass) { adapter = ((AdaptingMetaClass)oldMetaClass); emc = (ExpandoMetaClass)adapter.getAdaptee(); if (LOG.isDebugEnabled()) { LOG.debug("Obtained adapted MetaClass ["+emc+"] from AdapterMetaClass instance ["+adapter+"]"); } if (removeSource) { registry.removeMetaClass(fromClass); } } else { emc = (ExpandoMetaClass)oldMetaClass; if (LOG.isDebugEnabled()) { LOG.debug("No adapter MetaClass found, using original ["+emc+"]"); } } ExpandoMetaClass replacement = new ExpandoMetaClass(toClass, true, true); for (Object obj : emc.getExpandoMethods()) { if (obj instanceof ClosureInvokingMethod) { ClosureInvokingMethod cim = (ClosureInvokingMethod) obj; Closure callable = cim.getClosure(); if (!cim.isStatic()) { replacement.setProperty(cim.getName(), callable); } else { ((GroovyObject)replacement.getProperty(ExpandoMetaClass.STATIC_QUALIFIER)).setProperty(cim.getName(),callable); } } } for (Object o : emc.getExpandoProperties()) { if (o instanceof ThreadManagedMetaBeanProperty) { ThreadManagedMetaBeanProperty mbp = (ThreadManagedMetaBeanProperty)o; replacement.setProperty(mbp.getName(), mbp.getInitialValue()); } } replacement.initialize(); if (adapter == null) { if (LOG.isDebugEnabled()) { LOG.debug("Adding MetaClass for class ["+toClass+"] MetaClass ["+replacement+"]"); } registry.setMetaClass(toClass, replacement); } else { if (LOG.isDebugEnabled()) { LOG.debug("Adding MetaClass for class [" + toClass + "] MetaClass [" + replacement + "] with adapter [" + adapter + "]"); } try { Constructor c = adapter.getClass().getConstructor(new Class[]{MetaClass.class}); MetaClass newAdapter = (MetaClass) BeanUtils.instantiateClass(c,new Object[]{replacement}); registry.setMetaClass(toClass,newAdapter); } catch (NoSuchMethodException e) { if (LOG.isDebugEnabled()) { LOG.debug("Exception thrown constructing new MetaClass adapter when reloading: " + e.getMessage(),e); } } } }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "static", "void", "copyExpandoMetaClass", "(", "Class", "<", "?", ">", "fromClass", ",", "Class", "<", "?", ">", "toClass", ",", "boolean", "removeSource", ")", "{",...
Copies the ExpandoMetaClass dynamic methods and properties from one Class to another. @param fromClass The source class @param toClass The destination class @param removeSource Whether to remove the source class after completion. True if yes
[ "Copies", "the", "ExpandoMetaClass", "dynamic", "methods", "and", "properties", "from", "one", "Class", "to", "another", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsMetaClassUtils.java#L66-L139
32,485
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/json/JSONTokener.java
JSONTokener.skipPast
public void skipPast(String to) { this.myIndex = this.mySource.indexOf(to, this.myIndex); if (this.myIndex < 0) { this.myIndex = this.mySource.length(); } else { this.myIndex += to.length(); } }
java
public void skipPast(String to) { this.myIndex = this.mySource.indexOf(to, this.myIndex); if (this.myIndex < 0) { this.myIndex = this.mySource.length(); } else { this.myIndex += to.length(); } }
[ "public", "void", "skipPast", "(", "String", "to", ")", "{", "this", ".", "myIndex", "=", "this", ".", "mySource", ".", "indexOf", "(", "to", ",", "this", ".", "myIndex", ")", ";", "if", "(", "this", ".", "myIndex", "<", "0", ")", "{", "this", "....
Skip characters until past the requested string. If it is not found, we are left at the end of the source. @param to A string to skip past.
[ "Skip", "characters", "until", "past", "the", "requested", "string", ".", "If", "it", "is", "not", "found", "we", "are", "left", "at", "the", "end", "of", "the", "source", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/json/JSONTokener.java#L453-L460
32,486
grails/grails-core
grails-core/src/main/groovy/grails/util/CacheEntry.java
CacheEntry.getValue
@SuppressWarnings({ "unchecked", "rawtypes" }) public static <K, V> V getValue(ConcurrentMap<K, CacheEntry<V>> map, K key, long timeoutMillis, Callable<V> updater, Callable<? extends CacheEntry> cacheEntryFactory, boolean returnExpiredWhileUpdating, Object cacheRequestObject) { CacheEntry<V> cacheEntry = map.get(key); if(cacheEntry==null) { try { cacheEntry = cacheEntryFactory.call(); } catch (Exception e) { throw new UpdateException(e); } CacheEntry<V> previousEntry = map.putIfAbsent(key, cacheEntry); if(previousEntry != null) { cacheEntry = previousEntry; } } try { return cacheEntry.getValue(timeoutMillis, updater, returnExpiredWhileUpdating, cacheRequestObject); } catch (UpdateException e) { e.rethrowRuntimeException(); // make compiler happy return null; } }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static <K, V> V getValue(ConcurrentMap<K, CacheEntry<V>> map, K key, long timeoutMillis, Callable<V> updater, Callable<? extends CacheEntry> cacheEntryFactory, boolean returnExpiredWhileUpdating, Object cacheRequestObject) { CacheEntry<V> cacheEntry = map.get(key); if(cacheEntry==null) { try { cacheEntry = cacheEntryFactory.call(); } catch (Exception e) { throw new UpdateException(e); } CacheEntry<V> previousEntry = map.putIfAbsent(key, cacheEntry); if(previousEntry != null) { cacheEntry = previousEntry; } } try { return cacheEntry.getValue(timeoutMillis, updater, returnExpiredWhileUpdating, cacheRequestObject); } catch (UpdateException e) { e.rethrowRuntimeException(); // make compiler happy return null; } }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "static", "<", "K", ",", "V", ">", "V", "getValue", "(", "ConcurrentMap", "<", "K", ",", "CacheEntry", "<", "V", ">", ">", "map", ",", "K", "key", ",", "long...
Gets a value from cache. If the key doesn't exist, it will create the value using the updater callback Prevents cache storms with a lock The key is always added to the cache. Null return values will also be cached. You can use this together with ConcurrentLinkedHashMap to create a bounded LRU cache @param map the cache map @param key the key to look up @param timeoutMillis cache entry timeout @param updater callback to create/update value @param cacheEntryClass CacheEntry implementation class to use @param returnExpiredWhileUpdating when true, return expired value while updating new value @param cacheRequestObject context object that gets passed to hasExpired, shouldUpdate and updateValue methods, not used in default implementation @return
[ "Gets", "a", "value", "from", "cache", ".", "If", "the", "key", "doesn", "t", "exist", "it", "will", "create", "the", "value", "using", "the", "updater", "callback", "Prevents", "cache", "storms", "with", "a", "lock" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/CacheEntry.java#L72-L95
32,487
grails/grails-core
grails-core/src/main/groovy/grails/util/CacheEntry.java
CacheEntry.getValue
public V getValue(long timeout, Callable<V> updater, boolean returnExpiredWhileUpdating, Object cacheRequestObject) { if (!isInitialized() || hasExpired(timeout, cacheRequestObject)) { boolean lockAcquired = false; try { long beforeLockingCreatedMillis = createdMillis; if(returnExpiredWhileUpdating) { if(!writeLock.tryLock()) { if(isInitialized()) { return getValueWhileUpdating(cacheRequestObject); } else { if(LOG.isDebugEnabled()) { LOG.debug("Locking cache for update"); } writeLock.lock(); } } } else { LOG.debug("Locking cache for update"); writeLock.lock(); } lockAcquired = true; V value; if (!isInitialized() || shouldUpdate(beforeLockingCreatedMillis, cacheRequestObject)) { try { value = updateValue(getValue(), updater, cacheRequestObject); if(LOG.isDebugEnabled()) { LOG.debug("Updating cache for value [{}]", value); } setValue(value); } catch (Exception e) { throw new UpdateException(e); } } else { value = getValue(); resetTimestamp(false); } return value; } finally { if(lockAcquired) { if(LOG.isDebugEnabled()) { LOG.debug("Unlocking cache for update"); } writeLock.unlock(); } } } else { return getValue(); } }
java
public V getValue(long timeout, Callable<V> updater, boolean returnExpiredWhileUpdating, Object cacheRequestObject) { if (!isInitialized() || hasExpired(timeout, cacheRequestObject)) { boolean lockAcquired = false; try { long beforeLockingCreatedMillis = createdMillis; if(returnExpiredWhileUpdating) { if(!writeLock.tryLock()) { if(isInitialized()) { return getValueWhileUpdating(cacheRequestObject); } else { if(LOG.isDebugEnabled()) { LOG.debug("Locking cache for update"); } writeLock.lock(); } } } else { LOG.debug("Locking cache for update"); writeLock.lock(); } lockAcquired = true; V value; if (!isInitialized() || shouldUpdate(beforeLockingCreatedMillis, cacheRequestObject)) { try { value = updateValue(getValue(), updater, cacheRequestObject); if(LOG.isDebugEnabled()) { LOG.debug("Updating cache for value [{}]", value); } setValue(value); } catch (Exception e) { throw new UpdateException(e); } } else { value = getValue(); resetTimestamp(false); } return value; } finally { if(lockAcquired) { if(LOG.isDebugEnabled()) { LOG.debug("Unlocking cache for update"); } writeLock.unlock(); } } } else { return getValue(); } }
[ "public", "V", "getValue", "(", "long", "timeout", ",", "Callable", "<", "V", ">", "updater", ",", "boolean", "returnExpiredWhileUpdating", ",", "Object", "cacheRequestObject", ")", "{", "if", "(", "!", "isInitialized", "(", ")", "||", "hasExpired", "(", "ti...
gets the current value from the entry and updates it if it's older than timeout updater is a callback for creating an updated value. @param timeout @param updater @param returnExpiredWhileUpdating @param cacheRequestObject @return the current value
[ "gets", "the", "current", "value", "from", "the", "entry", "and", "updates", "it", "if", "it", "s", "older", "than", "timeout" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/CacheEntry.java#L128-L177
32,488
grails/grails-core
grails-encoder/src/main/groovy/org/grails/encoder/CodecLookupHelper.java
CodecLookupHelper.lookupEncoder
public static Encoder lookupEncoder(GrailsApplication grailsApplication, String codecName) { ApplicationContext ctx = grailsApplication != null ? grailsApplication.getMainContext() : null; if(ctx != null) { try { CodecLookup codecLookup = ctx.getBean("codecLookup", CodecLookup.class); return codecLookup.lookupEncoder(codecName); } catch (NoSuchBeanDefinitionException e) { // ignore missing codecLookup bean in tests log.debug("codecLookup bean is missing from test context.", e); } } return null; }
java
public static Encoder lookupEncoder(GrailsApplication grailsApplication, String codecName) { ApplicationContext ctx = grailsApplication != null ? grailsApplication.getMainContext() : null; if(ctx != null) { try { CodecLookup codecLookup = ctx.getBean("codecLookup", CodecLookup.class); return codecLookup.lookupEncoder(codecName); } catch (NoSuchBeanDefinitionException e) { // ignore missing codecLookup bean in tests log.debug("codecLookup bean is missing from test context.", e); } } return null; }
[ "public", "static", "Encoder", "lookupEncoder", "(", "GrailsApplication", "grailsApplication", ",", "String", "codecName", ")", "{", "ApplicationContext", "ctx", "=", "grailsApplication", "!=", "null", "?", "grailsApplication", ".", "getMainContext", "(", ")", ":", ...
Lookup encoder. @param grailsApplication the grailsApplication instance @param codecName the codec name @return the encoder instance
[ "Lookup", "encoder", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/encoder/CodecLookupHelper.java#L37-L49
32,489
grails/grails-core
grails-core/src/main/groovy/org/grails/core/support/internal/tools/MetaClassChangeReporter.java
MetaClassChangeReporter.updateConstantMetaClass
public void updateConstantMetaClass(MetaClassRegistryChangeEvent cmcu) { Class<?> classToUpdate = cmcu.getClassToUpdate(); MetaClass newMetaClass = cmcu.getNewMetaClass(); System.out.println("Class ["+classToUpdate+"] updated MetaClass to ["+newMetaClass+"]"); Thread.dumpStack(); }
java
public void updateConstantMetaClass(MetaClassRegistryChangeEvent cmcu) { Class<?> classToUpdate = cmcu.getClassToUpdate(); MetaClass newMetaClass = cmcu.getNewMetaClass(); System.out.println("Class ["+classToUpdate+"] updated MetaClass to ["+newMetaClass+"]"); Thread.dumpStack(); }
[ "public", "void", "updateConstantMetaClass", "(", "MetaClassRegistryChangeEvent", "cmcu", ")", "{", "Class", "<", "?", ">", "classToUpdate", "=", "cmcu", ".", "getClassToUpdate", "(", ")", ";", "MetaClass", "newMetaClass", "=", "cmcu", ".", "getNewMetaClass", "(",...
Called when the a constant MetaClass is updated. If the new MetaClass is null, then the MetaClass is removed. Be careful, while this method is executed other updates may happen. If you want this method thread safe, you have to take care of that by yourself. @param cmcu - the change event
[ "Called", "when", "the", "a", "constant", "MetaClass", "is", "updated", ".", "If", "the", "new", "MetaClass", "is", "null", "then", "the", "MetaClass", "is", "removed", ".", "Be", "careful", "while", "this", "method", "is", "executed", "other", "updates", ...
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/core/support/internal/tools/MetaClassChangeReporter.java#L36-L42
32,490
grails/grails-core
grails-bootstrap/src/main/groovy/grails/util/GrailsNameUtils.java
GrailsNameUtils.getPropertyForSetter
public static String getPropertyForSetter(String setterName) { if (setterName == null || setterName.length() == 0) return null; if (setterName.startsWith("set")) { String prop = setterName.substring(3); return convertValidPropertyMethodSuffix(prop); } return null; }
java
public static String getPropertyForSetter(String setterName) { if (setterName == null || setterName.length() == 0) return null; if (setterName.startsWith("set")) { String prop = setterName.substring(3); return convertValidPropertyMethodSuffix(prop); } return null; }
[ "public", "static", "String", "getPropertyForSetter", "(", "String", "setterName", ")", "{", "if", "(", "setterName", "==", "null", "||", "setterName", ".", "length", "(", ")", "==", "0", ")", "return", "null", ";", "if", "(", "setterName", ".", "startsWit...
Returns a property name equivalent for the given setter name or null if it is not a valid setter. If not null or empty the setter name is assumed to be a valid identifier. @param setterName The setter name, must be null or empty or a valid identifier name @return The property name equivalent
[ "Returns", "a", "property", "name", "equivalent", "for", "the", "given", "setter", "name", "or", "null", "if", "it", "is", "not", "a", "valid", "setter", ".", "If", "not", "null", "or", "empty", "the", "setter", "name", "is", "assumed", "to", "be", "a"...
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-bootstrap/src/main/groovy/grails/util/GrailsNameUtils.java#L712-L720
32,491
grails/grails-core
grails-plugin-controllers/src/main/groovy/org/grails/compiler/web/ControllerActionTransformer.java
ControllerActionTransformer.convertToMethodAction
private MethodNode convertToMethodAction(ClassNode classNode, MethodNode methodNode, SourceUnit source, GeneratorContext context) { final ClassNode returnType = methodNode.getReturnType(); Parameter[] parameters = methodNode.getParameters(); for (Parameter param : parameters) { if (param.hasInitialExpression()) { String paramName = param.getName(); String methodName = methodNode.getName(); String initialValue = param.getInitialExpression().getText(); String methodDeclaration = methodNode.getText(); String message = "Parameter [%s] to method [%s] has default value [%s]. " + "Default parameter values are not allowed in controller action methods. ([%s])"; String formattedMessage = String.format(message, paramName, methodName, initialValue, methodDeclaration); GrailsASTUtils.error(source, methodNode, formattedMessage); } } MethodNode method = null; if (methodNode.getParameters().length > 0) { final BlockStatement methodCode = new BlockStatement(); final BlockStatement codeToHandleAllowedMethods = getCodeToHandleAllowedMethods(classNode, methodNode.getName()); final Statement codeToCallOriginalMethod = addOriginalMethodCall(methodNode, initializeActionParameters( classNode, methodNode, methodNode.getName(), parameters, source, context)); methodCode.addStatement(codeToHandleAllowedMethods); methodCode.addStatement(codeToCallOriginalMethod); method = new MethodNode( methodNode.getName(), Modifier.PUBLIC, returnType, ZERO_PARAMETERS, EMPTY_CLASS_ARRAY, methodCode); GrailsASTUtils.copyAnnotations(methodNode, method); methodNode.addAnnotation(DELEGATING_METHOD_ANNOATION); annotateActionMethod(classNode, parameters, method); wrapMethodBodyWithExceptionHandling(classNode, method); } else { annotateActionMethod(classNode, parameters, methodNode); } wrapMethodBodyWithExceptionHandling(classNode, methodNode); return method; }
java
private MethodNode convertToMethodAction(ClassNode classNode, MethodNode methodNode, SourceUnit source, GeneratorContext context) { final ClassNode returnType = methodNode.getReturnType(); Parameter[] parameters = methodNode.getParameters(); for (Parameter param : parameters) { if (param.hasInitialExpression()) { String paramName = param.getName(); String methodName = methodNode.getName(); String initialValue = param.getInitialExpression().getText(); String methodDeclaration = methodNode.getText(); String message = "Parameter [%s] to method [%s] has default value [%s]. " + "Default parameter values are not allowed in controller action methods. ([%s])"; String formattedMessage = String.format(message, paramName, methodName, initialValue, methodDeclaration); GrailsASTUtils.error(source, methodNode, formattedMessage); } } MethodNode method = null; if (methodNode.getParameters().length > 0) { final BlockStatement methodCode = new BlockStatement(); final BlockStatement codeToHandleAllowedMethods = getCodeToHandleAllowedMethods(classNode, methodNode.getName()); final Statement codeToCallOriginalMethod = addOriginalMethodCall(methodNode, initializeActionParameters( classNode, methodNode, methodNode.getName(), parameters, source, context)); methodCode.addStatement(codeToHandleAllowedMethods); methodCode.addStatement(codeToCallOriginalMethod); method = new MethodNode( methodNode.getName(), Modifier.PUBLIC, returnType, ZERO_PARAMETERS, EMPTY_CLASS_ARRAY, methodCode); GrailsASTUtils.copyAnnotations(methodNode, method); methodNode.addAnnotation(DELEGATING_METHOD_ANNOATION); annotateActionMethod(classNode, parameters, method); wrapMethodBodyWithExceptionHandling(classNode, method); } else { annotateActionMethod(classNode, parameters, methodNode); } wrapMethodBodyWithExceptionHandling(classNode, methodNode); return method; }
[ "private", "MethodNode", "convertToMethodAction", "(", "ClassNode", "classNode", ",", "MethodNode", "methodNode", ",", "SourceUnit", "source", ",", "GeneratorContext", "context", ")", "{", "final", "ClassNode", "returnType", "=", "methodNode", ".", "getReturnType", "(...
Converts a method into a controller action. If the method accepts parameters, a no-arg counterpart is created which delegates to the original. @param classNode The controller class @param methodNode The method to be converted @return The no-arg wrapper method, or null if none was created.
[ "Converts", "a", "method", "into", "a", "controller", "action", ".", "If", "the", "method", "accepts", "parameters", "a", "no", "-", "arg", "counterpart", "is", "created", "which", "delegates", "to", "the", "original", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-plugin-controllers/src/main/groovy/org/grails/compiler/web/ControllerActionTransformer.java#L356-L407
32,492
grails/grails-core
grails-plugin-controllers/src/main/groovy/org/grails/compiler/web/ControllerActionTransformer.java
ControllerActionTransformer.doesModulePathIncludeSubstring
private boolean doesModulePathIncludeSubstring(ModuleNode moduleNode, final String substring) { if (moduleNode == null) { return false; } boolean substringFoundInDescription = false; String commandObjectModuleDescription = moduleNode.getDescription(); if (commandObjectModuleDescription != null) { substringFoundInDescription = commandObjectModuleDescription.contains(substring); } return substringFoundInDescription; }
java
private boolean doesModulePathIncludeSubstring(ModuleNode moduleNode, final String substring) { if (moduleNode == null) { return false; } boolean substringFoundInDescription = false; String commandObjectModuleDescription = moduleNode.getDescription(); if (commandObjectModuleDescription != null) { substringFoundInDescription = commandObjectModuleDescription.contains(substring); } return substringFoundInDescription; }
[ "private", "boolean", "doesModulePathIncludeSubstring", "(", "ModuleNode", "moduleNode", ",", "final", "String", "substring", ")", "{", "if", "(", "moduleNode", "==", "null", ")", "{", "return", "false", ";", "}", "boolean", "substringFoundInDescription", "=", "fa...
Checks to see if a Module is defined at a path which includes the specified substring @param moduleNode a ModuleNode @param substring The substring to search for @return true if moduleNode is defined at a path which includes the specified substring
[ "Checks", "to", "see", "if", "a", "Module", "is", "defined", "at", "a", "path", "which", "includes", "the", "specified", "substring" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-plugin-controllers/src/main/groovy/org/grails/compiler/web/ControllerActionTransformer.java#L855-L867
32,493
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java
GroovyPagesUriSupport.getViewURI
public String getViewURI(GroovyObject controller, String viewName) { return getViewURI(getLogicalControllerName(controller), viewName); }
java
public String getViewURI(GroovyObject controller, String viewName) { return getViewURI(getLogicalControllerName(controller), viewName); }
[ "public", "String", "getViewURI", "(", "GroovyObject", "controller", ",", "String", "viewName", ")", "{", "return", "getViewURI", "(", "getLogicalControllerName", "(", "controller", ")", ",", "viewName", ")", ";", "}" ]
Obtains a view URI of the given controller and view name @param controller The name of the controller @param viewName The name of the view @return The view URI
[ "Obtains", "a", "view", "URI", "of", "the", "given", "controller", "and", "view", "name" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java#L69-L71
32,494
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java
GroovyPagesUriSupport.getNoSuffixViewURI
public String getNoSuffixViewURI(GroovyObject controller, String viewName) { return getNoSuffixViewURI(getLogicalControllerName(controller), viewName); }
java
public String getNoSuffixViewURI(GroovyObject controller, String viewName) { return getNoSuffixViewURI(getLogicalControllerName(controller), viewName); }
[ "public", "String", "getNoSuffixViewURI", "(", "GroovyObject", "controller", ",", "String", "viewName", ")", "{", "return", "getNoSuffixViewURI", "(", "getLogicalControllerName", "(", "controller", ")", ",", "viewName", ")", ";", "}" ]
Obtains a view URI of the given controller and view name without the suffix @param controller The name of the controller @param viewName The name of the view @return The view URI
[ "Obtains", "a", "view", "URI", "of", "the", "given", "controller", "and", "view", "name", "without", "the", "suffix" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java#L79-L81
32,495
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java
GroovyPagesUriSupport.getAbsoluteTemplateURI
public String getAbsoluteTemplateURI(String templateName, boolean includeExtension) { FastStringWriter buf = new FastStringWriter(); String tmp = templateName.substring(1,templateName.length()); if (tmp.indexOf(SLASH) > -1) { buf.append(SLASH); int i = tmp.lastIndexOf(SLASH); buf.append(tmp.substring(0, i)); buf.append(SLASH_UNDR); buf.append(tmp.substring(i + 1,tmp.length())); } else { buf.append(SLASH_UNDR); buf.append(templateName.substring(1,templateName.length())); } if (includeExtension) { buf.append(EXTENSION); } String uri = buf.toString(); buf.close(); return uri; }
java
public String getAbsoluteTemplateURI(String templateName, boolean includeExtension) { FastStringWriter buf = new FastStringWriter(); String tmp = templateName.substring(1,templateName.length()); if (tmp.indexOf(SLASH) > -1) { buf.append(SLASH); int i = tmp.lastIndexOf(SLASH); buf.append(tmp.substring(0, i)); buf.append(SLASH_UNDR); buf.append(tmp.substring(i + 1,tmp.length())); } else { buf.append(SLASH_UNDR); buf.append(templateName.substring(1,templateName.length())); } if (includeExtension) { buf.append(EXTENSION); } String uri = buf.toString(); buf.close(); return uri; }
[ "public", "String", "getAbsoluteTemplateURI", "(", "String", "templateName", ",", "boolean", "includeExtension", ")", "{", "FastStringWriter", "buf", "=", "new", "FastStringWriter", "(", ")", ";", "String", "tmp", "=", "templateName", ".", "substring", "(", "1", ...
Used to resolve template names that are not relative to a controller. @param templateName The template name normally beginning with / @param includeExtension The flag to include the template extension @return The template URI
[ "Used", "to", "resolve", "template", "names", "that", "are", "not", "relative", "to", "a", "controller", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java#L157-L177
32,496
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java
GroovyPagesUriSupport.getViewURI
public String getViewURI(String controllerName, String viewName) { FastStringWriter buf = new FastStringWriter(); return getViewURIInternal(controllerName, viewName, buf, true); }
java
public String getViewURI(String controllerName, String viewName) { FastStringWriter buf = new FastStringWriter(); return getViewURIInternal(controllerName, viewName, buf, true); }
[ "public", "String", "getViewURI", "(", "String", "controllerName", ",", "String", "viewName", ")", "{", "FastStringWriter", "buf", "=", "new", "FastStringWriter", "(", ")", ";", "return", "getViewURIInternal", "(", "controllerName", ",", "viewName", ",", "buf", ...
Obtains a view URI of the given controller name and view name @param controllerName The name of the controller @param viewName The name of the view @return The view URI
[ "Obtains", "a", "view", "URI", "of", "the", "given", "controller", "name", "and", "view", "name" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java#L186-L190
32,497
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java
GroovyPagesUriSupport.getAbsoluteViewURI
public String getAbsoluteViewURI(String viewName) { FastStringWriter buf = new FastStringWriter(); return getAbsoluteViewURIInternal(viewName, buf, true); }
java
public String getAbsoluteViewURI(String viewName) { FastStringWriter buf = new FastStringWriter(); return getAbsoluteViewURIInternal(viewName, buf, true); }
[ "public", "String", "getAbsoluteViewURI", "(", "String", "viewName", ")", "{", "FastStringWriter", "buf", "=", "new", "FastStringWriter", "(", ")", ";", "return", "getAbsoluteViewURIInternal", "(", "viewName", ",", "buf", ",", "true", ")", ";", "}" ]
Obtains a view URI that is not relative to any given controller @param viewName The name of the view @return The view URI
[ "Obtains", "a", "view", "URI", "that", "is", "not", "relative", "to", "any", "given", "controller" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java#L198-L201
32,498
grails/grails-core
grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java
GroovyPagesUriSupport.getNoSuffixViewURI
public String getNoSuffixViewURI(String controllerName, String viewName) { FastStringWriter buf = new FastStringWriter(); return getViewURIInternal(controllerName, viewName, buf, false); }
java
public String getNoSuffixViewURI(String controllerName, String viewName) { FastStringWriter buf = new FastStringWriter(); return getViewURIInternal(controllerName, viewName, buf, false); }
[ "public", "String", "getNoSuffixViewURI", "(", "String", "controllerName", ",", "String", "viewName", ")", "{", "FastStringWriter", "buf", "=", "new", "FastStringWriter", "(", ")", ";", "return", "getViewURIInternal", "(", "controllerName", ",", "viewName", ",", "...
Obtains a view URI of the given controller name and view name without the suffix @param controllerName The name of the controller @param viewName The name of the view @return The view URI
[ "Obtains", "a", "view", "URI", "of", "the", "given", "controller", "name", "and", "view", "name", "without", "the", "suffix" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java#L209-L213
32,499
grails/grails-core
grails-encoder/src/main/groovy/org/grails/encoder/DefaultEncodingStateRegistry.java
DefaultEncodingStateRegistry.shouldEncodeWith
public static boolean shouldEncodeWith(Encoder encoderToApply, EncodingState currentEncodingState) { if(isNoneEncoder(encoderToApply)) return false; if (currentEncodingState != null && currentEncodingState.getEncoders() != null) { for (Encoder encoder : currentEncodingState.getEncoders()) { if (isPreviousEncoderSafeOrEqual(encoderToApply, encoder)) { return false; } } } return true; }
java
public static boolean shouldEncodeWith(Encoder encoderToApply, EncodingState currentEncodingState) { if(isNoneEncoder(encoderToApply)) return false; if (currentEncodingState != null && currentEncodingState.getEncoders() != null) { for (Encoder encoder : currentEncodingState.getEncoders()) { if (isPreviousEncoderSafeOrEqual(encoderToApply, encoder)) { return false; } } } return true; }
[ "public", "static", "boolean", "shouldEncodeWith", "(", "Encoder", "encoderToApply", ",", "EncodingState", "currentEncodingState", ")", "{", "if", "(", "isNoneEncoder", "(", "encoderToApply", ")", ")", "return", "false", ";", "if", "(", "currentEncodingState", "!=",...
Checks if encoder should be applied to a input with given encoding state @param encoderToApply the encoder to apply @param currentEncodingState the current encoding state @return true, if should encode
[ "Checks", "if", "encoder", "should", "be", "applied", "to", "a", "input", "with", "given", "encoding", "state" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/encoder/DefaultEncodingStateRegistry.java#L100-L110