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
144,700
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.createBottomSheetBuilder
private BottomSheet.Builder createBottomSheetBuilder() { BottomSheet.Builder builder = new BottomSheet.Builder(getActivity()); builder.setStyle(getStyle()); if (shouldTitleBeShown()) { builder.setTitle(getBottomSheetTitle()); } if (shouldIconBeShown()) { builder.setIcon(android.R.drawable.ic_dialog_alert); } return builder; }
java
private BottomSheet.Builder createBottomSheetBuilder() { BottomSheet.Builder builder = new BottomSheet.Builder(getActivity()); builder.setStyle(getStyle()); if (shouldTitleBeShown()) { builder.setTitle(getBottomSheetTitle()); } if (shouldIconBeShown()) { builder.setIcon(android.R.drawable.ic_dialog_alert); } return builder; }
[ "private", "BottomSheet", ".", "Builder", "createBottomSheetBuilder", "(", ")", "{", "BottomSheet", ".", "Builder", "builder", "=", "new", "BottomSheet", ".", "Builder", "(", "getActivity", "(", ")", ")", ";", "builder", ".", "setStyle", "(", "getStyle", "(", ")", ")", ";", "if", "(", "shouldTitleBeShown", "(", ")", ")", "{", "builder", ".", "setTitle", "(", "getBottomSheetTitle", "(", ")", ")", ";", "}", "if", "(", "shouldIconBeShown", "(", ")", ")", "{", "builder", ".", "setIcon", "(", "android", ".", "R", ".", "drawable", ".", "ic_dialog_alert", ")", ";", "}", "return", "builder", ";", "}" ]
Creates and returns a builder, which allows to create bottom sheets, depending on the app's settings. @return The builder, which has been created, as an instance of the class {@link BottomSheet.Builder}
[ "Creates", "and", "returns", "a", "builder", "which", "allows", "to", "create", "bottom", "sheets", "depending", "on", "the", "app", "s", "settings", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L211-L224
144,701
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.addItems
private void addItems(@NonNull final BottomSheet.Builder builder) { int dividerCount = getDividerCount(); boolean showDividerTitle = shouldDividerTitleBeShown(); int itemCount = getItemCount(); boolean showIcon = shouldItemIconsBeShown(); boolean disableItems = shouldItemsBeDisabled(); int index = 0; for (int i = 0; i < dividerCount + 1; i++) { if (i > 0) { builder.addDivider(showDividerTitle ? getString(R.string.divider_title, i) : null); index++; } for (int j = 0; j < itemCount; j++) { String title = getString(R.string.item_title, i * itemCount + j + 1); Drawable icon; if (isDarkThemeSet()) { icon = showIcon ? ContextCompat.getDrawable(getActivity(), getStyle() == Style.GRID ? R.drawable.grid_item_dark : R.drawable.list_item_dark) : null; } else { icon = showIcon ? ContextCompat.getDrawable(getActivity(), getStyle() == Style.GRID ? R.drawable.grid_item : R.drawable.list_item) : null; } builder.addItem(i * dividerCount + j, title, icon); if (disableItems) { builder.setItemEnabled(index, false); } index++; } } builder.setOnItemClickListener(createItemClickListener()); }
java
private void addItems(@NonNull final BottomSheet.Builder builder) { int dividerCount = getDividerCount(); boolean showDividerTitle = shouldDividerTitleBeShown(); int itemCount = getItemCount(); boolean showIcon = shouldItemIconsBeShown(); boolean disableItems = shouldItemsBeDisabled(); int index = 0; for (int i = 0; i < dividerCount + 1; i++) { if (i > 0) { builder.addDivider(showDividerTitle ? getString(R.string.divider_title, i) : null); index++; } for (int j = 0; j < itemCount; j++) { String title = getString(R.string.item_title, i * itemCount + j + 1); Drawable icon; if (isDarkThemeSet()) { icon = showIcon ? ContextCompat.getDrawable(getActivity(), getStyle() == Style.GRID ? R.drawable.grid_item_dark : R.drawable.list_item_dark) : null; } else { icon = showIcon ? ContextCompat.getDrawable(getActivity(), getStyle() == Style.GRID ? R.drawable.grid_item : R.drawable.list_item) : null; } builder.addItem(i * dividerCount + j, title, icon); if (disableItems) { builder.setItemEnabled(index, false); } index++; } } builder.setOnItemClickListener(createItemClickListener()); }
[ "private", "void", "addItems", "(", "@", "NonNull", "final", "BottomSheet", ".", "Builder", "builder", ")", "{", "int", "dividerCount", "=", "getDividerCount", "(", ")", ";", "boolean", "showDividerTitle", "=", "shouldDividerTitleBeShown", "(", ")", ";", "int", "itemCount", "=", "getItemCount", "(", ")", ";", "boolean", "showIcon", "=", "shouldItemIconsBeShown", "(", ")", ";", "boolean", "disableItems", "=", "shouldItemsBeDisabled", "(", ")", ";", "int", "index", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dividerCount", "+", "1", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "builder", ".", "addDivider", "(", "showDividerTitle", "?", "getString", "(", "R", ".", "string", ".", "divider_title", ",", "i", ")", ":", "null", ")", ";", "index", "++", ";", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "itemCount", ";", "j", "++", ")", "{", "String", "title", "=", "getString", "(", "R", ".", "string", ".", "item_title", ",", "i", "*", "itemCount", "+", "j", "+", "1", ")", ";", "Drawable", "icon", ";", "if", "(", "isDarkThemeSet", "(", ")", ")", "{", "icon", "=", "showIcon", "?", "ContextCompat", ".", "getDrawable", "(", "getActivity", "(", ")", ",", "getStyle", "(", ")", "==", "Style", ".", "GRID", "?", "R", ".", "drawable", ".", "grid_item_dark", ":", "R", ".", "drawable", ".", "list_item_dark", ")", ":", "null", ";", "}", "else", "{", "icon", "=", "showIcon", "?", "ContextCompat", ".", "getDrawable", "(", "getActivity", "(", ")", ",", "getStyle", "(", ")", "==", "Style", ".", "GRID", "?", "R", ".", "drawable", ".", "grid_item", ":", "R", ".", "drawable", ".", "list_item", ")", ":", "null", ";", "}", "builder", ".", "addItem", "(", "i", "*", "dividerCount", "+", "j", ",", "title", ",", "icon", ")", ";", "if", "(", "disableItems", ")", "{", "builder", ".", "setItemEnabled", "(", "index", ",", "false", ")", ";", "}", "index", "++", ";", "}", "}", "builder", ".", "setOnItemClickListener", "(", "createItemClickListener", "(", ")", ")", ";", "}" ]
Adds items, depending on the app's settings, to a builder, which allows to create a bottom sheet. @param builder The builder, which allows to create the bottom sheet, as an instance of the class {@link BottomSheet.Builder}. The builder may not be null
[ "Adds", "items", "depending", "on", "the", "app", "s", "settings", "to", "a", "builder", "which", "allows", "to", "create", "a", "bottom", "sheet", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L234-L273
144,702
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.getStyle
private Style getStyle() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.bottom_sheet_style_preference_key); String defaultValue = getString(R.string.bottom_sheet_style_preference_default_value); String style = sharedPreferences.getString(key, defaultValue); switch (style) { case "list": return Style.LIST; case "list_columns": return Style.LIST_COLUMNS; default: return Style.GRID; } }
java
private Style getStyle() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.bottom_sheet_style_preference_key); String defaultValue = getString(R.string.bottom_sheet_style_preference_default_value); String style = sharedPreferences.getString(key, defaultValue); switch (style) { case "list": return Style.LIST; case "list_columns": return Style.LIST_COLUMNS; default: return Style.GRID; } }
[ "private", "Style", "getStyle", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "bottom_sheet_style_preference_key", ")", ";", "String", "defaultValue", "=", "getString", "(", "R", ".", "string", ".", "bottom_sheet_style_preference_default_value", ")", ";", "String", "style", "=", "sharedPreferences", ".", "getString", "(", "key", ",", "defaultValue", ")", ";", "switch", "(", "style", ")", "{", "case", "\"list\"", ":", "return", "Style", ".", "LIST", ";", "case", "\"list_columns\"", ":", "return", "Style", ".", "LIST_COLUMNS", ";", "default", ":", "return", "Style", ".", "GRID", ";", "}", "}" ]
Returns the style, which should be used to create bottom sheets, depending on the app's settings. @return The style, which should be used to create bottom sheets, as a value of the enum {@link Style}
[ "Returns", "the", "style", "which", "should", "be", "used", "to", "create", "bottom", "sheets", "depending", "on", "the", "app", "s", "settings", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L302-L317
144,703
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.shouldTitleBeShown
private boolean shouldTitleBeShown() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.show_bottom_sheet_title_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.show_bottom_sheet_title_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
java
private boolean shouldTitleBeShown() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.show_bottom_sheet_title_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.show_bottom_sheet_title_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
[ "private", "boolean", "shouldTitleBeShown", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "show_bottom_sheet_title_preference_key", ")", ";", "boolean", "defaultValue", "=", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "show_bottom_sheet_title_preference_default_value", ")", ";", "return", "sharedPreferences", ".", "getBoolean", "(", "key", ",", "defaultValue", ")", ";", "}" ]
Returns, whether the title of bottom sheets should be shown, depending on the app's settings, or not. @return True, if the title of bottom sheets should be shown, false otherwise
[ "Returns", "whether", "the", "title", "of", "bottom", "sheets", "should", "be", "shown", "depending", "on", "the", "app", "s", "settings", "or", "not", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L325-L332
144,704
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.getBottomSheetTitle
private String getBottomSheetTitle() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.bottom_sheet_title_preference_key); String defaultValue = getString(R.string.bottom_sheet_title_preference_default_value); return sharedPreferences.getString(key, defaultValue); }
java
private String getBottomSheetTitle() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.bottom_sheet_title_preference_key); String defaultValue = getString(R.string.bottom_sheet_title_preference_default_value); return sharedPreferences.getString(key, defaultValue); }
[ "private", "String", "getBottomSheetTitle", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "bottom_sheet_title_preference_key", ")", ";", "String", "defaultValue", "=", "getString", "(", "R", ".", "string", ".", "bottom_sheet_title_preference_default_value", ")", ";", "return", "sharedPreferences", ".", "getString", "(", "key", ",", "defaultValue", ")", ";", "}" ]
Returns the title of bottom sheets, depending on the app's settings. @return The title of the bottom sheets
[ "Returns", "the", "title", "of", "bottom", "sheets", "depending", "on", "the", "app", "s", "settings", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L339-L345
144,705
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.shouldIconBeShown
private boolean shouldIconBeShown() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.show_bottom_sheet_icon_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.show_bottom_sheet_icon_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
java
private boolean shouldIconBeShown() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.show_bottom_sheet_icon_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.show_bottom_sheet_icon_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
[ "private", "boolean", "shouldIconBeShown", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "show_bottom_sheet_icon_preference_key", ")", ";", "boolean", "defaultValue", "=", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "show_bottom_sheet_icon_preference_default_value", ")", ";", "return", "sharedPreferences", ".", "getBoolean", "(", "key", ",", "defaultValue", ")", ";", "}" ]
Returns, whether the icon of bottom sheets should be shown, depending on the app's settings, or not. @return True, if the icon of bottom sheets should be shown, false otherwise
[ "Returns", "whether", "the", "icon", "of", "bottom", "sheets", "should", "be", "shown", "depending", "on", "the", "app", "s", "settings", "or", "not", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L353-L360
144,706
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.getDividerCount
private int getDividerCount() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.divider_count_preference_key); String defaultValue = getString(R.string.divider_count_preference_default_value); return Integer.valueOf(sharedPreferences.getString(key, defaultValue)); }
java
private int getDividerCount() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.divider_count_preference_key); String defaultValue = getString(R.string.divider_count_preference_default_value); return Integer.valueOf(sharedPreferences.getString(key, defaultValue)); }
[ "private", "int", "getDividerCount", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "divider_count_preference_key", ")", ";", "String", "defaultValue", "=", "getString", "(", "R", ".", "string", ".", "divider_count_preference_default_value", ")", ";", "return", "Integer", ".", "valueOf", "(", "sharedPreferences", ".", "getString", "(", "key", ",", "defaultValue", ")", ")", ";", "}" ]
Returns the number of dividers, which should be shown, depending on the app's settings. @return The number of dividers, which should be shown, as an {@link Integer} value
[ "Returns", "the", "number", "of", "dividers", "which", "should", "be", "shown", "depending", "on", "the", "app", "s", "settings", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L367-L373
144,707
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.shouldDividerTitleBeShown
private boolean shouldDividerTitleBeShown() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.show_divider_title_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.show_divider_title_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
java
private boolean shouldDividerTitleBeShown() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.show_divider_title_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.show_divider_title_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
[ "private", "boolean", "shouldDividerTitleBeShown", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "show_divider_title_preference_key", ")", ";", "boolean", "defaultValue", "=", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "show_divider_title_preference_default_value", ")", ";", "return", "sharedPreferences", ".", "getBoolean", "(", "key", ",", "defaultValue", ")", ";", "}" ]
Returns, whether the title of dividers should be shown, depending on the app's settings, or not. @return True, if the title of dividers should be shown, false otherwise
[ "Returns", "whether", "the", "title", "of", "dividers", "should", "be", "shown", "depending", "on", "the", "app", "s", "settings", "or", "not", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L381-L388
144,708
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.getItemCount
private int getItemCount() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.item_count_preference_key); String defaultValue = getString(R.string.item_count_preference_default_value); return Integer.valueOf(sharedPreferences.getString(key, defaultValue)); }
java
private int getItemCount() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.item_count_preference_key); String defaultValue = getString(R.string.item_count_preference_default_value); return Integer.valueOf(sharedPreferences.getString(key, defaultValue)); }
[ "private", "int", "getItemCount", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "item_count_preference_key", ")", ";", "String", "defaultValue", "=", "getString", "(", "R", ".", "string", ".", "item_count_preference_default_value", ")", ";", "return", "Integer", ".", "valueOf", "(", "sharedPreferences", ".", "getString", "(", "key", ",", "defaultValue", ")", ")", ";", "}" ]
Returns the number of items, which should be shown per divider, depending on the app's settings. @return The number of items, which should be shown per divider, as an {@link Integer} value
[ "Returns", "the", "number", "of", "items", "which", "should", "be", "shown", "per", "divider", "depending", "on", "the", "app", "s", "settings", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L396-L402
144,709
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.shouldItemIconsBeShown
private boolean shouldItemIconsBeShown() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.show_item_icons_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.show_item_icons_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
java
private boolean shouldItemIconsBeShown() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.show_item_icons_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.show_item_icons_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
[ "private", "boolean", "shouldItemIconsBeShown", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "show_item_icons_preference_key", ")", ";", "boolean", "defaultValue", "=", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "show_item_icons_preference_default_value", ")", ";", "return", "sharedPreferences", ".", "getBoolean", "(", "key", ",", "defaultValue", ")", ";", "}" ]
Returns, whether icons should be shown next to items, depending on the app's settings, or not. @return True, if icons should be shown next to items, false otherwise
[ "Returns", "whether", "icons", "should", "be", "shown", "next", "to", "items", "depending", "on", "the", "app", "s", "settings", "or", "not", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L410-L417
144,710
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.shouldItemsBeDisabled
private boolean shouldItemsBeDisabled() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.disable_items_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.disable_items_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
java
private boolean shouldItemsBeDisabled() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.disable_items_preference_key); boolean defaultValue = getResources().getBoolean(R.bool.disable_items_preference_default_value); return sharedPreferences.getBoolean(key, defaultValue); }
[ "private", "boolean", "shouldItemsBeDisabled", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "disable_items_preference_key", ")", ";", "boolean", "defaultValue", "=", "getResources", "(", ")", ".", "getBoolean", "(", "R", ".", "bool", ".", "disable_items_preference_default_value", ")", ";", "return", "sharedPreferences", ".", "getBoolean", "(", "key", ",", "defaultValue", ")", ";", "}" ]
Returns, whether items should be disabled, depending on the app's settings, or not. @return True, if items should be disabled, false otherwise.
[ "Returns", "whether", "items", "should", "be", "disabled", "depending", "on", "the", "app", "s", "settings", "or", "not", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L424-L431
144,711
michael-rapp/AndroidBottomSheet
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
PreferenceFragment.isDarkThemeSet
private boolean isDarkThemeSet() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.theme_preference_key); String defaultValue = getString(R.string.theme_preference_default_value); return Integer.valueOf(sharedPreferences.getString(key, defaultValue)) != 0; }
java
private boolean isDarkThemeSet() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String key = getString(R.string.theme_preference_key); String defaultValue = getString(R.string.theme_preference_default_value); return Integer.valueOf(sharedPreferences.getString(key, defaultValue)) != 0; }
[ "private", "boolean", "isDarkThemeSet", "(", ")", "{", "SharedPreferences", "sharedPreferences", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "getActivity", "(", ")", ")", ";", "String", "key", "=", "getString", "(", "R", ".", "string", ".", "theme_preference_key", ")", ";", "String", "defaultValue", "=", "getString", "(", "R", ".", "string", ".", "theme_preference_default_value", ")", ";", "return", "Integer", ".", "valueOf", "(", "sharedPreferences", ".", "getString", "(", "key", ",", "defaultValue", ")", ")", "!=", "0", ";", "}" ]
Returns, whether the app uses the dark theme, or not. @return True, if the app uses the dark theme, false otherwise
[ "Returns", "whether", "the", "app", "uses", "the", "dark", "theme", "or", "not", "." ]
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L438-L444
144,712
codecentric/zucchini
zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/token/TokenList.java
TokenList.detectVariableValues
public Map<String, String> detectVariableValues(TokenList tokenList) { Map<String, String> variables = new HashMap<String, String>(); boolean thisContainsVariables = containsVariables(); boolean thatContainsVariables = tokenList.containsVariables(); // If both lists contain variables, we get into trouble. if (thisContainsVariables && thatContainsVariables) { throw new VariableValueDetectionException("Cannot detect variable values if both token lists contain variables."); } // If both lists don't contain variables, no variables can be detected and we can return the empty map. if (!thisContainsVariables && !thatContainsVariables) { return variables; } ListIterator<Token> iteratorWithVariables = (thisContainsVariables ? this : tokenList).listIterator(); ListIterator<Token> iteratorWithoutVariables = (thisContainsVariables ? tokenList : this).listIterator(); // We now know that {@code iteratorWithVariables} contains at least one variable. We iterate over both lists // simultaneously and if {@code possibleVariableToken} is a {@link VariableToken}, we know that // {@code literalToken} contains the value for this variable. while (iteratorWithVariables.hasNext() && iteratorWithoutVariables.hasNext()) { Token possibleVariableToken = iteratorWithVariables.next(); Token literalToken = iteratorWithoutVariables.next(); if (possibleVariableToken instanceof VariableToken) { variables.put(possibleVariableToken.getText(), literalToken.getText()); } } return variables; }
java
public Map<String, String> detectVariableValues(TokenList tokenList) { Map<String, String> variables = new HashMap<String, String>(); boolean thisContainsVariables = containsVariables(); boolean thatContainsVariables = tokenList.containsVariables(); // If both lists contain variables, we get into trouble. if (thisContainsVariables && thatContainsVariables) { throw new VariableValueDetectionException("Cannot detect variable values if both token lists contain variables."); } // If both lists don't contain variables, no variables can be detected and we can return the empty map. if (!thisContainsVariables && !thatContainsVariables) { return variables; } ListIterator<Token> iteratorWithVariables = (thisContainsVariables ? this : tokenList).listIterator(); ListIterator<Token> iteratorWithoutVariables = (thisContainsVariables ? tokenList : this).listIterator(); // We now know that {@code iteratorWithVariables} contains at least one variable. We iterate over both lists // simultaneously and if {@code possibleVariableToken} is a {@link VariableToken}, we know that // {@code literalToken} contains the value for this variable. while (iteratorWithVariables.hasNext() && iteratorWithoutVariables.hasNext()) { Token possibleVariableToken = iteratorWithVariables.next(); Token literalToken = iteratorWithoutVariables.next(); if (possibleVariableToken instanceof VariableToken) { variables.put(possibleVariableToken.getText(), literalToken.getText()); } } return variables; }
[ "public", "Map", "<", "String", ",", "String", ">", "detectVariableValues", "(", "TokenList", "tokenList", ")", "{", "Map", "<", "String", ",", "String", ">", "variables", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "boolean", "thisContainsVariables", "=", "containsVariables", "(", ")", ";", "boolean", "thatContainsVariables", "=", "tokenList", ".", "containsVariables", "(", ")", ";", "// If both lists contain variables, we get into trouble.", "if", "(", "thisContainsVariables", "&&", "thatContainsVariables", ")", "{", "throw", "new", "VariableValueDetectionException", "(", "\"Cannot detect variable values if both token lists contain variables.\"", ")", ";", "}", "// If both lists don't contain variables, no variables can be detected and we can return the empty map.", "if", "(", "!", "thisContainsVariables", "&&", "!", "thatContainsVariables", ")", "{", "return", "variables", ";", "}", "ListIterator", "<", "Token", ">", "iteratorWithVariables", "=", "(", "thisContainsVariables", "?", "this", ":", "tokenList", ")", ".", "listIterator", "(", ")", ";", "ListIterator", "<", "Token", ">", "iteratorWithoutVariables", "=", "(", "thisContainsVariables", "?", "tokenList", ":", "this", ")", ".", "listIterator", "(", ")", ";", "// We now know that {@code iteratorWithVariables} contains at least one variable. We iterate over both lists", "// simultaneously and if {@code possibleVariableToken} is a {@link VariableToken}, we know that", "// {@code literalToken} contains the value for this variable.", "while", "(", "iteratorWithVariables", ".", "hasNext", "(", ")", "&&", "iteratorWithoutVariables", ".", "hasNext", "(", ")", ")", "{", "Token", "possibleVariableToken", "=", "iteratorWithVariables", ".", "next", "(", ")", ";", "Token", "literalToken", "=", "iteratorWithoutVariables", ".", "next", "(", ")", ";", "if", "(", "possibleVariableToken", "instanceof", "VariableToken", ")", "{", "variables", ".", "put", "(", "possibleVariableToken", ".", "getText", "(", ")", ",", "literalToken", ".", "getText", "(", ")", ")", ";", "}", "}", "return", "variables", ";", "}" ]
Detects variable values using another token list. Usually, one is working with two token lists. One list contains literals and variables and the other token list contains only literals. Both lists match are then compared to find values (literals of the second list) for variables in the first list. Example: - Token list 1: "a", "b", var "x", var "y" - Token list 2: "a", "b", "c", "d" The detected variables are: - variable["x"] = "c" - variable["y"] = "d" Note: Only one list may contain zero or more variables. An exception is thrown if both lists contain variables. @param tokenList The other token list. @return A map containing variable names and variable values. @throws de.codecentric.zucchini.bdd.resolver.token.VariableValueDetectionException Thrown if both lists contain variables.
[ "Detects", "variable", "values", "using", "another", "token", "list", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/token/TokenList.java#L51-L82
144,713
codecentric/zucchini
zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/token/TokenList.java
TokenList.tokenTypesMatch
private boolean tokenTypesMatch(Token token1, Token token2, Class<? extends Token> tokenType) { return tokenType.isAssignableFrom(token1.getClass()) && tokenType.isAssignableFrom(token2.getClass()); }
java
private boolean tokenTypesMatch(Token token1, Token token2, Class<? extends Token> tokenType) { return tokenType.isAssignableFrom(token1.getClass()) && tokenType.isAssignableFrom(token2.getClass()); }
[ "private", "boolean", "tokenTypesMatch", "(", "Token", "token1", ",", "Token", "token2", ",", "Class", "<", "?", "extends", "Token", ">", "tokenType", ")", "{", "return", "tokenType", ".", "isAssignableFrom", "(", "token1", ".", "getClass", "(", ")", ")", "&&", "tokenType", ".", "isAssignableFrom", "(", "token2", ".", "getClass", "(", ")", ")", ";", "}" ]
Checks whether both tokens have the specified type. @param token1 The first token to check. @param token2 The second token to check. @param tokenType The type that both tokens must have. @return {@literal true} if both tokens have the specified type, and {@literal false} otherwise.
[ "Checks", "whether", "both", "tokens", "have", "the", "specified", "type", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/token/TokenList.java#L197-L199
144,714
codecentric/zucchini
zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/token/TokenList.java
TokenList.tokenTextsDoNotMatch
private boolean tokenTextsDoNotMatch(Token token1, Token token2) { return !token1.getText().equals(token2.getText()); }
java
private boolean tokenTextsDoNotMatch(Token token1, Token token2) { return !token1.getText().equals(token2.getText()); }
[ "private", "boolean", "tokenTextsDoNotMatch", "(", "Token", "token1", ",", "Token", "token2", ")", "{", "return", "!", "token1", ".", "getText", "(", ")", ".", "equals", "(", "token2", ".", "getText", "(", ")", ")", ";", "}" ]
Checks whether both tokens have the same texts. @param token1 The first token to check. @param token2 The second token to check. @return {@literal true} if the tokens do not have the same texts, and {@literal false} otherwise.
[ "Checks", "whether", "both", "tokens", "have", "the", "same", "texts", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/token/TokenList.java#L208-L210
144,715
codecentric/zucchini
zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/StatementResolverHolder.java
StatementResolverHolder.setStatementResolver
@SuppressWarnings("WeakerAccess") public static void setStatementResolver(StatementResolver statementResolver) { if (statementResolver == null) { throw new NullPointerException("The statement resolver must not be null."); } StatementResolverHolder.STATEMENT_RESOLVER.set(statementResolver); }
java
@SuppressWarnings("WeakerAccess") public static void setStatementResolver(StatementResolver statementResolver) { if (statementResolver == null) { throw new NullPointerException("The statement resolver must not be null."); } StatementResolverHolder.STATEMENT_RESOLVER.set(statementResolver); }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "public", "static", "void", "setStatementResolver", "(", "StatementResolver", "statementResolver", ")", "{", "if", "(", "statementResolver", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"The statement resolver must not be null.\"", ")", ";", "}", "StatementResolverHolder", ".", "STATEMENT_RESOLVER", ".", "set", "(", "statementResolver", ")", ";", "}" ]
Sets the statement resolver for the current thread. @param statementResolver The statement resolver for the current thread.
[ "Sets", "the", "statement", "resolver", "for", "the", "current", "thread", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/StatementResolverHolder.java#L47-L53
144,716
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/util/WebAssert.java
WebAssert.findElementOrFail
public static WebElement findElementOrFail(WebDriver webDriver, By element) { try { return webDriver.findElement(element); } catch (NoSuchElementException e) { fail(String.format("Element %s should exist but it does not.", element.toString()), e); } /** * Never reached since {@link de.codecentric.zucchini.bdd.util.Assert#fail(String)} fail()} throws * {@link java.lang.AssertionError}. */ return null; }
java
public static WebElement findElementOrFail(WebDriver webDriver, By element) { try { return webDriver.findElement(element); } catch (NoSuchElementException e) { fail(String.format("Element %s should exist but it does not.", element.toString()), e); } /** * Never reached since {@link de.codecentric.zucchini.bdd.util.Assert#fail(String)} fail()} throws * {@link java.lang.AssertionError}. */ return null; }
[ "public", "static", "WebElement", "findElementOrFail", "(", "WebDriver", "webDriver", ",", "By", "element", ")", "{", "try", "{", "return", "webDriver", ".", "findElement", "(", "element", ")", ";", "}", "catch", "(", "NoSuchElementException", "e", ")", "{", "fail", "(", "String", ".", "format", "(", "\"Element %s should exist but it does not.\"", ",", "element", ".", "toString", "(", ")", ")", ",", "e", ")", ";", "}", "/**\n\t\t * Never reached since {@link de.codecentric.zucchini.bdd.util.Assert#fail(String)} fail()} throws\n\t\t * {@link java.lang.AssertionError}.\n\t\t */", "return", "null", ";", "}" ]
Tries to find a specific element and fails if the element could not be found. @param webDriver The web driver. @param element The element. @return The found element.
[ "Tries", "to", "find", "a", "specific", "element", "and", "fails", "if", "the", "element", "could", "not", "be", "found", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/util/WebAssert.java#L37-L48
144,717
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/TypeStep.java
TypeStep.go
@Override public void go() { logger.info("Typing \"{}\"...", (Object) keys); new Actions(getWebDriver()).sendKeys(Keys.ENTER); }
java
@Override public void go() { logger.info("Typing \"{}\"...", (Object) keys); new Actions(getWebDriver()).sendKeys(Keys.ENTER); }
[ "@", "Override", "public", "void", "go", "(", ")", "{", "logger", ".", "info", "(", "\"Typing \\\"{}\\\"...\"", ",", "(", "Object", ")", "keys", ")", ";", "new", "Actions", "(", "getWebDriver", "(", ")", ")", ".", "sendKeys", "(", "Keys", ".", "ENTER", ")", ";", "}" ]
Types the keys.
[ "Types", "the", "keys", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/TypeStep.java#L69-L73
144,718
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/WebDriverExecutor.java
WebDriverExecutor.failOnInvalidContext
protected void failOnInvalidContext(ExecutionContext executionContext) { for (Fact fact : executionContext.getFacts()) { failOnInvalidFact(fact); } for (Step step : executionContext.getSteps()) { failOnInvalidStep(step); } for (Result result : executionContext.getResults()) { failOnInvalidResult(result); } }
java
protected void failOnInvalidContext(ExecutionContext executionContext) { for (Fact fact : executionContext.getFacts()) { failOnInvalidFact(fact); } for (Step step : executionContext.getSteps()) { failOnInvalidStep(step); } for (Result result : executionContext.getResults()) { failOnInvalidResult(result); } }
[ "protected", "void", "failOnInvalidContext", "(", "ExecutionContext", "executionContext", ")", "{", "for", "(", "Fact", "fact", ":", "executionContext", ".", "getFacts", "(", ")", ")", "{", "failOnInvalidFact", "(", "fact", ")", ";", "}", "for", "(", "Step", "step", ":", "executionContext", ".", "getSteps", "(", ")", ")", "{", "failOnInvalidStep", "(", "step", ")", ";", "}", "for", "(", "Result", "result", ":", "executionContext", ".", "getResults", "(", ")", ")", "{", "failOnInvalidResult", "(", "result", ")", ";", "}", "}" ]
This method validates the execution context. Delegating statements and prepared statements are supported. @param executionContext The context that shall be validated.
[ "This", "method", "validates", "the", "execution", "context", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/WebDriverExecutor.java#L115-L125
144,719
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/results/NotResult.java
NotResult.expect
@Override public void expect() { try { webResult.setWebDriver(getWebDriver()); webResult.expect(); fail("Result should fail but it did not."); } catch (Exception e) { logger.debug("Negated failure:", e); } catch (AssertionError e) { logger.debug("Negated failure:", e); } }
java
@Override public void expect() { try { webResult.setWebDriver(getWebDriver()); webResult.expect(); fail("Result should fail but it did not."); } catch (Exception e) { logger.debug("Negated failure:", e); } catch (AssertionError e) { logger.debug("Negated failure:", e); } }
[ "@", "Override", "public", "void", "expect", "(", ")", "{", "try", "{", "webResult", ".", "setWebDriver", "(", "getWebDriver", "(", ")", ")", ";", "webResult", ".", "expect", "(", ")", ";", "fail", "(", "\"Result should fail but it did not.\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "debug", "(", "\"Negated failure:\"", ",", "e", ")", ";", "}", "catch", "(", "AssertionError", "e", ")", "{", "logger", ".", "debug", "(", "\"Negated failure:\"", ",", "e", ")", ";", "}", "}" ]
Expects that the specified web result fails.
[ "Expects", "that", "the", "specified", "web", "result", "fails", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/results/NotResult.java#L55-L66
144,720
codecentric/zucchini
zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/token/Tokenizer.java
Tokenizer.findTokens
private void findTokens() { mergedTokens = new TokenList(); variable = null; state = TokenizerState.START; index = -1; while (index < rawTokens.length) { switch (state) { case START: next(TokenizerState.OUTSIDE_VARIABLE_CONTEXT); break; case OUTSIDE_VARIABLE_CONTEXT: handleTokenOutsideOfVariableContext(); break; case INSIDE_VARIABLE_CONTEXT: handleTokenInsideOfVariableContext(); break; default: break; } } }
java
private void findTokens() { mergedTokens = new TokenList(); variable = null; state = TokenizerState.START; index = -1; while (index < rawTokens.length) { switch (state) { case START: next(TokenizerState.OUTSIDE_VARIABLE_CONTEXT); break; case OUTSIDE_VARIABLE_CONTEXT: handleTokenOutsideOfVariableContext(); break; case INSIDE_VARIABLE_CONTEXT: handleTokenInsideOfVariableContext(); break; default: break; } } }
[ "private", "void", "findTokens", "(", ")", "{", "mergedTokens", "=", "new", "TokenList", "(", ")", ";", "variable", "=", "null", ";", "state", "=", "TokenizerState", ".", "START", ";", "index", "=", "-", "1", ";", "while", "(", "index", "<", "rawTokens", ".", "length", ")", "{", "switch", "(", "state", ")", "{", "case", "START", ":", "next", "(", "TokenizerState", ".", "OUTSIDE_VARIABLE_CONTEXT", ")", ";", "break", ";", "case", "OUTSIDE_VARIABLE_CONTEXT", ":", "handleTokenOutsideOfVariableContext", "(", ")", ";", "break", ";", "case", "INSIDE_VARIABLE_CONTEXT", ":", "handleTokenInsideOfVariableContext", "(", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}", "}" ]
Finds tokens within the split statement name.
[ "Finds", "tokens", "within", "the", "split", "statement", "name", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-bdd/src/main/java/de/codecentric/zucchini/bdd/resolver/token/Tokenizer.java#L138-L159
144,721
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/WaitStep.java
WaitStep.go
@Override public void go() { logger.info("Waiting {} seconds...", sleepTime); try { Thread.sleep(sleepTime); } catch (InterruptedException e) { throw new ExecutionException("Thread could not sleep.", e); } }
java
@Override public void go() { logger.info("Waiting {} seconds...", sleepTime); try { Thread.sleep(sleepTime); } catch (InterruptedException e) { throw new ExecutionException("Thread could not sleep.", e); } }
[ "@", "Override", "public", "void", "go", "(", ")", "{", "logger", ".", "info", "(", "\"Waiting {} seconds...\"", ",", "sleepTime", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "sleepTime", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "ExecutionException", "(", "\"Thread could not sleep.\"", ",", "e", ")", ";", "}", "}" ]
Waits for the specified sleep time.
[ "Waits", "for", "the", "specified", "sleep", "time", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/WaitStep.java#L114-L122
144,722
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/TypeIntoStep.java
TypeIntoStep.go
@Override public void go() { logger.info("Typing \"{}\" into {}...", keys, element); findElementOrFail(getWebDriver(), element).sendKeys(keys); }
java
@Override public void go() { logger.info("Typing \"{}\" into {}...", keys, element); findElementOrFail(getWebDriver(), element).sendKeys(keys); }
[ "@", "Override", "public", "void", "go", "(", ")", "{", "logger", ".", "info", "(", "\"Typing \\\"{}\\\" into {}...\"", ",", "keys", ",", "element", ")", ";", "findElementOrFail", "(", "getWebDriver", "(", ")", ",", "element", ")", ".", "sendKeys", "(", "keys", ")", ";", "}" ]
Types into the element.
[ "Types", "into", "the", "element", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/TypeIntoStep.java#L68-L72
144,723
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/WaitForStep.java
WaitForStep.go
@Override public void go() { logger.info("Waiting {} seconds for {}...", timeout, element); WebDriverWait waiting = new WebDriverWait(getWebDriver(), timeout); try { waiting.until(ExpectedConditions.presenceOfElementLocated(element)); } catch (NullPointerException e) { fail(String.format("Element %s did not appear within %d seconds.", element, timeout), e); } }
java
@Override public void go() { logger.info("Waiting {} seconds for {}...", timeout, element); WebDriverWait waiting = new WebDriverWait(getWebDriver(), timeout); try { waiting.until(ExpectedConditions.presenceOfElementLocated(element)); } catch (NullPointerException e) { fail(String.format("Element %s did not appear within %d seconds.", element, timeout), e); } }
[ "@", "Override", "public", "void", "go", "(", ")", "{", "logger", ".", "info", "(", "\"Waiting {} seconds for {}...\"", ",", "timeout", ",", "element", ")", ";", "WebDriverWait", "waiting", "=", "new", "WebDriverWait", "(", "getWebDriver", "(", ")", ",", "timeout", ")", ";", "try", "{", "waiting", ".", "until", "(", "ExpectedConditions", ".", "presenceOfElementLocated", "(", "element", ")", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "fail", "(", "String", ".", "format", "(", "\"Element %s did not appear within %d seconds.\"", ",", "element", ",", "timeout", ")", ",", "e", ")", ";", "}", "}" ]
Waits for the element.
[ "Waits", "for", "the", "element", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/WaitForStep.java#L116-L125
144,724
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/results/SeeResult.java
SeeResult.expect
@Override public void expect() { assertTrue(String.format("Page should contain \"%s\" but it does not.", text), getWebDriver().getPageSource().contains(text)); }
java
@Override public void expect() { assertTrue(String.format("Page should contain \"%s\" but it does not.", text), getWebDriver().getPageSource().contains(text)); }
[ "@", "Override", "public", "void", "expect", "(", ")", "{", "assertTrue", "(", "String", ".", "format", "(", "\"Page should contain \\\"%s\\\" but it does not.\"", ",", "text", ")", ",", "getWebDriver", "(", ")", ".", "getPageSource", "(", ")", ".", "contains", "(", "text", ")", ")", ";", "}" ]
Expects that the specified text is present.
[ "Expects", "that", "the", "specified", "text", "is", "present", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/results/SeeResult.java#L53-L56
144,725
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/SelectContext.java
SelectContext.value
public SelectStep value(String value) { return new SelectStep(element, value, SelectStep.OptionSelectorType.VALUE); }
java
public SelectStep value(String value) { return new SelectStep(element, value, SelectStep.OptionSelectorType.VALUE); }
[ "public", "SelectStep", "value", "(", "String", "value", ")", "{", "return", "new", "SelectStep", "(", "element", ",", "value", ",", "SelectStep", ".", "OptionSelectorType", ".", "VALUE", ")", ";", "}" ]
Selects an option by its value. @param value The value of the option that shall be selected. @return A {@link de.codecentric.zucchini.web.steps.SelectStep} that selects an option by its value.
[ "Selects", "an", "option", "by", "its", "value", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/SelectContext.java#L62-L64
144,726
codecentric/zucchini
zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/SelectContext.java
SelectContext.text
public SelectStep text(String text) { return new SelectStep(element, text, SelectStep.OptionSelectorType.TEXT); }
java
public SelectStep text(String text) { return new SelectStep(element, text, SelectStep.OptionSelectorType.TEXT); }
[ "public", "SelectStep", "text", "(", "String", "text", ")", "{", "return", "new", "SelectStep", "(", "element", ",", "text", ",", "SelectStep", ".", "OptionSelectorType", ".", "TEXT", ")", ";", "}" ]
Selects an option by its text. @param text The text of the option that shall be selected. @return A {@link de.codecentric.zucchini.web.steps.SelectStep} that selects an option by its text.
[ "Selects", "an", "option", "by", "its", "text", "." ]
61541cd8ce666ef21ad943486a7c0eb53310ed5a
https://github.com/codecentric/zucchini/blob/61541cd8ce666ef21ad943486a7c0eb53310ed5a/zucchini-web/src/main/java/de/codecentric/zucchini/web/steps/SelectContext.java#L72-L74
144,727
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/controller/ApiController.java
ApiController.api
@SuppressWarnings({ "resource" }) @RequestMapping(value = { "/api.js", "/api-debug.js", "/api-debug-doc.js" }, method = RequestMethod.GET) public void api(@RequestParam(value = "apiNs", required = false) String apiNs, @RequestParam(value = "actionNs", required = false) String actionNs, @RequestParam(value = "remotingApiVar", required = false) String remotingApiVar, @RequestParam(value = "pollingUrlsVar", required = false) String pollingUrlsVar, @RequestParam(value = "group", required = false) String group, @RequestParam(value = "fullRouterUrl", required = false) Boolean fullRouterUrl, @RequestParam(value = "format", required = false) String format, @RequestParam(value = "baseRouterUrl", required = false) String baseRouterUrl, HttpServletRequest request, HttpServletResponse response) throws IOException { if (format == null) { response.setContentType( this.configurationService.getConfiguration().getJsContentType()); response.setCharacterEncoding(ExtDirectSpringUtil.UTF8_CHARSET.name()); String apiString = buildAndCacheApiString(apiNs, actionNs, remotingApiVar, pollingUrlsVar, group, fullRouterUrl, baseRouterUrl, request); byte[] outputBytes = apiString.getBytes(ExtDirectSpringUtil.UTF8_CHARSET); response.setContentLength(outputBytes.length); ServletOutputStream outputStream = response.getOutputStream(); outputStream.write(outputBytes); outputStream.flush(); } else { response.setContentType(RouterController.APPLICATION_JSON.toString()); response.setCharacterEncoding( RouterController.APPLICATION_JSON.getCharset().name()); String requestUrlString = request.getRequestURL().toString(); boolean debug = requestUrlString.contains("api-debug.js"); String routerUrl = requestUrlString.replaceFirst("api[^/]*?\\.js", "router"); String apiString = buildApiJson(apiNs, actionNs, remotingApiVar, routerUrl, group, debug); byte[] outputBytes = apiString.getBytes(ExtDirectSpringUtil.UTF8_CHARSET); response.setContentLength(outputBytes.length); ServletOutputStream outputStream = response.getOutputStream(); outputStream.write(outputBytes); outputStream.flush(); } }
java
@SuppressWarnings({ "resource" }) @RequestMapping(value = { "/api.js", "/api-debug.js", "/api-debug-doc.js" }, method = RequestMethod.GET) public void api(@RequestParam(value = "apiNs", required = false) String apiNs, @RequestParam(value = "actionNs", required = false) String actionNs, @RequestParam(value = "remotingApiVar", required = false) String remotingApiVar, @RequestParam(value = "pollingUrlsVar", required = false) String pollingUrlsVar, @RequestParam(value = "group", required = false) String group, @RequestParam(value = "fullRouterUrl", required = false) Boolean fullRouterUrl, @RequestParam(value = "format", required = false) String format, @RequestParam(value = "baseRouterUrl", required = false) String baseRouterUrl, HttpServletRequest request, HttpServletResponse response) throws IOException { if (format == null) { response.setContentType( this.configurationService.getConfiguration().getJsContentType()); response.setCharacterEncoding(ExtDirectSpringUtil.UTF8_CHARSET.name()); String apiString = buildAndCacheApiString(apiNs, actionNs, remotingApiVar, pollingUrlsVar, group, fullRouterUrl, baseRouterUrl, request); byte[] outputBytes = apiString.getBytes(ExtDirectSpringUtil.UTF8_CHARSET); response.setContentLength(outputBytes.length); ServletOutputStream outputStream = response.getOutputStream(); outputStream.write(outputBytes); outputStream.flush(); } else { response.setContentType(RouterController.APPLICATION_JSON.toString()); response.setCharacterEncoding( RouterController.APPLICATION_JSON.getCharset().name()); String requestUrlString = request.getRequestURL().toString(); boolean debug = requestUrlString.contains("api-debug.js"); String routerUrl = requestUrlString.replaceFirst("api[^/]*?\\.js", "router"); String apiString = buildApiJson(apiNs, actionNs, remotingApiVar, routerUrl, group, debug); byte[] outputBytes = apiString.getBytes(ExtDirectSpringUtil.UTF8_CHARSET); response.setContentLength(outputBytes.length); ServletOutputStream outputStream = response.getOutputStream(); outputStream.write(outputBytes); outputStream.flush(); } }
[ "@", "SuppressWarnings", "(", "{", "\"resource\"", "}", ")", "@", "RequestMapping", "(", "value", "=", "{", "\"/api.js\"", ",", "\"/api-debug.js\"", ",", "\"/api-debug-doc.js\"", "}", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "void", "api", "(", "@", "RequestParam", "(", "value", "=", "\"apiNs\"", ",", "required", "=", "false", ")", "String", "apiNs", ",", "@", "RequestParam", "(", "value", "=", "\"actionNs\"", ",", "required", "=", "false", ")", "String", "actionNs", ",", "@", "RequestParam", "(", "value", "=", "\"remotingApiVar\"", ",", "required", "=", "false", ")", "String", "remotingApiVar", ",", "@", "RequestParam", "(", "value", "=", "\"pollingUrlsVar\"", ",", "required", "=", "false", ")", "String", "pollingUrlsVar", ",", "@", "RequestParam", "(", "value", "=", "\"group\"", ",", "required", "=", "false", ")", "String", "group", ",", "@", "RequestParam", "(", "value", "=", "\"fullRouterUrl\"", ",", "required", "=", "false", ")", "Boolean", "fullRouterUrl", ",", "@", "RequestParam", "(", "value", "=", "\"format\"", ",", "required", "=", "false", ")", "String", "format", ",", "@", "RequestParam", "(", "value", "=", "\"baseRouterUrl\"", ",", "required", "=", "false", ")", "String", "baseRouterUrl", ",", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "IOException", "{", "if", "(", "format", "==", "null", ")", "{", "response", ".", "setContentType", "(", "this", ".", "configurationService", ".", "getConfiguration", "(", ")", ".", "getJsContentType", "(", ")", ")", ";", "response", ".", "setCharacterEncoding", "(", "ExtDirectSpringUtil", ".", "UTF8_CHARSET", ".", "name", "(", ")", ")", ";", "String", "apiString", "=", "buildAndCacheApiString", "(", "apiNs", ",", "actionNs", ",", "remotingApiVar", ",", "pollingUrlsVar", ",", "group", ",", "fullRouterUrl", ",", "baseRouterUrl", ",", "request", ")", ";", "byte", "[", "]", "outputBytes", "=", "apiString", ".", "getBytes", "(", "ExtDirectSpringUtil", ".", "UTF8_CHARSET", ")", ";", "response", ".", "setContentLength", "(", "outputBytes", ".", "length", ")", ";", "ServletOutputStream", "outputStream", "=", "response", ".", "getOutputStream", "(", ")", ";", "outputStream", ".", "write", "(", "outputBytes", ")", ";", "outputStream", ".", "flush", "(", ")", ";", "}", "else", "{", "response", ".", "setContentType", "(", "RouterController", ".", "APPLICATION_JSON", ".", "toString", "(", ")", ")", ";", "response", ".", "setCharacterEncoding", "(", "RouterController", ".", "APPLICATION_JSON", ".", "getCharset", "(", ")", ".", "name", "(", ")", ")", ";", "String", "requestUrlString", "=", "request", ".", "getRequestURL", "(", ")", ".", "toString", "(", ")", ";", "boolean", "debug", "=", "requestUrlString", ".", "contains", "(", "\"api-debug.js\"", ")", ";", "String", "routerUrl", "=", "requestUrlString", ".", "replaceFirst", "(", "\"api[^/]*?\\\\.js\"", ",", "\"router\"", ")", ";", "String", "apiString", "=", "buildApiJson", "(", "apiNs", ",", "actionNs", ",", "remotingApiVar", ",", "routerUrl", ",", "group", ",", "debug", ")", ";", "byte", "[", "]", "outputBytes", "=", "apiString", ".", "getBytes", "(", "ExtDirectSpringUtil", ".", "UTF8_CHARSET", ")", ";", "response", ".", "setContentLength", "(", "outputBytes", ".", "length", ")", ";", "ServletOutputStream", "outputStream", "=", "response", ".", "getOutputStream", "(", ")", ";", "outputStream", ".", "write", "(", "outputBytes", ")", ";", "outputStream", ".", "flush", "(", ")", ";", "}", "}" ]
Method that handles api.js and api-debug.js calls. Generates a javascript with the necessary code for Ext Direct. @param apiNs name of the namespace the variable remotingApiVar will live in. Defaults to Ext.app @param actionNs name of the namespace the action will live in. @param remotingApiVar name of the remoting api variable. Defaults to REMOTING_API @param pollingUrlsVar name of the polling urls object. Defaults to POLLING_URLS @param group name of the api group. Multiple groups delimited with comma @param fullRouterUrl if true the router property contains the full request URL with method, server and port. Defaults to false returns only the URL without method, server and port @param format only valid value is "json2. Ext Designer sends this parameter and the response is a JSON. Defaults to null and response is Javascript. @param baseRouterUrl Sets the path to the router and poll controllers. If set overrides default behavior that uses request.getRequestURI @param request the HTTP servlet request @param response the HTTP servlet response @throws IOException
[ "Method", "that", "handles", "api", ".", "js", "and", "api", "-", "debug", ".", "js", "calls", ".", "Generates", "a", "javascript", "with", "the", "necessary", "code", "for", "Ext", "Direct", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/controller/ApiController.java#L93-L143
144,728
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectFormPostResult.java
ExtDirectFormPostResult.addError
public void addError(String field, String error) { Assert.notNull(field, "field must not be null"); Assert.notNull(error, "field must not be null"); addErrors(field, Collections.singletonList(error)); addResultProperty(SUCCESS_PROPERTY, Boolean.FALSE); }
java
public void addError(String field, String error) { Assert.notNull(field, "field must not be null"); Assert.notNull(error, "field must not be null"); addErrors(field, Collections.singletonList(error)); addResultProperty(SUCCESS_PROPERTY, Boolean.FALSE); }
[ "public", "void", "addError", "(", "String", "field", ",", "String", "error", ")", "{", "Assert", ".", "notNull", "(", "field", ",", "\"field must not be null\"", ")", ";", "Assert", ".", "notNull", "(", "error", ",", "\"field must not be null\"", ")", ";", "addErrors", "(", "field", ",", "Collections", ".", "singletonList", "(", "error", ")", ")", ";", "addResultProperty", "(", "SUCCESS_PROPERTY", ",", "Boolean", ".", "FALSE", ")", ";", "}" ]
Adds one error message to a specific field. Does not overwrite already existing errors. @param field the name of the field @param error the error message
[ "Adds", "one", "error", "message", "to", "a", "specific", "field", ".", "Does", "not", "overwrite", "already", "existing", "errors", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectFormPostResult.java#L181-L188
144,729
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectFormPostResult.java
ExtDirectFormPostResult.addErrors
@SuppressWarnings("unchecked") public void addErrors(String field, List<String> errors) { Assert.notNull(field, "field must not be null"); Assert.notNull(errors, "field must not be null"); // do not overwrite existing errors Map<String, List<String>> errorMap = (Map<String, List<String>>) this.result .get(ERRORS_PROPERTY); if (errorMap == null) { errorMap = new HashMap<>(); addResultProperty(ERRORS_PROPERTY, errorMap); } List<String> fieldErrors = errorMap.get(field); if (fieldErrors == null) { fieldErrors = new ArrayList<>(); errorMap.put(field, fieldErrors); } fieldErrors.addAll(errors); addResultProperty(SUCCESS_PROPERTY, Boolean.FALSE); }
java
@SuppressWarnings("unchecked") public void addErrors(String field, List<String> errors) { Assert.notNull(field, "field must not be null"); Assert.notNull(errors, "field must not be null"); // do not overwrite existing errors Map<String, List<String>> errorMap = (Map<String, List<String>>) this.result .get(ERRORS_PROPERTY); if (errorMap == null) { errorMap = new HashMap<>(); addResultProperty(ERRORS_PROPERTY, errorMap); } List<String> fieldErrors = errorMap.get(field); if (fieldErrors == null) { fieldErrors = new ArrayList<>(); errorMap.put(field, fieldErrors); } fieldErrors.addAll(errors); addResultProperty(SUCCESS_PROPERTY, Boolean.FALSE); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "addErrors", "(", "String", "field", ",", "List", "<", "String", ">", "errors", ")", "{", "Assert", ".", "notNull", "(", "field", ",", "\"field must not be null\"", ")", ";", "Assert", ".", "notNull", "(", "errors", ",", "\"field must not be null\"", ")", ";", "// do not overwrite existing errors", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "errorMap", "=", "(", "Map", "<", "String", ",", "List", "<", "String", ">", ">", ")", "this", ".", "result", ".", "get", "(", "ERRORS_PROPERTY", ")", ";", "if", "(", "errorMap", "==", "null", ")", "{", "errorMap", "=", "new", "HashMap", "<>", "(", ")", ";", "addResultProperty", "(", "ERRORS_PROPERTY", ",", "errorMap", ")", ";", "}", "List", "<", "String", ">", "fieldErrors", "=", "errorMap", ".", "get", "(", "field", ")", ";", "if", "(", "fieldErrors", "==", "null", ")", "{", "fieldErrors", "=", "new", "ArrayList", "<>", "(", ")", ";", "errorMap", ".", "put", "(", "field", ",", "fieldErrors", ")", ";", "}", "fieldErrors", ".", "addAll", "(", "errors", ")", ";", "addResultProperty", "(", "SUCCESS_PROPERTY", ",", "Boolean", ".", "FALSE", ")", ";", "}" ]
Adds multiple error messages to a specific field. Does not overwrite already existing errors. @param field the name of the field @param errors a collection of error messages
[ "Adds", "multiple", "error", "messages", "to", "a", "specific", "field", ".", "Does", "not", "overwrite", "already", "existing", "errors", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectFormPostResult.java#L197-L218
144,730
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectStoreReadRequest.java
ExtDirectStoreReadRequest.getFirstFilterForField
@SuppressWarnings("unchecked") public <T extends Filter> T getFirstFilterForField(String field) { for (Filter filter : this.filters) { if (filter.getField().equals(field)) { return (T) filter; } } return null; }
java
@SuppressWarnings("unchecked") public <T extends Filter> T getFirstFilterForField(String field) { for (Filter filter : this.filters) { if (filter.getField().equals(field)) { return (T) filter; } } return null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", "extends", "Filter", ">", "T", "getFirstFilterForField", "(", "String", "field", ")", "{", "for", "(", "Filter", "filter", ":", "this", ".", "filters", ")", "{", "if", "(", "filter", ".", "getField", "(", ")", ".", "equals", "(", "field", ")", ")", "{", "return", "(", "T", ")", "filter", ";", "}", "}", "return", "null", ";", "}" ]
Returns the first filter for the field. @param field name of the field @return the first filter for the field. Null if not filter exists.
[ "Returns", "the", "first", "filter", "for", "the", "field", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectStoreReadRequest.java#L214-L222
144,731
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectStoreReadRequest.java
ExtDirectStoreReadRequest.getAllFiltersForField
public List<Filter> getAllFiltersForField(String field) { List<Filter> foundFilters = new ArrayList<>(); for (Filter filter : this.filters) { if (filter.getField().equals(field)) { foundFilters.add(filter); } } return Collections.unmodifiableList(foundFilters); }
java
public List<Filter> getAllFiltersForField(String field) { List<Filter> foundFilters = new ArrayList<>(); for (Filter filter : this.filters) { if (filter.getField().equals(field)) { foundFilters.add(filter); } } return Collections.unmodifiableList(foundFilters); }
[ "public", "List", "<", "Filter", ">", "getAllFiltersForField", "(", "String", "field", ")", "{", "List", "<", "Filter", ">", "foundFilters", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Filter", "filter", ":", "this", ".", "filters", ")", "{", "if", "(", "filter", ".", "getField", "(", ")", ".", "equals", "(", "field", ")", ")", "{", "foundFilters", ".", "add", "(", "filter", ")", ";", "}", "}", "return", "Collections", ".", "unmodifiableList", "(", "foundFilters", ")", ";", "}" ]
Returns all filters for a field @param field name of the field @return a collection of filters for the field. Empty collection if no filter exists
[ "Returns", "all", "filters", "for", "a", "field" ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectStoreReadRequest.java#L230-L240
144,732
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectResponseBuilder.java
ExtDirectResponseBuilder.addResultProperty
public ExtDirectResponseBuilder addResultProperty(String key, Object value) { this.result.put(key, value); return this; }
java
public ExtDirectResponseBuilder addResultProperty(String key, Object value) { this.result.put(key, value); return this; }
[ "public", "ExtDirectResponseBuilder", "addResultProperty", "(", "String", "key", ",", "Object", "value", ")", "{", "this", ".", "result", ".", "put", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Add additional property to the response. @param key the key of the property @param value the value of this property @return this instance
[ "Add", "additional", "property", "to", "the", "response", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/bean/ExtDirectResponseBuilder.java#L188-L191
144,733
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/util/ExtDirectSpringUtil.java
ExtDirectSpringUtil.isMultipart
public static boolean isMultipart(HttpServletRequest request) { if (!"post".equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); return contentType != null && contentType.toLowerCase().startsWith("multipart/"); }
java
public static boolean isMultipart(HttpServletRequest request) { if (!"post".equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); return contentType != null && contentType.toLowerCase().startsWith("multipart/"); }
[ "public", "static", "boolean", "isMultipart", "(", "HttpServletRequest", "request", ")", "{", "if", "(", "!", "\"post\"", ".", "equals", "(", "request", ".", "getMethod", "(", ")", ".", "toLowerCase", "(", ")", ")", ")", "{", "return", "false", ";", "}", "String", "contentType", "=", "request", ".", "getContentType", "(", ")", ";", "return", "contentType", "!=", "null", "&&", "contentType", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"multipart/\"", ")", ";", "}" ]
Checks if the request is a multipart request @param request the HTTP servlet request @return true if request is a Multipart request (file upload)
[ "Checks", "if", "the", "request", "is", "a", "multipart", "request" ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/util/ExtDirectSpringUtil.java#L74-L80
144,734
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/util/ExtDirectSpringUtil.java
ExtDirectSpringUtil.invoke
public static Object invoke(ApplicationContext context, String beanName, MethodInfo methodInfo, final Object[] params) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { Object bean = context.getBean(beanName); Method handlerMethod = methodInfo.getMethod(); ReflectionUtils.makeAccessible(handlerMethod); Object result = handlerMethod.invoke(bean, params); if (result != null && result instanceof Optional) { return ((Optional<?>) result).orElse(null); } return result; }
java
public static Object invoke(ApplicationContext context, String beanName, MethodInfo methodInfo, final Object[] params) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { Object bean = context.getBean(beanName); Method handlerMethod = methodInfo.getMethod(); ReflectionUtils.makeAccessible(handlerMethod); Object result = handlerMethod.invoke(bean, params); if (result != null && result instanceof Optional) { return ((Optional<?>) result).orElse(null); } return result; }
[ "public", "static", "Object", "invoke", "(", "ApplicationContext", "context", ",", "String", "beanName", ",", "MethodInfo", "methodInfo", ",", "final", "Object", "[", "]", "params", ")", "throws", "IllegalArgumentException", ",", "IllegalAccessException", ",", "InvocationTargetException", "{", "Object", "bean", "=", "context", ".", "getBean", "(", "beanName", ")", ";", "Method", "handlerMethod", "=", "methodInfo", ".", "getMethod", "(", ")", ";", "ReflectionUtils", ".", "makeAccessible", "(", "handlerMethod", ")", ";", "Object", "result", "=", "handlerMethod", ".", "invoke", "(", "bean", ",", "params", ")", ";", "if", "(", "result", "!=", "null", "&&", "result", "instanceof", "Optional", ")", "{", "return", "(", "(", "Optional", "<", "?", ">", ")", "result", ")", ".", "orElse", "(", "null", ")", ";", "}", "return", "result", ";", "}" ]
Invokes a method on a Spring managed bean. @param context a Spring application context @param beanName the name of the bean @param methodInfo the methodInfo object @param params the parameters @return the result of the method invocation @throws IllegalArgumentException if there is no bean in the context @throws IllegalAccessException @throws InvocationTargetException
[ "Invokes", "a", "method", "on", "a", "Spring", "managed", "bean", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/util/ExtDirectSpringUtil.java#L94-L108
144,735
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/util/ExtDirectSpringUtil.java
ExtDirectSpringUtil.addCacheHeaders
public static void addCacheHeaders(HttpServletResponse response, String etag, Integer month) { Assert.notNull(etag, "ETag must not be null"); long seconds; if (month != null) { seconds = month * secondsInAMonth; } else { seconds = 6L * secondsInAMonth; } response.setDateHeader("Expires", System.currentTimeMillis() + seconds * 1000L); response.setHeader("ETag", etag); response.setHeader("Cache-Control", "public, max-age=" + seconds); }
java
public static void addCacheHeaders(HttpServletResponse response, String etag, Integer month) { Assert.notNull(etag, "ETag must not be null"); long seconds; if (month != null) { seconds = month * secondsInAMonth; } else { seconds = 6L * secondsInAMonth; } response.setDateHeader("Expires", System.currentTimeMillis() + seconds * 1000L); response.setHeader("ETag", etag); response.setHeader("Cache-Control", "public, max-age=" + seconds); }
[ "public", "static", "void", "addCacheHeaders", "(", "HttpServletResponse", "response", ",", "String", "etag", ",", "Integer", "month", ")", "{", "Assert", ".", "notNull", "(", "etag", ",", "\"ETag must not be null\"", ")", ";", "long", "seconds", ";", "if", "(", "month", "!=", "null", ")", "{", "seconds", "=", "month", "*", "secondsInAMonth", ";", "}", "else", "{", "seconds", "=", "6L", "*", "secondsInAMonth", ";", "}", "response", ".", "setDateHeader", "(", "\"Expires\"", ",", "System", ".", "currentTimeMillis", "(", ")", "+", "seconds", "*", "1000L", ")", ";", "response", ".", "setHeader", "(", "\"ETag\"", ",", "etag", ")", ";", "response", ".", "setHeader", "(", "\"Cache-Control\"", ",", "\"public, max-age=\"", "+", "seconds", ")", ";", "}" ]
Adds Expires, ETag and Cache-Control response headers. @param response the HTTP servlet response @param etag the calculated etag (md5) of the response @param month number of months the response can be cached. Added to the Expires and Cache-Control header. If null defaults to 6 months.
[ "Adds", "Expires", "ETag", "and", "Cache", "-", "Control", "response", "headers", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/util/ExtDirectSpringUtil.java#L147-L162
144,736
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/util/ExtDirectSpringUtil.java
ExtDirectSpringUtil.generateApiString
public static String generateApiString(ApplicationContext ctx, String remotingVarName, String pollingApiVarName) throws JsonProcessingException { RemotingApi remotingApi = new RemotingApi(ctx.getBean(ConfigurationService.class) .getConfiguration().getProviderType(), "router", null); for (Map.Entry<MethodInfoCache.Key, MethodInfo> entry : ctx .getBean(MethodInfoCache.class)) { MethodInfo methodInfo = entry.getValue(); if (methodInfo.getAction() != null) { remotingApi.addAction(entry.getKey().getBeanName(), methodInfo.getAction()); } else if (methodInfo.getPollingProvider() != null) { remotingApi.addPollingProvider(methodInfo.getPollingProvider()); } } remotingApi.sort(); StringBuilder extDirectConfig = new StringBuilder(100); extDirectConfig.append("var ").append(remotingVarName).append(" = "); extDirectConfig.append(new ObjectMapper().writer().withDefaultPrettyPrinter() .writeValueAsString(remotingApi)); extDirectConfig.append(";"); List<PollingProvider> pollingProviders = remotingApi.getPollingProviders(); if (!pollingProviders.isEmpty()) { extDirectConfig.append("\n\nvar ").append(pollingApiVarName).append(" = {\n"); for (int i = 0; i < pollingProviders.size(); i++) { extDirectConfig.append(" \""); extDirectConfig.append(pollingProviders.get(i).getEvent()); extDirectConfig.append("\" : \"poll/"); extDirectConfig.append(pollingProviders.get(i).getBeanName()); extDirectConfig.append("/"); extDirectConfig.append(pollingProviders.get(i).getMethod()); extDirectConfig.append("/"); extDirectConfig.append(pollingProviders.get(i).getEvent()); extDirectConfig.append("\""); if (i < pollingProviders.size() - 1) { extDirectConfig.append(",\n"); } } extDirectConfig.append("\n};"); } return extDirectConfig.toString(); }
java
public static String generateApiString(ApplicationContext ctx, String remotingVarName, String pollingApiVarName) throws JsonProcessingException { RemotingApi remotingApi = new RemotingApi(ctx.getBean(ConfigurationService.class) .getConfiguration().getProviderType(), "router", null); for (Map.Entry<MethodInfoCache.Key, MethodInfo> entry : ctx .getBean(MethodInfoCache.class)) { MethodInfo methodInfo = entry.getValue(); if (methodInfo.getAction() != null) { remotingApi.addAction(entry.getKey().getBeanName(), methodInfo.getAction()); } else if (methodInfo.getPollingProvider() != null) { remotingApi.addPollingProvider(methodInfo.getPollingProvider()); } } remotingApi.sort(); StringBuilder extDirectConfig = new StringBuilder(100); extDirectConfig.append("var ").append(remotingVarName).append(" = "); extDirectConfig.append(new ObjectMapper().writer().withDefaultPrettyPrinter() .writeValueAsString(remotingApi)); extDirectConfig.append(";"); List<PollingProvider> pollingProviders = remotingApi.getPollingProviders(); if (!pollingProviders.isEmpty()) { extDirectConfig.append("\n\nvar ").append(pollingApiVarName).append(" = {\n"); for (int i = 0; i < pollingProviders.size(); i++) { extDirectConfig.append(" \""); extDirectConfig.append(pollingProviders.get(i).getEvent()); extDirectConfig.append("\" : \"poll/"); extDirectConfig.append(pollingProviders.get(i).getBeanName()); extDirectConfig.append("/"); extDirectConfig.append(pollingProviders.get(i).getMethod()); extDirectConfig.append("/"); extDirectConfig.append(pollingProviders.get(i).getEvent()); extDirectConfig.append("\""); if (i < pollingProviders.size() - 1) { extDirectConfig.append(",\n"); } } extDirectConfig.append("\n};"); } return extDirectConfig.toString(); }
[ "public", "static", "String", "generateApiString", "(", "ApplicationContext", "ctx", ",", "String", "remotingVarName", ",", "String", "pollingApiVarName", ")", "throws", "JsonProcessingException", "{", "RemotingApi", "remotingApi", "=", "new", "RemotingApi", "(", "ctx", ".", "getBean", "(", "ConfigurationService", ".", "class", ")", ".", "getConfiguration", "(", ")", ".", "getProviderType", "(", ")", ",", "\"router\"", ",", "null", ")", ";", "for", "(", "Map", ".", "Entry", "<", "MethodInfoCache", ".", "Key", ",", "MethodInfo", ">", "entry", ":", "ctx", ".", "getBean", "(", "MethodInfoCache", ".", "class", ")", ")", "{", "MethodInfo", "methodInfo", "=", "entry", ".", "getValue", "(", ")", ";", "if", "(", "methodInfo", ".", "getAction", "(", ")", "!=", "null", ")", "{", "remotingApi", ".", "addAction", "(", "entry", ".", "getKey", "(", ")", ".", "getBeanName", "(", ")", ",", "methodInfo", ".", "getAction", "(", ")", ")", ";", "}", "else", "if", "(", "methodInfo", ".", "getPollingProvider", "(", ")", "!=", "null", ")", "{", "remotingApi", ".", "addPollingProvider", "(", "methodInfo", ".", "getPollingProvider", "(", ")", ")", ";", "}", "}", "remotingApi", ".", "sort", "(", ")", ";", "StringBuilder", "extDirectConfig", "=", "new", "StringBuilder", "(", "100", ")", ";", "extDirectConfig", ".", "append", "(", "\"var \"", ")", ".", "append", "(", "remotingVarName", ")", ".", "append", "(", "\" = \"", ")", ";", "extDirectConfig", ".", "append", "(", "new", "ObjectMapper", "(", ")", ".", "writer", "(", ")", ".", "withDefaultPrettyPrinter", "(", ")", ".", "writeValueAsString", "(", "remotingApi", ")", ")", ";", "extDirectConfig", ".", "append", "(", "\";\"", ")", ";", "List", "<", "PollingProvider", ">", "pollingProviders", "=", "remotingApi", ".", "getPollingProviders", "(", ")", ";", "if", "(", "!", "pollingProviders", ".", "isEmpty", "(", ")", ")", "{", "extDirectConfig", ".", "append", "(", "\"\\n\\nvar \"", ")", ".", "append", "(", "pollingApiVarName", ")", ".", "append", "(", "\" = {\\n\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pollingProviders", ".", "size", "(", ")", ";", "i", "++", ")", "{", "extDirectConfig", ".", "append", "(", "\" \\\"\"", ")", ";", "extDirectConfig", ".", "append", "(", "pollingProviders", ".", "get", "(", "i", ")", ".", "getEvent", "(", ")", ")", ";", "extDirectConfig", ".", "append", "(", "\"\\\" : \\\"poll/\"", ")", ";", "extDirectConfig", ".", "append", "(", "pollingProviders", ".", "get", "(", "i", ")", ".", "getBeanName", "(", ")", ")", ";", "extDirectConfig", ".", "append", "(", "\"/\"", ")", ";", "extDirectConfig", ".", "append", "(", "pollingProviders", ".", "get", "(", "i", ")", ".", "getMethod", "(", ")", ")", ";", "extDirectConfig", ".", "append", "(", "\"/\"", ")", ";", "extDirectConfig", ".", "append", "(", "pollingProviders", ".", "get", "(", "i", ")", ".", "getEvent", "(", ")", ")", ";", "extDirectConfig", ".", "append", "(", "\"\\\"\"", ")", ";", "if", "(", "i", "<", "pollingProviders", ".", "size", "(", ")", "-", "1", ")", "{", "extDirectConfig", ".", "append", "(", "\",\\n\"", ")", ";", "}", "}", "extDirectConfig", ".", "append", "(", "\"\\n};\"", ")", ";", "}", "return", "extDirectConfig", ".", "toString", "(", ")", ";", "}" ]
Returns the api configuration as a String @param ctx The spring applicationcontext @param remotingVarName name of the variable for the remoting configuration (e.g. REMOTING_API) @param pollingApiVarName name of the variable for the polling configuration (e.g. POLLING_URLS) @return the api configuration @throws JsonProcessingException
[ "Returns", "the", "api", "configuration", "as", "a", "String" ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/util/ExtDirectSpringUtil.java#L221-L269
144,737
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/util/JsonHandler.java
JsonHandler.writeValueAsString
public String writeValueAsString(Object obj, boolean indent) { try { if (indent) { return this.mapper.writer().withDefaultPrettyPrinter() .writeValueAsString(obj); } return this.mapper.writeValueAsString(obj); } catch (Exception e) { LogFactory.getLog(JsonHandler.class).info("serialize object to json", e); return null; } }
java
public String writeValueAsString(Object obj, boolean indent) { try { if (indent) { return this.mapper.writer().withDefaultPrettyPrinter() .writeValueAsString(obj); } return this.mapper.writeValueAsString(obj); } catch (Exception e) { LogFactory.getLog(JsonHandler.class).info("serialize object to json", e); return null; } }
[ "public", "String", "writeValueAsString", "(", "Object", "obj", ",", "boolean", "indent", ")", "{", "try", "{", "if", "(", "indent", ")", "{", "return", "this", ".", "mapper", ".", "writer", "(", ")", ".", "withDefaultPrettyPrinter", "(", ")", ".", "writeValueAsString", "(", "obj", ")", ";", "}", "return", "this", ".", "mapper", ".", "writeValueAsString", "(", "obj", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LogFactory", ".", "getLog", "(", "JsonHandler", ".", "class", ")", ".", "info", "(", "\"serialize object to json\"", ",", "e", ")", ";", "return", "null", ";", "}", "}" ]
Converts an object into a JSON string. In case of an exceptions returns null and logs the exception. @param obj the source object @param indent if true JSON is written in a human readable format, if false JSON is written on one line @return obj JSON string, <code>null</code> if an exception occurred
[ "Converts", "an", "object", "into", "a", "JSON", "string", ".", "In", "case", "of", "an", "exceptions", "returns", "null", "and", "logs", "the", "exception", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/util/JsonHandler.java#L80-L92
144,738
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/util/JsonHandler.java
JsonHandler.readValue
public Object readValue(InputStream is, Class<Object> clazz) { try { return this.mapper.readValue(is, clazz); } catch (Exception e) { LogFactory.getLog(JsonHandler.class).info("deserialize json to object", e); return null; } }
java
public Object readValue(InputStream is, Class<Object> clazz) { try { return this.mapper.readValue(is, clazz); } catch (Exception e) { LogFactory.getLog(JsonHandler.class).info("deserialize json to object", e); return null; } }
[ "public", "Object", "readValue", "(", "InputStream", "is", ",", "Class", "<", "Object", ">", "clazz", ")", "{", "try", "{", "return", "this", ".", "mapper", ".", "readValue", "(", "is", ",", "clazz", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LogFactory", ".", "getLog", "(", "JsonHandler", ".", "class", ")", ".", "info", "(", "\"deserialize json to object\"", ",", "e", ")", ";", "return", "null", ";", "}", "}" ]
Converts a JSON string into an object. The input is read from an InputStream. In case of an exception returns null and logs the exception. @param is a InputStream @param clazz class of object to create @return the converted object, null if there is an exception
[ "Converts", "a", "JSON", "string", "into", "an", "object", ".", "The", "input", "is", "read", "from", "an", "InputStream", ".", "In", "case", "of", "an", "exception", "returns", "null", "and", "logs", "the", "exception", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/util/JsonHandler.java#L142-L150
144,739
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/util/MethodInfo.java
MethodInfo.findMethodWithAnnotation
public static Method findMethodWithAnnotation(Method method, Class<? extends Annotation> annotation) { if (method.isAnnotationPresent(annotation)) { return method; } Class<?> cl = method.getDeclaringClass(); while (cl != null && cl != Object.class) { try { Method equivalentMethod = cl.getDeclaredMethod(method.getName(), method.getParameterTypes()); if (equivalentMethod.isAnnotationPresent(annotation)) { return equivalentMethod; } } catch (NoSuchMethodException e) { // do nothing here } cl = cl.getSuperclass(); } return null; }
java
public static Method findMethodWithAnnotation(Method method, Class<? extends Annotation> annotation) { if (method.isAnnotationPresent(annotation)) { return method; } Class<?> cl = method.getDeclaringClass(); while (cl != null && cl != Object.class) { try { Method equivalentMethod = cl.getDeclaredMethod(method.getName(), method.getParameterTypes()); if (equivalentMethod.isAnnotationPresent(annotation)) { return equivalentMethod; } } catch (NoSuchMethodException e) { // do nothing here } cl = cl.getSuperclass(); } return null; }
[ "public", "static", "Method", "findMethodWithAnnotation", "(", "Method", "method", ",", "Class", "<", "?", "extends", "Annotation", ">", "annotation", ")", "{", "if", "(", "method", ".", "isAnnotationPresent", "(", "annotation", ")", ")", "{", "return", "method", ";", "}", "Class", "<", "?", ">", "cl", "=", "method", ".", "getDeclaringClass", "(", ")", ";", "while", "(", "cl", "!=", "null", "&&", "cl", "!=", "Object", ".", "class", ")", "{", "try", "{", "Method", "equivalentMethod", "=", "cl", ".", "getDeclaredMethod", "(", "method", ".", "getName", "(", ")", ",", "method", ".", "getParameterTypes", "(", ")", ")", ";", "if", "(", "equivalentMethod", ".", "isAnnotationPresent", "(", "annotation", ")", ")", "{", "return", "equivalentMethod", ";", "}", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "// do nothing here", "}", "cl", "=", "cl", ".", "getSuperclass", "(", ")", ";", "}", "return", "null", ";", "}" ]
Find a method that is annotated with a specific annotation. Starts with the method and goes up to the superclasses of the class. @param method the starting method @param annotation the annotation to look for @return the method if there is a annotated method, else null
[ "Find", "a", "method", "that", "is", "annotated", "with", "a", "specific", "annotation", ".", "Starts", "with", "the", "method", "and", "goes", "up", "to", "the", "superclasses", "of", "the", "class", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/util/MethodInfo.java#L356-L378
144,740
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/util/MethodInfoCache.java
MethodInfoCache.put
public void put(String beanName, Class<?> clazz, Method method, ApplicationContext context) { MethodInfo info = new MethodInfo(clazz, context, beanName, method); this.cache.put(new Key(beanName, method.getName()), info); }
java
public void put(String beanName, Class<?> clazz, Method method, ApplicationContext context) { MethodInfo info = new MethodInfo(clazz, context, beanName, method); this.cache.put(new Key(beanName, method.getName()), info); }
[ "public", "void", "put", "(", "String", "beanName", ",", "Class", "<", "?", ">", "clazz", ",", "Method", "method", ",", "ApplicationContext", "context", ")", "{", "MethodInfo", "info", "=", "new", "MethodInfo", "(", "clazz", ",", "context", ",", "beanName", ",", "method", ")", ";", "this", ".", "cache", ".", "put", "(", "new", "Key", "(", "beanName", ",", "method", ".", "getName", "(", ")", ")", ",", "info", ")", ";", "}" ]
Put a method into the MethodCache. @param beanName the name of the bean @param clazz the class of the bean @param method the method @param context the Spring application context
[ "Put", "a", "method", "into", "the", "MethodCache", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/util/MethodInfoCache.java#L49-L53
144,741
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/util/MethodInfoCache.java
MethodInfoCache.get
public MethodInfo get(String beanName, String methodName) { return this.cache.get(new Key(beanName, methodName)); }
java
public MethodInfo get(String beanName, String methodName) { return this.cache.get(new Key(beanName, methodName)); }
[ "public", "MethodInfo", "get", "(", "String", "beanName", ",", "String", "methodName", ")", "{", "return", "this", ".", "cache", ".", "get", "(", "new", "Key", "(", "beanName", ",", "methodName", ")", ")", ";", "}" ]
Get a method from the MethodCache. @param beanName the name of the bean @param methodName the name of the method @return the found methodInfo object, null if there is no method found in the cache
[ "Get", "a", "method", "from", "the", "MethodCache", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/util/MethodInfoCache.java#L62-L64
144,742
ralscha/extdirectspring
src/main/java/ch/ralscha/extdirectspring/controller/Configuration.java
Configuration.getMessage
public String getMessage(Throwable exception) { String message; if (getExceptionToMessage() != null) { message = getExceptionToMessage().get(exception.getClass()); if (StringUtils.hasText(message)) { return message; } // map entry with a null value if (getExceptionToMessage().containsKey(exception.getClass())) { return exception.getMessage(); } } if (isSendExceptionMessage()) { return exception.getMessage(); } return getDefaultExceptionMessage(); }
java
public String getMessage(Throwable exception) { String message; if (getExceptionToMessage() != null) { message = getExceptionToMessage().get(exception.getClass()); if (StringUtils.hasText(message)) { return message; } // map entry with a null value if (getExceptionToMessage().containsKey(exception.getClass())) { return exception.getMessage(); } } if (isSendExceptionMessage()) { return exception.getMessage(); } return getDefaultExceptionMessage(); }
[ "public", "String", "getMessage", "(", "Throwable", "exception", ")", "{", "String", "message", ";", "if", "(", "getExceptionToMessage", "(", ")", "!=", "null", ")", "{", "message", "=", "getExceptionToMessage", "(", ")", ".", "get", "(", "exception", ".", "getClass", "(", ")", ")", ";", "if", "(", "StringUtils", ".", "hasText", "(", "message", ")", ")", "{", "return", "message", ";", "}", "// map entry with a null value", "if", "(", "getExceptionToMessage", "(", ")", ".", "containsKey", "(", "exception", ".", "getClass", "(", ")", ")", ")", "{", "return", "exception", ".", "getMessage", "(", ")", ";", "}", "}", "if", "(", "isSendExceptionMessage", "(", ")", ")", "{", "return", "exception", ".", "getMessage", "(", ")", ";", "}", "return", "getDefaultExceptionMessage", "(", ")", ";", "}" ]
Returns an error message for the supplied exception and based on this configuration. @see #setDefaultExceptionMessage(String) @see #setSendExceptionMessage(boolean) @see #setExceptionToMessage(Map) @param exception the thrown exception @return exception message
[ "Returns", "an", "error", "message", "for", "the", "supplied", "exception", "and", "based", "on", "this", "configuration", "." ]
4b018497c4e7503033f91d0491b4e74bf8291d2c
https://github.com/ralscha/extdirectspring/blob/4b018497c4e7503033f91d0491b4e74bf8291d2c/src/main/java/ch/ralscha/extdirectspring/controller/Configuration.java#L303-L322
144,743
sargue/mailgun
src/main/java/net/sargue/mailgun/Configuration.java
Configuration.copy
@Deprecated public Configuration copy() { Configuration copy = new Configuration(); copy.apiUrl = apiUrl; copy.domain = domain; copy.apiKey = apiKey; copy.mailRequestCallbackFactory = mailRequestCallbackFactory; copy.mailSendFilter = mailSendFilter; //noinspection Convert2Diamond copy.defaultParameters = new MultivaluedHashMap<String,String>(defaultParameters); //NOSONAR copy.converters.addAll(converters); return copy; }
java
@Deprecated public Configuration copy() { Configuration copy = new Configuration(); copy.apiUrl = apiUrl; copy.domain = domain; copy.apiKey = apiKey; copy.mailRequestCallbackFactory = mailRequestCallbackFactory; copy.mailSendFilter = mailSendFilter; //noinspection Convert2Diamond copy.defaultParameters = new MultivaluedHashMap<String,String>(defaultParameters); //NOSONAR copy.converters.addAll(converters); return copy; }
[ "@", "Deprecated", "public", "Configuration", "copy", "(", ")", "{", "Configuration", "copy", "=", "new", "Configuration", "(", ")", ";", "copy", ".", "apiUrl", "=", "apiUrl", ";", "copy", ".", "domain", "=", "domain", ";", "copy", ".", "apiKey", "=", "apiKey", ";", "copy", ".", "mailRequestCallbackFactory", "=", "mailRequestCallbackFactory", ";", "copy", ".", "mailSendFilter", "=", "mailSendFilter", ";", "//noinspection Convert2Diamond", "copy", ".", "defaultParameters", "=", "new", "MultivaluedHashMap", "<", "String", ",", "String", ">", "(", "defaultParameters", ")", ";", "//NOSONAR", "copy", ".", "converters", ".", "addAll", "(", "converters", ")", ";", "return", "copy", ";", "}" ]
Creates a copy of this configuration. @return a copy of this configuration @deprecated it's not clear what a 'copy' is so this method will be removed
[ "Creates", "a", "copy", "of", "this", "configuration", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/Configuration.java#L87-L99
144,744
sargue/mailgun
src/main/java/net/sargue/mailgun/MailBuilder.java
MailBuilder.from
public MailBuilder from(String name, String email) { return param("from", email(name, email)); }
java
public MailBuilder from(String name, String email) { return param("from", email(name, email)); }
[ "public", "MailBuilder", "from", "(", "String", "name", ",", "String", "email", ")", "{", "return", "param", "(", "\"from\"", ",", "email", "(", "name", ",", "email", ")", ")", ";", "}" ]
Sets the address of the sender. @param name the name of the sender @param email the address of the sender @return this builder
[ "Sets", "the", "address", "of", "the", "sender", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/MailBuilder.java#L82-L84
144,745
sargue/mailgun
src/main/java/net/sargue/mailgun/MailBuilder.java
MailBuilder.to
public MailBuilder to(String name, String email) { return param("to", email(name, email)); }
java
public MailBuilder to(String name, String email) { return param("to", email(name, email)); }
[ "public", "MailBuilder", "to", "(", "String", "name", ",", "String", "email", ")", "{", "return", "param", "(", "\"to\"", ",", "email", "(", "name", ",", "email", ")", ")", ";", "}" ]
Adds a destination recipient's address. @param name the name of the destination recipient @param email the address of the destination recipient @return this builder
[ "Adds", "a", "destination", "recipient", "s", "address", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/MailBuilder.java#L108-L110
144,746
sargue/mailgun
src/main/java/net/sargue/mailgun/MailBuilder.java
MailBuilder.cc
public MailBuilder cc(String name, String email) { return param("cc", email(name, email)); }
java
public MailBuilder cc(String name, String email) { return param("cc", email(name, email)); }
[ "public", "MailBuilder", "cc", "(", "String", "name", ",", "String", "email", ")", "{", "return", "param", "(", "\"cc\"", ",", "email", "(", "name", ",", "email", ")", ")", ";", "}" ]
Adds a CC recipient's address. @param name the name of the CC recipient @param email the address of the CC recipient @return this builder
[ "Adds", "a", "CC", "recipient", "s", "address", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/MailBuilder.java#L134-L136
144,747
sargue/mailgun
src/main/java/net/sargue/mailgun/MailBuilder.java
MailBuilder.bcc
public MailBuilder bcc(String name, String email) { return param("bcc", email(name, email)); }
java
public MailBuilder bcc(String name, String email) { return param("bcc", email(name, email)); }
[ "public", "MailBuilder", "bcc", "(", "String", "name", ",", "String", "email", ")", "{", "return", "param", "(", "\"bcc\"", ",", "email", "(", "name", ",", "email", ")", ")", ";", "}" ]
Adds a BCC recipient's address. @param name the name of the BCC recipient @param email the address of the BCC recipient @return this builder
[ "Adds", "a", "BCC", "recipient", "s", "address", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/MailBuilder.java#L160-L162
144,748
sargue/mailgun
src/main/java/net/sargue/mailgun/Mail.java
Mail.sendAsync
public void sendAsync() { if (!configuration.mailSendFilter().filter(this)) return; MailRequestCallbackFactory factory = configuration.mailRequestCallbackFactory(); if (factory == null) { prepareSend(); request().async().post(entity()); } else sendAsync(factory.create(this)); }
java
public void sendAsync() { if (!configuration.mailSendFilter().filter(this)) return; MailRequestCallbackFactory factory = configuration.mailRequestCallbackFactory(); if (factory == null) { prepareSend(); request().async().post(entity()); } else sendAsync(factory.create(this)); }
[ "public", "void", "sendAsync", "(", ")", "{", "if", "(", "!", "configuration", ".", "mailSendFilter", "(", ")", ".", "filter", "(", "this", ")", ")", "return", ";", "MailRequestCallbackFactory", "factory", "=", "configuration", ".", "mailRequestCallbackFactory", "(", ")", ";", "if", "(", "factory", "==", "null", ")", "{", "prepareSend", "(", ")", ";", "request", "(", ")", ".", "async", "(", ")", ".", "post", "(", "entity", "(", ")", ")", ";", "}", "else", "sendAsync", "(", "factory", ".", "create", "(", "this", ")", ")", ";", "}" ]
Sends the email asynchronously. It uses the configuration provided default callback if available, ignoring the outcome otherwise. If you want to use a specific callback for this call use {@link #sendAsync(MailRequestCallback)} instead.
[ "Sends", "the", "email", "asynchronously", ".", "It", "uses", "the", "configuration", "provided", "default", "callback", "if", "available", "ignoring", "the", "outcome", "otherwise", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/Mail.java#L116-L124
144,749
sargue/mailgun
src/main/java/net/sargue/mailgun/MultipartBuilder.java
MultipartBuilder.attachment
public MultipartBuilder attachment(InputStream is, String filename) { return bodyPart(new StreamDataBodyPart(ATTACHMENT_NAME, is, filename)); }
java
public MultipartBuilder attachment(InputStream is, String filename) { return bodyPart(new StreamDataBodyPart(ATTACHMENT_NAME, is, filename)); }
[ "public", "MultipartBuilder", "attachment", "(", "InputStream", "is", ",", "String", "filename", ")", "{", "return", "bodyPart", "(", "new", "StreamDataBodyPart", "(", "ATTACHMENT_NAME", ",", "is", ",", "filename", ")", ")", ";", "}" ]
Adds a named attachment. @param is an stream to read the attachment @param filename the filename to give to the attachment @return this builder
[ "Adds", "a", "named", "attachment", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/MultipartBuilder.java#L66-L68
144,750
sargue/mailgun
src/main/java/net/sargue/mailgun/MultipartBuilder.java
MultipartBuilder.attachment
public MultipartBuilder attachment(String content, String filename) { ByteArrayInputStream is = new ByteArrayInputStream(content.getBytes()); return bodyPart(new StreamDataBodyPart(ATTACHMENT_NAME, is, filename)); }
java
public MultipartBuilder attachment(String content, String filename) { ByteArrayInputStream is = new ByteArrayInputStream(content.getBytes()); return bodyPart(new StreamDataBodyPart(ATTACHMENT_NAME, is, filename)); }
[ "public", "MultipartBuilder", "attachment", "(", "String", "content", ",", "String", "filename", ")", "{", "ByteArrayInputStream", "is", "=", "new", "ByteArrayInputStream", "(", "content", ".", "getBytes", "(", ")", ")", ";", "return", "bodyPart", "(", "new", "StreamDataBodyPart", "(", "ATTACHMENT_NAME", ",", "is", ",", "filename", ")", ")", ";", "}" ]
Adds an attachment directly by content. @param content the content of the attachment @param filename the filename of the attachment @return this builder
[ "Adds", "an", "attachment", "directly", "by", "content", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/MultipartBuilder.java#L91-L94
144,751
sargue/mailgun
src/main/java/net/sargue/mailgun/MultipartBuilder.java
MultipartBuilder.inline
public MultipartBuilder inline(InputStream is, String cidName) { return bodyPart(new StreamDataBodyPart("inline", is, cidName)); }
java
public MultipartBuilder inline(InputStream is, String cidName) { return bodyPart(new StreamDataBodyPart("inline", is, cidName)); }
[ "public", "MultipartBuilder", "inline", "(", "InputStream", "is", ",", "String", "cidName", ")", "{", "return", "bodyPart", "(", "new", "StreamDataBodyPart", "(", "\"inline\"", ",", "is", ",", "cidName", ")", ")", ";", "}" ]
Adds a named inline attachment. @param is an stream to read the attachment @param cidName the name to give to the attachment as referenced by the HTML email body i.e. use cidName sample-image.png for the below example <p> <img src="cid:sample-image.png" alt="sample"> </p> @return this builder
[ "Adds", "a", "named", "inline", "attachment", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/MultipartBuilder.java#L107-L109
144,752
sargue/mailgun
src/main/java/net/sargue/mailgun/content/MailContent.java
MailContent.row
public MailContent row(String firstCell, String secondCell, String thirdCell) { return tag("tr").cell(firstCell).cell(secondCell).cell(thirdCell).end(); }
java
public MailContent row(String firstCell, String secondCell, String thirdCell) { return tag("tr").cell(firstCell).cell(secondCell).cell(thirdCell).end(); }
[ "public", "MailContent", "row", "(", "String", "firstCell", ",", "String", "secondCell", ",", "String", "thirdCell", ")", "{", "return", "tag", "(", "\"tr\"", ")", ".", "cell", "(", "firstCell", ")", ".", "cell", "(", "secondCell", ")", ".", "cell", "(", "thirdCell", ")", ".", "end", "(", ")", ";", "}" ]
Adds a new row with three columns. @param firstCell the first cell text content @param secondCell the second cell text content @param thirdCell the third cell text content @return the changed mail content object
[ "Adds", "a", "new", "row", "with", "three", "columns", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/content/MailContent.java#L403-L407
144,753
sargue/mailgun
src/main/java/net/sargue/mailgun/content/Builder.java
Builder.mail
public MailBuilder mail() { if (mailBuilder != null) return mailBuilder.content(build()); else return MailBuilder.using(configuration).content(build()); }
java
public MailBuilder mail() { if (mailBuilder != null) return mailBuilder.content(build()); else return MailBuilder.using(configuration).content(build()); }
[ "public", "MailBuilder", "mail", "(", ")", "{", "if", "(", "mailBuilder", "!=", "null", ")", "return", "mailBuilder", ".", "content", "(", "build", "(", ")", ")", ";", "else", "return", "MailBuilder", ".", "using", "(", "configuration", ")", ".", "content", "(", "build", "(", ")", ")", ";", "}" ]
Convenience method for chaining the creation of the content body with the creation of the mail envelope. If this builder was created associated to a MailBuilder, that one (with the content updated) is returned. Else it returns a new {@link MailBuilder} with this content and using the same * configuration that this Builder was created with. @return a {@link MailBuilder} with this content
[ "Convenience", "method", "for", "chaining", "the", "creation", "of", "the", "content", "body", "with", "the", "creation", "of", "the", "mail", "envelope", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/content/Builder.java#L96-L101
144,754
sargue/mailgun
src/main/java/net/sargue/mailgun/content/Builder.java
Builder.end
public Builder end() { if (ends.isEmpty()) throw new IllegalStateException("No pending tag/section to close."); String tag = ends.pop(); html.a(tag); if (newLineAfterTheseTags.contains(tag.toLowerCase())) { html.nl(); text.nl(); } return this; }
java
public Builder end() { if (ends.isEmpty()) throw new IllegalStateException("No pending tag/section to close."); String tag = ends.pop(); html.a(tag); if (newLineAfterTheseTags.contains(tag.toLowerCase())) { html.nl(); text.nl(); } return this; }
[ "public", "Builder", "end", "(", ")", "{", "if", "(", "ends", ".", "isEmpty", "(", ")", ")", "throw", "new", "IllegalStateException", "(", "\"No pending tag/section to close.\"", ")", ";", "String", "tag", "=", "ends", ".", "pop", "(", ")", ";", "html", ".", "a", "(", "tag", ")", ";", "if", "(", "newLineAfterTheseTags", ".", "contains", "(", "tag", ".", "toLowerCase", "(", ")", ")", ")", "{", "html", ".", "nl", "(", ")", ";", "text", ".", "nl", "(", ")", ";", "}", "return", "this", ";", "}" ]
Closes the last opened tag or section. @return this builder @throws IllegalStateException if there are no pending tags to close
[ "Closes", "the", "last", "opened", "tag", "or", "section", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/content/Builder.java#L109-L119
144,755
sargue/mailgun
src/main/java/net/sargue/mailgun/content/Builder.java
Builder.row
public <T> Builder row(T firstCell, T secondCell) { return tag("tr").cell(firstCell, false).cell(secondCell).end(); }
java
public <T> Builder row(T firstCell, T secondCell) { return tag("tr").cell(firstCell, false).cell(secondCell).end(); }
[ "public", "<", "T", ">", "Builder", "row", "(", "T", "firstCell", ",", "T", "secondCell", ")", "{", "return", "tag", "(", "\"tr\"", ")", ".", "cell", "(", "firstCell", ",", "false", ")", ".", "cell", "(", "secondCell", ")", ".", "end", "(", ")", ";", "}" ]
Adds a new row with two columns. @param <T> the type parameter @param firstCell the first cell content @param secondCell the second cell content @return this builder
[ "Adds", "a", "new", "row", "with", "two", "columns", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/content/Builder.java#L440-L442
144,756
sargue/mailgun
src/main/java/net/sargue/mailgun/content/Builder.java
Builder.rowh
public <T> Builder rowh(String label, T data) { return tag("tr").cellHeader(label, false).cell(data).end(); }
java
public <T> Builder rowh(String label, T data) { return tag("tr").cellHeader(label, false).cell(data).end(); }
[ "public", "<", "T", ">", "Builder", "rowh", "(", "String", "label", ",", "T", "data", ")", "{", "return", "tag", "(", "\"tr\"", ")", ".", "cellHeader", "(", "label", ",", "false", ")", ".", "cell", "(", "data", ")", ".", "end", "(", ")", ";", "}" ]
Adds a new row with two columns, the first one being a header cell. @param <T> the type parameter @param label the header cell content @param data the second cell content @return this builder
[ "Adds", "a", "new", "row", "with", "two", "columns", "the", "first", "one", "being", "a", "header", "cell", "." ]
2ffb0a156f3f3666eb1bb2db661451b9377c3d11
https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/content/Builder.java#L452-L454
144,757
kevinherron/opc-ua-stack
stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/ArrayUtil.java
ArrayUtil.flatten
public static Object flatten(Object array) { Preconditions.checkArgument(array.getClass().isArray(), "array"); Class<?> type = getType(array); int[] dimensions = getDimensions(array); int length = length(dimensions); Object flattened = Array.newInstance(type, length); flatten(array, flattened, dimensions, 0); return flattened; }
java
public static Object flatten(Object array) { Preconditions.checkArgument(array.getClass().isArray(), "array"); Class<?> type = getType(array); int[] dimensions = getDimensions(array); int length = length(dimensions); Object flattened = Array.newInstance(type, length); flatten(array, flattened, dimensions, 0); return flattened; }
[ "public", "static", "Object", "flatten", "(", "Object", "array", ")", "{", "Preconditions", ".", "checkArgument", "(", "array", ".", "getClass", "(", ")", ".", "isArray", "(", ")", ",", "\"array\"", ")", ";", "Class", "<", "?", ">", "type", "=", "getType", "(", "array", ")", ";", "int", "[", "]", "dimensions", "=", "getDimensions", "(", "array", ")", ";", "int", "length", "=", "length", "(", "dimensions", ")", ";", "Object", "flattened", "=", "Array", ".", "newInstance", "(", "type", ",", "length", ")", ";", "flatten", "(", "array", ",", "flattened", ",", "dimensions", ",", "0", ")", ";", "return", "flattened", ";", "}" ]
Flatten a multi-dimensional array into a one-dimensional array. @param array the array to flatten. @return a 1-dimensional array.
[ "Flatten", "a", "multi", "-", "dimensional", "array", "into", "a", "one", "-", "dimensional", "array", "." ]
007f4e5c4ff102814bec17bb7c41f27e2e52f2fd
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/ArrayUtil.java#L33-L45
144,758
kevinherron/opc-ua-stack
stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/ArrayUtil.java
ArrayUtil.unflatten
public static Object unflatten(Object array, int[] dimensions) { Class<?> type = getType(array); return unflatten(type, array, dimensions, 0); }
java
public static Object unflatten(Object array, int[] dimensions) { Class<?> type = getType(array); return unflatten(type, array, dimensions, 0); }
[ "public", "static", "Object", "unflatten", "(", "Object", "array", ",", "int", "[", "]", "dimensions", ")", "{", "Class", "<", "?", ">", "type", "=", "getType", "(", "array", ")", ";", "return", "unflatten", "(", "type", ",", "array", ",", "dimensions", ",", "0", ")", ";", "}" ]
Un-flatten a one-dimensional array into an multi-dimensional array based on the provided dimensions. @param array the 1-dimensional array to un-flatten. @param dimensions the dimensions to un-flatten to. @return a multi-dimensional array of the provided dimensions.
[ "Un", "-", "flatten", "a", "one", "-", "dimensional", "array", "into", "an", "multi", "-", "dimensional", "array", "based", "on", "the", "provided", "dimensions", "." ]
007f4e5c4ff102814bec17bb7c41f27e2e52f2fd
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/ArrayUtil.java#L70-L74
144,759
kevinherron/opc-ua-stack
stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/DigestUtil.java
DigestUtil.sha1
public static byte[] sha1(byte[] input) { MessageDigest messageDigest = sha1Digest.get(); if (messageDigest == null) { try { messageDigest = MessageDigest.getInstance("SHA1"); sha1Digest.set(messageDigest); } catch (NoSuchAlgorithmException e) { throw new UaRuntimeException(StatusCodes.Bad_InternalError, e); } } return messageDigest.digest(input); }
java
public static byte[] sha1(byte[] input) { MessageDigest messageDigest = sha1Digest.get(); if (messageDigest == null) { try { messageDigest = MessageDigest.getInstance("SHA1"); sha1Digest.set(messageDigest); } catch (NoSuchAlgorithmException e) { throw new UaRuntimeException(StatusCodes.Bad_InternalError, e); } } return messageDigest.digest(input); }
[ "public", "static", "byte", "[", "]", "sha1", "(", "byte", "[", "]", "input", ")", "{", "MessageDigest", "messageDigest", "=", "sha1Digest", ".", "get", "(", ")", ";", "if", "(", "messageDigest", "==", "null", ")", "{", "try", "{", "messageDigest", "=", "MessageDigest", ".", "getInstance", "(", "\"SHA1\"", ")", ";", "sha1Digest", ".", "set", "(", "messageDigest", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "e", ")", "{", "throw", "new", "UaRuntimeException", "(", "StatusCodes", ".", "Bad_InternalError", ",", "e", ")", ";", "}", "}", "return", "messageDigest", ".", "digest", "(", "input", ")", ";", "}" ]
Compute the SHA1 digest for a given input. @param input the input to compute the digest for. @return the SHA1 digest of {@code input}.
[ "Compute", "the", "SHA1", "digest", "for", "a", "given", "input", "." ]
007f4e5c4ff102814bec17bb7c41f27e2e52f2fd
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/DigestUtil.java#L35-L48
144,760
kevinherron/opc-ua-stack
stack-core/src/main/java/com/digitalpetri/opcua/stack/core/channel/messages/TcpMessageEncoder.java
TcpMessageEncoder.encode
private static ByteBuf encode(MessageType messageType, Consumer<ByteBuf> messageEncoder, ByteBuf buffer) throws UaException { buffer.writeMedium(MessageType.toMediumInt(messageType)); buffer.writeByte('F'); int lengthIndex = buffer.writerIndex(); buffer.writeInt(0); int indexBefore = buffer.writerIndex(); messageEncoder.accept(buffer); int indexAfter = buffer.writerIndex(); int bytesWritten = indexAfter - indexBefore; buffer.writerIndex(lengthIndex); buffer.writeInt(8 + bytesWritten); buffer.writerIndex(indexAfter); return buffer; }
java
private static ByteBuf encode(MessageType messageType, Consumer<ByteBuf> messageEncoder, ByteBuf buffer) throws UaException { buffer.writeMedium(MessageType.toMediumInt(messageType)); buffer.writeByte('F'); int lengthIndex = buffer.writerIndex(); buffer.writeInt(0); int indexBefore = buffer.writerIndex(); messageEncoder.accept(buffer); int indexAfter = buffer.writerIndex(); int bytesWritten = indexAfter - indexBefore; buffer.writerIndex(lengthIndex); buffer.writeInt(8 + bytesWritten); buffer.writerIndex(indexAfter); return buffer; }
[ "private", "static", "ByteBuf", "encode", "(", "MessageType", "messageType", ",", "Consumer", "<", "ByteBuf", ">", "messageEncoder", ",", "ByteBuf", "buffer", ")", "throws", "UaException", "{", "buffer", ".", "writeMedium", "(", "MessageType", ".", "toMediumInt", "(", "messageType", ")", ")", ";", "buffer", ".", "writeByte", "(", "'", "'", ")", ";", "int", "lengthIndex", "=", "buffer", ".", "writerIndex", "(", ")", ";", "buffer", ".", "writeInt", "(", "0", ")", ";", "int", "indexBefore", "=", "buffer", ".", "writerIndex", "(", ")", ";", "messageEncoder", ".", "accept", "(", "buffer", ")", ";", "int", "indexAfter", "=", "buffer", ".", "writerIndex", "(", ")", ";", "int", "bytesWritten", "=", "indexAfter", "-", "indexBefore", ";", "buffer", ".", "writerIndex", "(", "lengthIndex", ")", ";", "buffer", ".", "writeInt", "(", "8", "+", "bytesWritten", ")", ";", "buffer", ".", "writerIndex", "(", "indexAfter", ")", ";", "return", "buffer", ";", "}" ]
Encode a simple UA TCP message. @param messageType {@link MessageType#Hello}, {@link MessageType#Acknowledge}, or {@link MessageType#Error}. @param messageEncoder a function that encodes the message payload. @param buffer the {@link ByteBuf} to encode into.
[ "Encode", "a", "simple", "UA", "TCP", "message", "." ]
007f4e5c4ff102814bec17bb7c41f27e2e52f2fd
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/channel/messages/TcpMessageEncoder.java#L59-L76
144,761
kevinherron/opc-ua-stack
stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/CertificateValidationUtil.java
CertificateValidationUtil.validateHostnameOrIpAddress
public static void validateHostnameOrIpAddress(X509Certificate certificate, String hostname) throws UaException { boolean dnsNameMatches = validateSubjectAltNameField(certificate, SUBJECT_ALT_NAME_DNS_NAME, hostname::equals); boolean ipAddressMatches = validateSubjectAltNameField(certificate, SUBJECT_ALT_NAME_IP_ADDRESS, hostname::equals); if (!(dnsNameMatches || ipAddressMatches)) { throw new UaException(StatusCodes.Bad_CertificateHostNameInvalid); } }
java
public static void validateHostnameOrIpAddress(X509Certificate certificate, String hostname) throws UaException { boolean dnsNameMatches = validateSubjectAltNameField(certificate, SUBJECT_ALT_NAME_DNS_NAME, hostname::equals); boolean ipAddressMatches = validateSubjectAltNameField(certificate, SUBJECT_ALT_NAME_IP_ADDRESS, hostname::equals); if (!(dnsNameMatches || ipAddressMatches)) { throw new UaException(StatusCodes.Bad_CertificateHostNameInvalid); } }
[ "public", "static", "void", "validateHostnameOrIpAddress", "(", "X509Certificate", "certificate", ",", "String", "hostname", ")", "throws", "UaException", "{", "boolean", "dnsNameMatches", "=", "validateSubjectAltNameField", "(", "certificate", ",", "SUBJECT_ALT_NAME_DNS_NAME", ",", "hostname", "::", "equals", ")", ";", "boolean", "ipAddressMatches", "=", "validateSubjectAltNameField", "(", "certificate", ",", "SUBJECT_ALT_NAME_IP_ADDRESS", ",", "hostname", "::", "equals", ")", ";", "if", "(", "!", "(", "dnsNameMatches", "||", "ipAddressMatches", ")", ")", "{", "throw", "new", "UaException", "(", "StatusCodes", ".", "Bad_CertificateHostNameInvalid", ")", ";", "}", "}" ]
Validate that the hostname used in the endpoint URL matches either the SubjectAltName DNSName or IPAddress in the given certificate. @param certificate the certificate to validate against. @param hostname the hostname used in the endpoint URL. @throws UaException if there is no matching DNSName or IPAddress entry.
[ "Validate", "that", "the", "hostname", "used", "in", "the", "endpoint", "URL", "matches", "either", "the", "SubjectAltName", "DNSName", "or", "IPAddress", "in", "the", "given", "certificate", "." ]
007f4e5c4ff102814bec17bb7c41f27e2e52f2fd
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/CertificateValidationUtil.java#L111-L121
144,762
kevinherron/opc-ua-stack
stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/CertificateValidationUtil.java
CertificateValidationUtil.validateApplicationUri
public static void validateApplicationUri(X509Certificate certificate, String applicationUri) throws UaException { if (!validateSubjectAltNameField(certificate, SUBJECT_ALT_NAME_URI, applicationUri::equals)) { throw new UaException(StatusCodes.Bad_CertificateUriInvalid); } }
java
public static void validateApplicationUri(X509Certificate certificate, String applicationUri) throws UaException { if (!validateSubjectAltNameField(certificate, SUBJECT_ALT_NAME_URI, applicationUri::equals)) { throw new UaException(StatusCodes.Bad_CertificateUriInvalid); } }
[ "public", "static", "void", "validateApplicationUri", "(", "X509Certificate", "certificate", ",", "String", "applicationUri", ")", "throws", "UaException", "{", "if", "(", "!", "validateSubjectAltNameField", "(", "certificate", ",", "SUBJECT_ALT_NAME_URI", ",", "applicationUri", "::", "equals", ")", ")", "{", "throw", "new", "UaException", "(", "StatusCodes", ".", "Bad_CertificateUriInvalid", ")", ";", "}", "}" ]
Validate that the application URI matches the SubjectAltName URI in the given certificate. @param certificate the certificate to validate against. @param applicationUri the URI to validate. @throws UaException if the certificate is invalid, does not contain a uri, or contains a uri that does not match.
[ "Validate", "that", "the", "application", "URI", "matches", "the", "SubjectAltName", "URI", "in", "the", "given", "certificate", "." ]
007f4e5c4ff102814bec17bb7c41f27e2e52f2fd
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/CertificateValidationUtil.java#L130-L134
144,763
kevinherron/opc-ua-stack
stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/SignatureUtil.java
SignatureUtil.hmac
public static byte[] hmac(SecurityAlgorithm securityAlgorithm, byte[] secretKey, ByteBuffer... buffers) throws UaException { String transformation = securityAlgorithm.getTransformation(); try { Mac mac = Mac.getInstance(transformation); mac.init(new SecretKeySpec(secretKey, transformation)); for (ByteBuffer buffer : buffers) { mac.update(buffer); } return mac.doFinal(); } catch (GeneralSecurityException e) { throw new UaException(StatusCodes.Bad_SecurityChecksFailed, e); } }
java
public static byte[] hmac(SecurityAlgorithm securityAlgorithm, byte[] secretKey, ByteBuffer... buffers) throws UaException { String transformation = securityAlgorithm.getTransformation(); try { Mac mac = Mac.getInstance(transformation); mac.init(new SecretKeySpec(secretKey, transformation)); for (ByteBuffer buffer : buffers) { mac.update(buffer); } return mac.doFinal(); } catch (GeneralSecurityException e) { throw new UaException(StatusCodes.Bad_SecurityChecksFailed, e); } }
[ "public", "static", "byte", "[", "]", "hmac", "(", "SecurityAlgorithm", "securityAlgorithm", ",", "byte", "[", "]", "secretKey", ",", "ByteBuffer", "...", "buffers", ")", "throws", "UaException", "{", "String", "transformation", "=", "securityAlgorithm", ".", "getTransformation", "(", ")", ";", "try", "{", "Mac", "mac", "=", "Mac", ".", "getInstance", "(", "transformation", ")", ";", "mac", ".", "init", "(", "new", "SecretKeySpec", "(", "secretKey", ",", "transformation", ")", ")", ";", "for", "(", "ByteBuffer", "buffer", ":", "buffers", ")", "{", "mac", ".", "update", "(", "buffer", ")", ";", "}", "return", "mac", ".", "doFinal", "(", ")", ";", "}", "catch", "(", "GeneralSecurityException", "e", ")", "{", "throw", "new", "UaException", "(", "StatusCodes", ".", "Bad_SecurityChecksFailed", ",", "e", ")", ";", "}", "}" ]
Compute the HMAC of the provided buffers. @param securityAlgorithm the {@link SecurityAlgorithm} that provides the transformation for {@link Mac#getInstance(String)}}. @param secretKey the secret key. @param buffers the buffers to use. @return the computed HMAC. @throws UaException
[ "Compute", "the", "HMAC", "of", "the", "provided", "buffers", "." ]
007f4e5c4ff102814bec17bb7c41f27e2e52f2fd
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/util/SignatureUtil.java#L72-L90
144,764
kevinherron/opc-ua-stack
stack-core/src/main/java/com/digitalpetri/opcua/stack/core/StatusCodes.java
StatusCodes.lookup
public static Optional<String[]> lookup(long code) { String[] desc = DESCRIPTIONS.get(code & 0xFFFF0000); return Optional.ofNullable(desc); }
java
public static Optional<String[]> lookup(long code) { String[] desc = DESCRIPTIONS.get(code & 0xFFFF0000); return Optional.ofNullable(desc); }
[ "public", "static", "Optional", "<", "String", "[", "]", ">", "lookup", "(", "long", "code", ")", "{", "String", "[", "]", "desc", "=", "DESCRIPTIONS", ".", "get", "(", "code", "&", "0xFFFF0000", ")", ";", "return", "Optional", ".", "ofNullable", "(", "desc", ")", ";", "}" ]
Lookup information about a StatusCode. @param code the code to lookup. @return a String[] where String[0] contains the name and String[1] contains the description.
[ "Lookup", "information", "about", "a", "StatusCode", "." ]
007f4e5c4ff102814bec17bb7c41f27e2e52f2fd
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/StatusCodes.java#L61-L65
144,765
kevinherron/opc-ua-stack
stack-client/src/main/java/com/digitalpetri/opcua/stack/client/UaTcpStackClient.java
UaTcpStackClient.getEndpoints
public static CompletableFuture<EndpointDescription[]> getEndpoints(String endpointUrl) { UaTcpStackClientConfig config = UaTcpStackClientConfig.builder() .setEndpointUrl(endpointUrl) .build(); UaTcpStackClient client = new UaTcpStackClient(config); GetEndpointsRequest request = new GetEndpointsRequest( new RequestHeader(null, DateTime.now(), uint(1), uint(0), null, uint(5000), null), endpointUrl, null, new String[]{Stack.UA_TCP_BINARY_TRANSPORT_URI}); return client.<GetEndpointsResponse>sendRequest(request) .whenComplete((r, ex) -> client.disconnect()) .thenApply(GetEndpointsResponse::getEndpoints); }
java
public static CompletableFuture<EndpointDescription[]> getEndpoints(String endpointUrl) { UaTcpStackClientConfig config = UaTcpStackClientConfig.builder() .setEndpointUrl(endpointUrl) .build(); UaTcpStackClient client = new UaTcpStackClient(config); GetEndpointsRequest request = new GetEndpointsRequest( new RequestHeader(null, DateTime.now(), uint(1), uint(0), null, uint(5000), null), endpointUrl, null, new String[]{Stack.UA_TCP_BINARY_TRANSPORT_URI}); return client.<GetEndpointsResponse>sendRequest(request) .whenComplete((r, ex) -> client.disconnect()) .thenApply(GetEndpointsResponse::getEndpoints); }
[ "public", "static", "CompletableFuture", "<", "EndpointDescription", "[", "]", ">", "getEndpoints", "(", "String", "endpointUrl", ")", "{", "UaTcpStackClientConfig", "config", "=", "UaTcpStackClientConfig", ".", "builder", "(", ")", ".", "setEndpointUrl", "(", "endpointUrl", ")", ".", "build", "(", ")", ";", "UaTcpStackClient", "client", "=", "new", "UaTcpStackClient", "(", "config", ")", ";", "GetEndpointsRequest", "request", "=", "new", "GetEndpointsRequest", "(", "new", "RequestHeader", "(", "null", ",", "DateTime", ".", "now", "(", ")", ",", "uint", "(", "1", ")", ",", "uint", "(", "0", ")", ",", "null", ",", "uint", "(", "5000", ")", ",", "null", ")", ",", "endpointUrl", ",", "null", ",", "new", "String", "[", "]", "{", "Stack", ".", "UA_TCP_BINARY_TRANSPORT_URI", "}", ")", ";", "return", "client", ".", "<", "GetEndpointsResponse", ">", "sendRequest", "(", "request", ")", ".", "whenComplete", "(", "(", "r", ",", "ex", ")", "->", "client", ".", "disconnect", "(", ")", ")", ".", "thenApply", "(", "GetEndpointsResponse", "::", "getEndpoints", ")", ";", "}" ]
Query the GetEndpoints service at the given endpoint URL. @param endpointUrl the endpoint URL to get endpoints from. @return the {@link EndpointDescription}s returned by the GetEndpoints service.
[ "Query", "the", "GetEndpoints", "service", "at", "the", "given", "endpoint", "URL", "." ]
007f4e5c4ff102814bec17bb7c41f27e2e52f2fd
https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-client/src/main/java/com/digitalpetri/opcua/stack/client/UaTcpStackClient.java#L412-L426
144,766
duracloud/snapshot
snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/StepExecutionSupport.java
StepExecutionSupport.skipLinesAlreadyRead
protected void skipLinesAlreadyRead(Iterator it) { long linesRead = getItemsRead(); if (linesRead > 0) { for (long i = 0; i < linesRead; i++) { if (it.hasNext()) { it.next(); } } } }
java
protected void skipLinesAlreadyRead(Iterator it) { long linesRead = getItemsRead(); if (linesRead > 0) { for (long i = 0; i < linesRead; i++) { if (it.hasNext()) { it.next(); } } } }
[ "protected", "void", "skipLinesAlreadyRead", "(", "Iterator", "it", ")", "{", "long", "linesRead", "=", "getItemsRead", "(", ")", ";", "if", "(", "linesRead", ">", "0", ")", "{", "for", "(", "long", "i", "=", "0", ";", "i", "<", "linesRead", ";", "i", "++", ")", "{", "if", "(", "it", ".", "hasNext", "(", ")", ")", "{", "it", ".", "next", "(", ")", ";", "}", "}", "}", "}" ]
Skips the iterator ahead to the items read value stored in the execution context @param it any iterator
[ "Skips", "the", "iterator", "ahead", "to", "the", "items", "read", "value", "stored", "in", "the", "execution", "context" ]
7cb387b22fd4a9425087f654276138727c2c0b73
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/StepExecutionSupport.java#L89-L98
144,767
duracloud/snapshot
snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/StepExecutionSupport.java
StepExecutionSupport.addToLong
protected void addToLong(String key, long value) { synchronized (this.stepExecution) { long currentValue = getLongValue(key); getExecutionContext().putLong(key, currentValue + value); } }
java
protected void addToLong(String key, long value) { synchronized (this.stepExecution) { long currentValue = getLongValue(key); getExecutionContext().putLong(key, currentValue + value); } }
[ "protected", "void", "addToLong", "(", "String", "key", ",", "long", "value", ")", "{", "synchronized", "(", "this", ".", "stepExecution", ")", "{", "long", "currentValue", "=", "getLongValue", "(", "key", ")", ";", "getExecutionContext", "(", ")", ".", "putLong", "(", "key", ",", "currentValue", "+", "value", ")", ";", "}", "}" ]
Adds the specified value to the existing key. @param key @param value
[ "Adds", "the", "specified", "value", "to", "the", "existing", "key", "." ]
7cb387b22fd4a9425087f654276138727c2c0b73
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/StepExecutionSupport.java#L141-L147
144,768
vatbub/common
core/src/main/java/com/github/vatbub/common/core/Prefs.java
Prefs.reload
public void reload() { try { if (file.exists()) { try(FileReader fileReader = new FileReader(file)) { props.load(fileReader); } } } catch (IOException e) { FOKLogger.log(Prefs.class.getName(), Level.SEVERE, FOKLogger.DEFAULT_ERROR_TEXT, e); } }
java
public void reload() { try { if (file.exists()) { try(FileReader fileReader = new FileReader(file)) { props.load(fileReader); } } } catch (IOException e) { FOKLogger.log(Prefs.class.getName(), Level.SEVERE, FOKLogger.DEFAULT_ERROR_TEXT, e); } }
[ "public", "void", "reload", "(", ")", "{", "try", "{", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "try", "(", "FileReader", "fileReader", "=", "new", "FileReader", "(", "file", ")", ")", "{", "props", ".", "load", "(", "fileReader", ")", ";", "}", "}", "}", "catch", "(", "IOException", "e", ")", "{", "FOKLogger", ".", "log", "(", "Prefs", ".", "class", ".", "getName", "(", ")", ",", "Level", ".", "SEVERE", ",", "FOKLogger", ".", "DEFAULT_ERROR_TEXT", ",", "e", ")", ";", "}", "}" ]
Reloads this preference file from the hard disk
[ "Reloads", "this", "preference", "file", "from", "the", "hard", "disk" ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/core/src/main/java/com/github/vatbub/common/core/Prefs.java#L54-L65
144,769
vatbub/common
core/src/main/java/com/github/vatbub/common/core/Prefs.java
Prefs.setPreference
public void setPreference(String prefKey, String prefValue) { props.setProperty(prefKey, prefValue); savePreferences(); }
java
public void setPreference(String prefKey, String prefValue) { props.setProperty(prefKey, prefValue); savePreferences(); }
[ "public", "void", "setPreference", "(", "String", "prefKey", ",", "String", "prefValue", ")", "{", "props", ".", "setProperty", "(", "prefKey", ",", "prefValue", ")", ";", "savePreferences", "(", ")", ";", "}" ]
Sets the value of the specified preference in the properties file @param prefKey The key of the preference to save @param prefValue The value of the preference to save
[ "Sets", "the", "value", "of", "the", "specified", "preference", "in", "the", "properties", "file" ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/core/src/main/java/com/github/vatbub/common/core/Prefs.java#L73-L76
144,770
vatbub/common
core/src/main/java/com/github/vatbub/common/core/Prefs.java
Prefs.getPreference
public String getPreference(String prefKey, String defaultValue) { return props.getProperty(prefKey, defaultValue); }
java
public String getPreference(String prefKey, String defaultValue) { return props.getProperty(prefKey, defaultValue); }
[ "public", "String", "getPreference", "(", "String", "prefKey", ",", "String", "defaultValue", ")", "{", "return", "props", ".", "getProperty", "(", "prefKey", ",", "defaultValue", ")", ";", "}" ]
Returns the value of the specified preference. @param prefKey The preference to look for @param defaultValue The value to be returned if the key was not found in the properties file @return The value of the specified preference or the {@code defaultValue} if the key was not found
[ "Returns", "the", "value", "of", "the", "specified", "preference", "." ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/core/src/main/java/com/github/vatbub/common/core/Prefs.java#L85-L87
144,771
cloudiator/sword
drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/config/JCloudsComputeModule.java
JCloudsComputeModule.overrideImageSupplier
protected Supplier<Set<Image>> overrideImageSupplier(Injector injector, Supplier<Set<Image>> originalSupplier) { return originalSupplier; }
java
protected Supplier<Set<Image>> overrideImageSupplier(Injector injector, Supplier<Set<Image>> originalSupplier) { return originalSupplier; }
[ "protected", "Supplier", "<", "Set", "<", "Image", ">", ">", "overrideImageSupplier", "(", "Injector", "injector", ",", "Supplier", "<", "Set", "<", "Image", ">", ">", "originalSupplier", ")", "{", "return", "originalSupplier", ";", "}" ]
Allows jclouds submodules to override the image supplier
[ "Allows", "jclouds", "submodules", "to", "override", "the", "image", "supplier" ]
b7808ea2776c6d70d439342c403369dfc5bb26bc
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/config/JCloudsComputeModule.java#L108-L111
144,772
cloudiator/sword
drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/config/JCloudsComputeModule.java
JCloudsComputeModule.overrideLocationSupplier
protected Supplier<Set<Location>> overrideLocationSupplier(Injector injector, Supplier<Set<Location>> originalSupplier) { return originalSupplier; }
java
protected Supplier<Set<Location>> overrideLocationSupplier(Injector injector, Supplier<Set<Location>> originalSupplier) { return originalSupplier; }
[ "protected", "Supplier", "<", "Set", "<", "Location", ">", ">", "overrideLocationSupplier", "(", "Injector", "injector", ",", "Supplier", "<", "Set", "<", "Location", ">", ">", "originalSupplier", ")", "{", "return", "originalSupplier", ";", "}" ]
Allows jclouds submodules to override the location supplier
[ "Allows", "jclouds", "submodules", "to", "override", "the", "location", "supplier" ]
b7808ea2776c6d70d439342c403369dfc5bb26bc
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/config/JCloudsComputeModule.java#L121-L124
144,773
cloudiator/sword
drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/config/JCloudsComputeModule.java
JCloudsComputeModule.overrideHardwareFlavorSupplier
protected Supplier<Set<HardwareFlavor>> overrideHardwareFlavorSupplier(Injector injector, Supplier<Set<HardwareFlavor>> originalSupplier) { return originalSupplier; }
java
protected Supplier<Set<HardwareFlavor>> overrideHardwareFlavorSupplier(Injector injector, Supplier<Set<HardwareFlavor>> originalSupplier) { return originalSupplier; }
[ "protected", "Supplier", "<", "Set", "<", "HardwareFlavor", ">", ">", "overrideHardwareFlavorSupplier", "(", "Injector", "injector", ",", "Supplier", "<", "Set", "<", "HardwareFlavor", ">", ">", "originalSupplier", ")", "{", "return", "originalSupplier", ";", "}" ]
Allows jclouds submodules to override the hardware supplier
[ "Allows", "jclouds", "submodules", "to", "override", "the", "hardware", "supplier" ]
b7808ea2776c6d70d439342c403369dfc5bb26bc
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/config/JCloudsComputeModule.java#L135-L138
144,774
cloudiator/sword
drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/config/JCloudsComputeModule.java
JCloudsComputeModule.overrideVirtualMachineSupplier
protected Supplier<Set<VirtualMachine>> overrideVirtualMachineSupplier(Injector injector, Supplier<Set<VirtualMachine>> originalSupplier) { return originalSupplier; }
java
protected Supplier<Set<VirtualMachine>> overrideVirtualMachineSupplier(Injector injector, Supplier<Set<VirtualMachine>> originalSupplier) { return originalSupplier; }
[ "protected", "Supplier", "<", "Set", "<", "VirtualMachine", ">", ">", "overrideVirtualMachineSupplier", "(", "Injector", "injector", ",", "Supplier", "<", "Set", "<", "VirtualMachine", ">", ">", "originalSupplier", ")", "{", "return", "originalSupplier", ";", "}" ]
Allows jclouds submodules to override the VirtualMachine supplier
[ "Allows", "jclouds", "submodules", "to", "override", "the", "VirtualMachine", "supplier" ]
b7808ea2776c6d70d439342c403369dfc5bb26bc
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/config/JCloudsComputeModule.java#L149-L152
144,775
cloudiator/sword
core/src/main/java/de/uniulm/omi/cloudiator/sword/domain/TemplateOptionsBuilder.java
TemplateOptionsBuilder.addOption
public TemplateOptionsBuilder addOption(Object field, Object value) { additionalOptions.put(field, value); return this; }
java
public TemplateOptionsBuilder addOption(Object field, Object value) { additionalOptions.put(field, value); return this; }
[ "public", "TemplateOptionsBuilder", "addOption", "(", "Object", "field", ",", "Object", "value", ")", "{", "additionalOptions", ".", "put", "(", "field", ",", "value", ")", ";", "return", "this", ";", "}" ]
Adds a generic option to the template @param field key of the option @param value value of the option @return fluid interface
[ "Adds", "a", "generic", "option", "to", "the", "template" ]
b7808ea2776c6d70d439342c403369dfc5bb26bc
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/core/src/main/java/de/uniulm/omi/cloudiator/sword/domain/TemplateOptionsBuilder.java#L88-L91
144,776
cloudiator/sword
core/src/main/java/de/uniulm/omi/cloudiator/sword/domain/LocationBuilder.java
LocationBuilder.build
public Location build() { return new LocationImpl(id, providerId, name, parent, isAssignable, locationScope, geoLocation, tags); }
java
public Location build() { return new LocationImpl(id, providerId, name, parent, isAssignable, locationScope, geoLocation, tags); }
[ "public", "Location", "build", "(", ")", "{", "return", "new", "LocationImpl", "(", "id", ",", "providerId", ",", "name", ",", "parent", ",", "isAssignable", ",", "locationScope", ",", "geoLocation", ",", "tags", ")", ";", "}" ]
Builds the location. @return the location.
[ "Builds", "the", "location", "." ]
b7808ea2776c6d70d439342c403369dfc5bb26bc
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/core/src/main/java/de/uniulm/omi/cloudiator/sword/domain/LocationBuilder.java#L76-L79
144,777
vatbub/common
core/src/main/java/com/github/vatbub/common/core/StringCommon.java
StringCommon.fromFile
public static String fromFile(File file) throws IOException { BufferedReader br = new BufferedReader(new FileReader(file)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); line = br.readLine(); if (line != null) sb.append(System.lineSeparator()); } br.close(); return sb.toString(); }
java
public static String fromFile(File file) throws IOException { BufferedReader br = new BufferedReader(new FileReader(file)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); line = br.readLine(); if (line != null) sb.append(System.lineSeparator()); } br.close(); return sb.toString(); }
[ "public", "static", "String", "fromFile", "(", "File", "file", ")", "throws", "IOException", "{", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "new", "FileReader", "(", "file", ")", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "String", "line", "=", "br", ".", "readLine", "(", ")", ";", "while", "(", "line", "!=", "null", ")", "{", "sb", ".", "append", "(", "line", ")", ";", "line", "=", "br", ".", "readLine", "(", ")", ";", "if", "(", "line", "!=", "null", ")", "sb", ".", "append", "(", "System", ".", "lineSeparator", "(", ")", ")", ";", "}", "br", ".", "close", "(", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Reads the text from a text file @param file The file to read @return The text in that text file @throws IOException if the file cannot be read
[ "Reads", "the", "text", "from", "a", "text", "file" ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/core/src/main/java/com/github/vatbub/common/core/StringCommon.java#L45-L59
144,778
vatbub/common
core/src/main/java/com/github/vatbub/common/core/StringCommon.java
StringCommon.getRequiredSpaces
private static String getRequiredSpaces(String reference, String message) { StringBuilder res = new StringBuilder(); int requiredSpaces = reference.length() - message.length() - 4; for (int i = 0; i < requiredSpaces; i++) { res.append(" "); } return res.toString(); }
java
private static String getRequiredSpaces(String reference, String message) { StringBuilder res = new StringBuilder(); int requiredSpaces = reference.length() - message.length() - 4; for (int i = 0; i < requiredSpaces; i++) { res.append(" "); } return res.toString(); }
[ "private", "static", "String", "getRequiredSpaces", "(", "String", "reference", ",", "String", "message", ")", "{", "StringBuilder", "res", "=", "new", "StringBuilder", "(", ")", ";", "int", "requiredSpaces", "=", "reference", ".", "length", "(", ")", "-", "message", ".", "length", "(", ")", "-", "4", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "requiredSpaces", ";", "i", "++", ")", "{", "res", ".", "append", "(", "\" \"", ")", ";", "}", "return", "res", ".", "toString", "(", ")", ";", "}" ]
Formats a message to be printed on the console @param message The line to be formatted @return The formatted version of {@code message}
[ "Formats", "a", "message", "to", "be", "printed", "on", "the", "console" ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/core/src/main/java/com/github/vatbub/common/core/StringCommon.java#L90-L99
144,779
vatbub/common
core/src/main/java/com/github/vatbub/common/core/Config.java
Config.readRemoteConfig
private void readRemoteConfig(URL remoteConfig, URL fallbackConfig, boolean cacheRemoteConfig, String cacheFileName) throws IOException { // Check if offline cache exists checkForOfflineCacheOrLoadFallback(fallbackConfig, cacheFileName); if (!isOfflineMode()) getRemoteConfig(remoteConfig, cacheRemoteConfig, cacheFileName); }
java
private void readRemoteConfig(URL remoteConfig, URL fallbackConfig, boolean cacheRemoteConfig, String cacheFileName) throws IOException { // Check if offline cache exists checkForOfflineCacheOrLoadFallback(fallbackConfig, cacheFileName); if (!isOfflineMode()) getRemoteConfig(remoteConfig, cacheRemoteConfig, cacheFileName); }
[ "private", "void", "readRemoteConfig", "(", "URL", "remoteConfig", ",", "URL", "fallbackConfig", ",", "boolean", "cacheRemoteConfig", ",", "String", "cacheFileName", ")", "throws", "IOException", "{", "// Check if offline cache exists", "checkForOfflineCacheOrLoadFallback", "(", "fallbackConfig", ",", "cacheFileName", ")", ";", "if", "(", "!", "isOfflineMode", "(", ")", ")", "getRemoteConfig", "(", "remoteConfig", ",", "cacheRemoteConfig", ",", "cacheFileName", ")", ";", "}" ]
Reads the config from the remote url synchronously. If this fails for any reason and a cached config is available, the cached config is used instead. If the remote config can't be read and no cached version is available, the fallbackConfig is used. @param remoteConfig The {@code URL} of the remote config to be read. @param fallbackConfig The config file to be read in case the {@code remoteConfig} cannot be downloaded and no cached version is available. @param cacheRemoteConfig If {@code true}, the remote config will be cached once downloaded for offline use. @throws IOException If the specified fallbackConfig does not exist or cannot be read.
[ "Reads", "the", "config", "from", "the", "remote", "url", "synchronously", ".", "If", "this", "fails", "for", "any", "reason", "and", "a", "cached", "config", "is", "available", "the", "cached", "config", "is", "used", "instead", ".", "If", "the", "remote", "config", "can", "t", "be", "read", "and", "no", "cached", "version", "is", "available", "the", "fallbackConfig", "is", "used", "." ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/core/src/main/java/com/github/vatbub/common/core/Config.java#L186-L192
144,780
vatbub/common
core/src/main/java/com/github/vatbub/common/core/Config.java
Config.contains
public boolean contains(String key) { return onlineProps.getProperty(key) != null || offlineProps.getProperty(key) != null; }
java
public boolean contains(String key) { return onlineProps.getProperty(key) != null || offlineProps.getProperty(key) != null; }
[ "public", "boolean", "contains", "(", "String", "key", ")", "{", "return", "onlineProps", ".", "getProperty", "(", "key", ")", "!=", "null", "||", "offlineProps", ".", "getProperty", "(", "key", ")", "!=", "null", ";", "}" ]
Checks if the specified key is defined in this Config file. @param key The key of the property to be checked. @return {@code true} if a property with the specified key is found, {@code false} otherwise.
[ "Checks", "if", "the", "specified", "key", "is", "defined", "in", "this", "Config", "file", "." ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/core/src/main/java/com/github/vatbub/common/core/Config.java#L264-L266
144,781
vatbub/common
updater/src/main/java/com/github/vatbub/common/updater/VersionList.java
VersionList.removeSnapshots
public void removeSnapshots() { VersionList versionToRemove = new VersionList(); // collect Versions to be removed for (Version ver : this) { if (ver.isSnapshot()) { versionToRemove.add(ver); } } // remove them this.removeAll(versionToRemove); }
java
public void removeSnapshots() { VersionList versionToRemove = new VersionList(); // collect Versions to be removed for (Version ver : this) { if (ver.isSnapshot()) { versionToRemove.add(ver); } } // remove them this.removeAll(versionToRemove); }
[ "public", "void", "removeSnapshots", "(", ")", "{", "VersionList", "versionToRemove", "=", "new", "VersionList", "(", ")", ";", "// collect Versions to be removed", "for", "(", "Version", "ver", ":", "this", ")", "{", "if", "(", "ver", ".", "isSnapshot", "(", ")", ")", "{", "versionToRemove", ".", "add", "(", "ver", ")", ";", "}", "}", "// remove them", "this", ".", "removeAll", "(", "versionToRemove", ")", ";", "}" ]
Removes all snapshots from this list
[ "Removes", "all", "snapshots", "from", "this", "list" ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/updater/src/main/java/com/github/vatbub/common/updater/VersionList.java#L53-L65
144,782
vatbub/common
view/motd/core/src/main/java/com/github/vatbub/common/view/motd/PlatformIndependentMOTD.java
PlatformIndependentMOTD.markAsRead
public void markAsRead() throws IOException, ClassNotFoundException { if (!this.isMarkedAsRead()) { FileOutputStream fileOut = getMotdFileOutputStreamProvider().createFileOutputStream(getNextSerializationFileName()); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(entry); out.close(); fileOut.close(); } }
java
public void markAsRead() throws IOException, ClassNotFoundException { if (!this.isMarkedAsRead()) { FileOutputStream fileOut = getMotdFileOutputStreamProvider().createFileOutputStream(getNextSerializationFileName()); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(entry); out.close(); fileOut.close(); } }
[ "public", "void", "markAsRead", "(", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "if", "(", "!", "this", ".", "isMarkedAsRead", "(", ")", ")", "{", "FileOutputStream", "fileOut", "=", "getMotdFileOutputStreamProvider", "(", ")", ".", "createFileOutputStream", "(", "getNextSerializationFileName", "(", ")", ")", ";", "ObjectOutputStream", "out", "=", "new", "ObjectOutputStream", "(", "fileOut", ")", ";", "out", ".", "writeObject", "(", "entry", ")", ";", "out", ".", "close", "(", ")", ";", "fileOut", ".", "close", "(", ")", ";", "}", "}" ]
Marks this message of the day as read. @throws IOException If the info if this message of the day is marked as read cannot be read from the computers hard disk @throws ClassNotFoundException This exception occurs if you did not add the <a href="https://rometools.github.io/rome/index.html">ROME library</a> to your classpath. If you use maven don't worry about this exception as maven already added the library for you.
[ "Marks", "this", "message", "of", "the", "day", "as", "read", "." ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/view/motd/core/src/main/java/com/github/vatbub/common/view/motd/PlatformIndependentMOTD.java#L253-L261
144,783
vatbub/common
core/src/main/java/com/github/vatbub/common/core/linux/DesktopFile.java
DesktopFile.isValid
public boolean isValid() { if (name == null) { return false; } if (type == null || !type.isValid()) { return false; } else if (type == Type.Link) { if (url == null) { return false; } } // Check actions if (this.getActions() != null) { for (DesktopAction a : this.getActions()) { if (!a.isValid()) { return false; } } } // Everything ok return true; }
java
public boolean isValid() { if (name == null) { return false; } if (type == null || !type.isValid()) { return false; } else if (type == Type.Link) { if (url == null) { return false; } } // Check actions if (this.getActions() != null) { for (DesktopAction a : this.getActions()) { if (!a.isValid()) { return false; } } } // Everything ok return true; }
[ "public", "boolean", "isValid", "(", ")", "{", "if", "(", "name", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "type", "==", "null", "||", "!", "type", ".", "isValid", "(", ")", ")", "{", "return", "false", ";", "}", "else", "if", "(", "type", "==", "Type", ".", "Link", ")", "{", "if", "(", "url", "==", "null", ")", "{", "return", "false", ";", "}", "}", "// Check actions", "if", "(", "this", ".", "getActions", "(", ")", "!=", "null", ")", "{", "for", "(", "DesktopAction", "a", ":", "this", ".", "getActions", "(", ")", ")", "{", "if", "(", "!", "a", ".", "isValid", "(", ")", ")", "{", "return", "false", ";", "}", "}", "}", "// Everything ok", "return", "true", ";", "}" ]
Checks if this link is valid to be saved @return {@code true} if this link is valid, {@code false} if not.
[ "Checks", "if", "this", "link", "is", "valid", "to", "be", "saved" ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/core/src/main/java/com/github/vatbub/common/core/linux/DesktopFile.java#L1563-L1587
144,784
lastaflute/lasta-thymeleaf
src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java
ClassificationExpressionObject.list
public List<Classification> list(String classificationName) { assertArgumentNotNull("classificationName", classificationName); final String delimiter = GROUP_DELIMITER; final String pureName; final String groupName; if (classificationName.contains(delimiter)) { // e.g. sea.land or maihamadb-sea.land pureName = Srl.substringFirstFront(classificationName, delimiter); // e.g. sea or maihamadb-sea groupName = Srl.substringFirstRear(classificationName, delimiter); // e.g. land } else { // e.g. sea or maihamadb-sea pureName = classificationName; groupName = null; } final ClassificationMeta meta = findClassificationMeta(pureName, () -> { return "list('" + classificationName + "')"; }); if (groupName != null) { final List<Classification> groupOfList = meta.groupOf(groupName); if (groupOfList.isEmpty()) { // means not found throw new TemplateProcessingException("Not found the classification group: " + groupName + " of " + pureName); } return groupOfList; } else { return meta.listAll(); } }
java
public List<Classification> list(String classificationName) { assertArgumentNotNull("classificationName", classificationName); final String delimiter = GROUP_DELIMITER; final String pureName; final String groupName; if (classificationName.contains(delimiter)) { // e.g. sea.land or maihamadb-sea.land pureName = Srl.substringFirstFront(classificationName, delimiter); // e.g. sea or maihamadb-sea groupName = Srl.substringFirstRear(classificationName, delimiter); // e.g. land } else { // e.g. sea or maihamadb-sea pureName = classificationName; groupName = null; } final ClassificationMeta meta = findClassificationMeta(pureName, () -> { return "list('" + classificationName + "')"; }); if (groupName != null) { final List<Classification> groupOfList = meta.groupOf(groupName); if (groupOfList.isEmpty()) { // means not found throw new TemplateProcessingException("Not found the classification group: " + groupName + " of " + pureName); } return groupOfList; } else { return meta.listAll(); } }
[ "public", "List", "<", "Classification", ">", "list", "(", "String", "classificationName", ")", "{", "assertArgumentNotNull", "(", "\"classificationName\"", ",", "classificationName", ")", ";", "final", "String", "delimiter", "=", "GROUP_DELIMITER", ";", "final", "String", "pureName", ";", "final", "String", "groupName", ";", "if", "(", "classificationName", ".", "contains", "(", "delimiter", ")", ")", "{", "// e.g. sea.land or maihamadb-sea.land", "pureName", "=", "Srl", ".", "substringFirstFront", "(", "classificationName", ",", "delimiter", ")", ";", "// e.g. sea or maihamadb-sea", "groupName", "=", "Srl", ".", "substringFirstRear", "(", "classificationName", ",", "delimiter", ")", ";", "// e.g. land", "}", "else", "{", "// e.g. sea or maihamadb-sea", "pureName", "=", "classificationName", ";", "groupName", "=", "null", ";", "}", "final", "ClassificationMeta", "meta", "=", "findClassificationMeta", "(", "pureName", ",", "(", ")", "->", "{", "return", "\"list('\"", "+", "classificationName", "+", "\"')\"", ";", "}", ")", ";", "if", "(", "groupName", "!=", "null", ")", "{", "final", "List", "<", "Classification", ">", "groupOfList", "=", "meta", ".", "groupOf", "(", "groupName", ")", ";", "if", "(", "groupOfList", ".", "isEmpty", "(", ")", ")", "{", "// means not found", "throw", "new", "TemplateProcessingException", "(", "\"Not found the classification group: \"", "+", "groupName", "+", "\" of \"", "+", "pureName", ")", ";", "}", "return", "groupOfList", ";", "}", "else", "{", "return", "meta", ".", "listAll", "(", ")", ";", "}", "}" ]
Get list of specified classification. @param classificationName The name of classification, can contain group name by delimiter. (NotNull) @return The list of all classification. (NotNull)
[ "Get", "list", "of", "specified", "classification", "." ]
d340a6e7eeddfcc9177052958c383fecd4a7fefa
https://github.com/lastaflute/lasta-thymeleaf/blob/d340a6e7eeddfcc9177052958c383fecd4a7fefa/src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java#L84-L108
144,785
lastaflute/lasta-thymeleaf
src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java
ClassificationExpressionObject.listAll
public List<Classification> listAll(String classificationName) { assertArgumentNotNull("classificationName", classificationName); return findClassificationMeta(classificationName, () -> { return "listAll('" + classificationName + "')"; }).listAll(); }
java
public List<Classification> listAll(String classificationName) { assertArgumentNotNull("classificationName", classificationName); return findClassificationMeta(classificationName, () -> { return "listAll('" + classificationName + "')"; }).listAll(); }
[ "public", "List", "<", "Classification", ">", "listAll", "(", "String", "classificationName", ")", "{", "assertArgumentNotNull", "(", "\"classificationName\"", ",", "classificationName", ")", ";", "return", "findClassificationMeta", "(", "classificationName", ",", "(", ")", "->", "{", "return", "\"listAll('\"", "+", "classificationName", "+", "\"')\"", ";", "}", ")", ".", "listAll", "(", ")", ";", "}" ]
Get list of all classification. @param classificationName The name of classification. (NotNull) @return The list of all classification. (NotNull)
[ "Get", "list", "of", "all", "classification", "." ]
d340a6e7eeddfcc9177052958c383fecd4a7fefa
https://github.com/lastaflute/lasta-thymeleaf/blob/d340a6e7eeddfcc9177052958c383fecd4a7fefa/src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java#L118-L123
144,786
lastaflute/lasta-thymeleaf
src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java
ClassificationExpressionObject.alias
public String alias(Object cls, String defaultValue) { assertArgumentNotNull("defaultValue", defaultValue); if (cls != null) { return alias(cls); } else { return defaultValue; } }
java
public String alias(Object cls, String defaultValue) { assertArgumentNotNull("defaultValue", defaultValue); if (cls != null) { return alias(cls); } else { return defaultValue; } }
[ "public", "String", "alias", "(", "Object", "cls", ",", "String", "defaultValue", ")", "{", "assertArgumentNotNull", "(", "\"defaultValue\"", ",", "defaultValue", ")", ";", "if", "(", "cls", "!=", "null", ")", "{", "return", "alias", "(", "cls", ")", ";", "}", "else", "{", "return", "defaultValue", ";", "}", "}" ]
Get classification alias or default value if the classification is null. @param cls The instance of classification to get code. (NotNull) @param defaultValue The default value for no classification. (NotNull, EmptyAllowed) @return The alias of classification. (NotNull: if not classification, throws exception)
[ "Get", "classification", "alias", "or", "default", "value", "if", "the", "classification", "is", "null", "." ]
d340a6e7eeddfcc9177052958c383fecd4a7fefa
https://github.com/lastaflute/lasta-thymeleaf/blob/d340a6e7eeddfcc9177052958c383fecd4a7fefa/src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java#L145-L152
144,787
lastaflute/lasta-thymeleaf
src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java
ClassificationExpressionObject.codeOf
public Classification codeOf(String classificationName, String code) { assertArgumentNotNull("elementName", classificationName); assertArgumentNotNull("code", code); return findClassificationMeta(classificationName, () -> { return "codeOf('" + classificationName + "', '" + code + "')"; }).codeOf(code); }
java
public Classification codeOf(String classificationName, String code) { assertArgumentNotNull("elementName", classificationName); assertArgumentNotNull("code", code); return findClassificationMeta(classificationName, () -> { return "codeOf('" + classificationName + "', '" + code + "')"; }).codeOf(code); }
[ "public", "Classification", "codeOf", "(", "String", "classificationName", ",", "String", "code", ")", "{", "assertArgumentNotNull", "(", "\"elementName\"", ",", "classificationName", ")", ";", "assertArgumentNotNull", "(", "\"code\"", ",", "code", ")", ";", "return", "findClassificationMeta", "(", "classificationName", ",", "(", ")", "->", "{", "return", "\"codeOf('\"", "+", "classificationName", "+", "\"', '\"", "+", "code", "+", "\"')\"", ";", "}", ")", ".", "codeOf", "(", "code", ")", ";", "}" ]
Get classification by code. @param classificationName The name of classification. (NotNull) @param code The code of classification to find. (NotNull) @return The found instance of classification for the code. (NotNull: if not found, throws exception)
[ "Get", "classification", "by", "code", "." ]
d340a6e7eeddfcc9177052958c383fecd4a7fefa
https://github.com/lastaflute/lasta-thymeleaf/blob/d340a6e7eeddfcc9177052958c383fecd4a7fefa/src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java#L211-L217
144,788
lastaflute/lasta-thymeleaf
src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java
ClassificationExpressionObject.nameOf
public Classification nameOf(String classificationName, String name) { return findClassificationMeta((String) classificationName, () -> { return "nameOf('" + classificationName + "', '" + name + "')"; }).nameOf(name); }
java
public Classification nameOf(String classificationName, String name) { return findClassificationMeta((String) classificationName, () -> { return "nameOf('" + classificationName + "', '" + name + "')"; }).nameOf(name); }
[ "public", "Classification", "nameOf", "(", "String", "classificationName", ",", "String", "name", ")", "{", "return", "findClassificationMeta", "(", "(", "String", ")", "classificationName", ",", "(", ")", "->", "{", "return", "\"nameOf('\"", "+", "classificationName", "+", "\"', '\"", "+", "name", "+", "\"')\"", ";", "}", ")", ".", "nameOf", "(", "name", ")", ";", "}" ]
Get classification by name. @param classificationName The name of classification. (NotNull) @param name The name of classification to find. (NotNull) @return The found instance of classification for the code. (NotNull: if not found, throws exception)
[ "Get", "classification", "by", "name", "." ]
d340a6e7eeddfcc9177052958c383fecd4a7fefa
https://github.com/lastaflute/lasta-thymeleaf/blob/d340a6e7eeddfcc9177052958c383fecd4a7fefa/src/main/java/org/lastaflute/thymeleaf/expression/ClassificationExpressionObject.java#L225-L229
144,789
cloudiator/sword
core/src/main/java/de/uniulm/omi/cloudiator/sword/strategy/DefaultGetStrategy.java
DefaultGetStrategy.get
@Nullable @Override public T get(String s) { checkNotNull(s); checkArgument(!s.isEmpty()); for (T t : supplier.get()) { if (t.id().equals(s)) { return t; } } return null; }
java
@Nullable @Override public T get(String s) { checkNotNull(s); checkArgument(!s.isEmpty()); for (T t : supplier.get()) { if (t.id().equals(s)) { return t; } } return null; }
[ "@", "Nullable", "@", "Override", "public", "T", "get", "(", "String", "s", ")", "{", "checkNotNull", "(", "s", ")", ";", "checkArgument", "(", "!", "s", ".", "isEmpty", "(", ")", ")", ";", "for", "(", "T", "t", ":", "supplier", ".", "get", "(", ")", ")", "{", "if", "(", "t", ".", "id", "(", ")", ".", "equals", "(", "s", ")", ")", "{", "return", "t", ";", "}", "}", "return", "null", ";", "}" ]
Searches for the given id in the supplier. @param s the id. @return the found resource or null. @throws NullPointerException if the given id is null. @throws IllegalArgumentException if the given id is empty.
[ "Searches", "for", "the", "given", "id", "in", "the", "supplier", "." ]
b7808ea2776c6d70d439342c403369dfc5bb26bc
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/core/src/main/java/de/uniulm/omi/cloudiator/sword/strategy/DefaultGetStrategy.java#L65-L76
144,790
vatbub/common
updater/src/main/java/com/github/vatbub/common/updater/UpdateChecker.java
UpdateChecker.isUpdateAvailable
public static UpdateInfo isUpdateAvailable(URL repoBaseURL, String mavenGroupID, String mavenArtifactID, String mavenClassifier) { return isUpdateAvailable(repoBaseURL, mavenGroupID, mavenArtifactID, mavenClassifier, "jar"); }
java
public static UpdateInfo isUpdateAvailable(URL repoBaseURL, String mavenGroupID, String mavenArtifactID, String mavenClassifier) { return isUpdateAvailable(repoBaseURL, mavenGroupID, mavenArtifactID, mavenClassifier, "jar"); }
[ "public", "static", "UpdateInfo", "isUpdateAvailable", "(", "URL", "repoBaseURL", ",", "String", "mavenGroupID", ",", "String", "mavenArtifactID", ",", "String", "mavenClassifier", ")", "{", "return", "isUpdateAvailable", "(", "repoBaseURL", ",", "mavenGroupID", ",", "mavenArtifactID", ",", "mavenClassifier", ",", "\"jar\"", ")", ";", "}" ]
Checks if a new release has been published on the website. This does not compare the current app version to the release version on the website, just checks if something happened on the website. This ensures that updates that were ignored by the user do not show up again. Assumes that the artifact has a jar-packaging. @param repoBaseURL The base url of the maven repo to use @param mavenGroupID The maven groupId of the artifact to update @param mavenArtifactID The maven artifactId of the artifact to update @param mavenClassifier The maven classifier of the artifact to update @return {@code true} if a new release is available and the user did not ignore it.
[ "Checks", "if", "a", "new", "release", "has", "been", "published", "on", "the", "website", ".", "This", "does", "not", "compare", "the", "current", "app", "version", "to", "the", "release", "version", "on", "the", "website", "just", "checks", "if", "something", "happened", "on", "the", "website", ".", "This", "ensures", "that", "updates", "that", "were", "ignored", "by", "the", "user", "do", "not", "show", "up", "again", ".", "Assumes", "that", "the", "artifact", "has", "a", "jar", "-", "packaging", "." ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/updater/src/main/java/com/github/vatbub/common/updater/UpdateChecker.java#L104-L107
144,791
vatbub/common
updater/src/main/java/com/github/vatbub/common/updater/UpdateChecker.java
UpdateChecker.isUpdateAvailable
@SuppressWarnings("Duplicates") public static UpdateInfo isUpdateAvailable(URL repoBaseURL, String mavenGroupID, String mavenArtifactID, String mavenClassifier, @SuppressWarnings("SameParameterValue") String packaging) { String savedSetting = updatePrefs.getPreference(latestSeenVersionPrefKey, ""); UpdateInfo res = null; try { FOKLogger.info(UpdateChecker.class.getName(), "Checking for updates..."); res = getLatestUpdateInfo(repoBaseURL, mavenGroupID, mavenArtifactID, mavenClassifier, packaging); Version currentVersion; try { currentVersion = new Version(Common.getInstance().getAppVersion()); } catch (IllegalArgumentException e) { FOKLogger.log(UpdateChecker.class.getName(), Level.SEVERE, FOKLogger.DEFAULT_ERROR_TEXT, e); res.showAlert = false; return res; } Version savedVersion; try { savedVersion = new Version(savedSetting); } catch (IllegalArgumentException e) { // No update was ever ignored by the user so use the current // version as the savedVersion savedVersion = currentVersion; } if (res.toVersion.compareTo(savedVersion) > 0) { // new update found FOKLogger.info(UpdateChecker.class.getName(), "Update available!"); FOKLogger.info(UpdateChecker.class.getName(), "Version after update: " + res.toVersion.toString()); FOKLogger.info(UpdateChecker.class.getName(), "Filesize: " + res.fileSizeInMB + "MB"); res.showAlert = true; } else if (res.toVersion.compareTo(currentVersion) > 0) { // found update that is ignored FOKLogger.info(UpdateChecker.class.getName(), "Update available (Update was ignored by the user)!"); FOKLogger.info(UpdateChecker.class.getName(), "Version after update: " + res.toVersion.toString()); FOKLogger.info(UpdateChecker.class.getName(), "Filesize: " + res.fileSizeInMB + "MB"); } else { FOKLogger.info(UpdateChecker.class.getName(), "No update found."); } } catch (JDOMException | IOException e) { FOKLogger.log(UpdateChecker.class.getName(), Level.SEVERE, FOKLogger.DEFAULT_ERROR_TEXT, e); } return res; }
java
@SuppressWarnings("Duplicates") public static UpdateInfo isUpdateAvailable(URL repoBaseURL, String mavenGroupID, String mavenArtifactID, String mavenClassifier, @SuppressWarnings("SameParameterValue") String packaging) { String savedSetting = updatePrefs.getPreference(latestSeenVersionPrefKey, ""); UpdateInfo res = null; try { FOKLogger.info(UpdateChecker.class.getName(), "Checking for updates..."); res = getLatestUpdateInfo(repoBaseURL, mavenGroupID, mavenArtifactID, mavenClassifier, packaging); Version currentVersion; try { currentVersion = new Version(Common.getInstance().getAppVersion()); } catch (IllegalArgumentException e) { FOKLogger.log(UpdateChecker.class.getName(), Level.SEVERE, FOKLogger.DEFAULT_ERROR_TEXT, e); res.showAlert = false; return res; } Version savedVersion; try { savedVersion = new Version(savedSetting); } catch (IllegalArgumentException e) { // No update was ever ignored by the user so use the current // version as the savedVersion savedVersion = currentVersion; } if (res.toVersion.compareTo(savedVersion) > 0) { // new update found FOKLogger.info(UpdateChecker.class.getName(), "Update available!"); FOKLogger.info(UpdateChecker.class.getName(), "Version after update: " + res.toVersion.toString()); FOKLogger.info(UpdateChecker.class.getName(), "Filesize: " + res.fileSizeInMB + "MB"); res.showAlert = true; } else if (res.toVersion.compareTo(currentVersion) > 0) { // found update that is ignored FOKLogger.info(UpdateChecker.class.getName(), "Update available (Update was ignored by the user)!"); FOKLogger.info(UpdateChecker.class.getName(), "Version after update: " + res.toVersion.toString()); FOKLogger.info(UpdateChecker.class.getName(), "Filesize: " + res.fileSizeInMB + "MB"); } else { FOKLogger.info(UpdateChecker.class.getName(), "No update found."); } } catch (JDOMException | IOException e) { FOKLogger.log(UpdateChecker.class.getName(), Level.SEVERE, FOKLogger.DEFAULT_ERROR_TEXT, e); } return res; }
[ "@", "SuppressWarnings", "(", "\"Duplicates\"", ")", "public", "static", "UpdateInfo", "isUpdateAvailable", "(", "URL", "repoBaseURL", ",", "String", "mavenGroupID", ",", "String", "mavenArtifactID", ",", "String", "mavenClassifier", ",", "@", "SuppressWarnings", "(", "\"SameParameterValue\"", ")", "String", "packaging", ")", "{", "String", "savedSetting", "=", "updatePrefs", ".", "getPreference", "(", "latestSeenVersionPrefKey", ",", "\"\"", ")", ";", "UpdateInfo", "res", "=", "null", ";", "try", "{", "FOKLogger", ".", "info", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "\"Checking for updates...\"", ")", ";", "res", "=", "getLatestUpdateInfo", "(", "repoBaseURL", ",", "mavenGroupID", ",", "mavenArtifactID", ",", "mavenClassifier", ",", "packaging", ")", ";", "Version", "currentVersion", ";", "try", "{", "currentVersion", "=", "new", "Version", "(", "Common", ".", "getInstance", "(", ")", ".", "getAppVersion", "(", ")", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "FOKLogger", ".", "log", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "Level", ".", "SEVERE", ",", "FOKLogger", ".", "DEFAULT_ERROR_TEXT", ",", "e", ")", ";", "res", ".", "showAlert", "=", "false", ";", "return", "res", ";", "}", "Version", "savedVersion", ";", "try", "{", "savedVersion", "=", "new", "Version", "(", "savedSetting", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "// No update was ever ignored by the user so use the current", "// version as the savedVersion", "savedVersion", "=", "currentVersion", ";", "}", "if", "(", "res", ".", "toVersion", ".", "compareTo", "(", "savedVersion", ")", ">", "0", ")", "{", "// new update found", "FOKLogger", ".", "info", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "\"Update available!\"", ")", ";", "FOKLogger", ".", "info", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "\"Version after update: \"", "+", "res", ".", "toVersion", ".", "toString", "(", ")", ")", ";", "FOKLogger", ".", "info", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "\"Filesize: \"", "+", "res", ".", "fileSizeInMB", "+", "\"MB\"", ")", ";", "res", ".", "showAlert", "=", "true", ";", "}", "else", "if", "(", "res", ".", "toVersion", ".", "compareTo", "(", "currentVersion", ")", ">", "0", ")", "{", "// found update that is ignored", "FOKLogger", ".", "info", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "\"Update available (Update was ignored by the user)!\"", ")", ";", "FOKLogger", ".", "info", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "\"Version after update: \"", "+", "res", ".", "toVersion", ".", "toString", "(", ")", ")", ";", "FOKLogger", ".", "info", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "\"Filesize: \"", "+", "res", ".", "fileSizeInMB", "+", "\"MB\"", ")", ";", "}", "else", "{", "FOKLogger", ".", "info", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "\"No update found.\"", ")", ";", "}", "}", "catch", "(", "JDOMException", "|", "IOException", "e", ")", "{", "FOKLogger", ".", "log", "(", "UpdateChecker", ".", "class", ".", "getName", "(", ")", ",", "Level", ".", "SEVERE", ",", "FOKLogger", ".", "DEFAULT_ERROR_TEXT", ",", "e", ")", ";", "}", "return", "res", ";", "}" ]
Checks if a new release has been published on the website. This does not compare the current app version to the release version on the website, just checks if something happened on the website. This ensures that updates that were ignored by the user do not show up again. @param repoBaseURL The base url of the maven repo to use @param mavenGroupID The maven groupId of the artifact to update @param mavenArtifactID The maven artifactId of the artifact to update @param mavenClassifier The maven classifier of the artifact to update @param packaging The packaging type of the artifact to update @return {@code true} if a new release is available and the user did not ignore it. @see Common#getPackaging()
[ "Checks", "if", "a", "new", "release", "has", "been", "published", "on", "the", "website", ".", "This", "does", "not", "compare", "the", "current", "app", "version", "to", "the", "release", "version", "on", "the", "website", "just", "checks", "if", "something", "happened", "on", "the", "website", ".", "This", "ensures", "that", "updates", "that", "were", "ignored", "by", "the", "user", "do", "not", "show", "up", "again", "." ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/updater/src/main/java/com/github/vatbub/common/updater/UpdateChecker.java#L124-L170
144,792
vatbub/common
updater/src/main/java/com/github/vatbub/common/updater/UpdateChecker.java
UpdateChecker.isUpdateAvailableCompareAppVersion
public static UpdateInfo isUpdateAvailableCompareAppVersion(URL repoBaseURL, String mavenGroupID, String mavenArtifactID, String mavenClassifier) { return isUpdateAvailableCompareAppVersion(repoBaseURL, mavenGroupID, mavenArtifactID, mavenClassifier, "jar"); }
java
public static UpdateInfo isUpdateAvailableCompareAppVersion(URL repoBaseURL, String mavenGroupID, String mavenArtifactID, String mavenClassifier) { return isUpdateAvailableCompareAppVersion(repoBaseURL, mavenGroupID, mavenArtifactID, mavenClassifier, "jar"); }
[ "public", "static", "UpdateInfo", "isUpdateAvailableCompareAppVersion", "(", "URL", "repoBaseURL", ",", "String", "mavenGroupID", ",", "String", "mavenArtifactID", ",", "String", "mavenClassifier", ")", "{", "return", "isUpdateAvailableCompareAppVersion", "(", "repoBaseURL", ",", "mavenGroupID", ",", "mavenArtifactID", ",", "mavenClassifier", ",", "\"jar\"", ")", ";", "}" ]
Checks if a new release has been published on the website. This compares the current appVersion to the version available on the website and thus does not take into account if the user ignored that update. Assumes that the artifact has a jar-packaging. @param repoBaseURL The base url of the maven repo to use @param mavenGroupID The maven groupId of the artifact to update @param mavenArtifactID The maven artifactId of the artifact to update @param mavenClassifier The maven classifier of the artifact to update @return {@code true} if a new release is available.
[ "Checks", "if", "a", "new", "release", "has", "been", "published", "on", "the", "website", ".", "This", "compares", "the", "current", "appVersion", "to", "the", "version", "available", "on", "the", "website", "and", "thus", "does", "not", "take", "into", "account", "if", "the", "user", "ignored", "that", "update", ".", "Assumes", "that", "the", "artifact", "has", "a", "jar", "-", "packaging", "." ]
8b9fd2ece0a23d520ce53b66c84cbd094e378443
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/updater/src/main/java/com/github/vatbub/common/updater/UpdateChecker.java#L185-L188
144,793
lastaflute/lasta-thymeleaf
src/main/java/org/lastaflute/thymeleaf/ThymeleafHtmlRenderer.java
ThymeleafHtmlRenderer.checkRegisteredDataUsingReservedWord
protected void checkRegisteredDataUsingReservedWord(ActionRuntime runtime, WebContext context, String varKey) { if (isSuppressRegisteredDataUsingReservedWordCheck()) { return; } if (context.getVariableNames().contains(varKey)) { throwThymeleafRegisteredDataUsingReservedWordException(runtime, context, varKey); } }
java
protected void checkRegisteredDataUsingReservedWord(ActionRuntime runtime, WebContext context, String varKey) { if (isSuppressRegisteredDataUsingReservedWordCheck()) { return; } if (context.getVariableNames().contains(varKey)) { throwThymeleafRegisteredDataUsingReservedWordException(runtime, context, varKey); } }
[ "protected", "void", "checkRegisteredDataUsingReservedWord", "(", "ActionRuntime", "runtime", ",", "WebContext", "context", ",", "String", "varKey", ")", "{", "if", "(", "isSuppressRegisteredDataUsingReservedWordCheck", "(", ")", ")", "{", "return", ";", "}", "if", "(", "context", ".", "getVariableNames", "(", ")", ".", "contains", "(", "varKey", ")", ")", "{", "throwThymeleafRegisteredDataUsingReservedWordException", "(", "runtime", ",", "context", ",", "varKey", ")", ";", "}", "}" ]
Thymeleaf's reserved words are already checked in Thymeleaf process so no check them here
[ "Thymeleaf", "s", "reserved", "words", "are", "already", "checked", "in", "Thymeleaf", "process", "so", "no", "check", "them", "here" ]
d340a6e7eeddfcc9177052958c383fecd4a7fefa
https://github.com/lastaflute/lasta-thymeleaf/blob/d340a6e7eeddfcc9177052958c383fecd4a7fefa/src/main/java/org/lastaflute/thymeleaf/ThymeleafHtmlRenderer.java#L178-L185
144,794
electrumpayments/service-interface-base
src/main/java/io/electrum/vas/model/CardPayment.java
CardPayment.getPan
@ApiModelProperty(required = true, value = "Primary account number that uniquely identifies this card.") @JsonProperty("pan") @NotNull @Pattern(regexp = "[0-9]{1,19}") @Masked public String getPan() { return pan; }
java
@ApiModelProperty(required = true, value = "Primary account number that uniquely identifies this card.") @JsonProperty("pan") @NotNull @Pattern(regexp = "[0-9]{1,19}") @Masked public String getPan() { return pan; }
[ "@", "ApiModelProperty", "(", "required", "=", "true", ",", "value", "=", "\"Primary account number that uniquely identifies this card.\"", ")", "@", "JsonProperty", "(", "\"pan\"", ")", "@", "NotNull", "@", "Pattern", "(", "regexp", "=", "\"[0-9]{1,19}\"", ")", "@", "Masked", "public", "String", "getPan", "(", ")", "{", "return", "pan", ";", "}" ]
Primary account number that uniquely identifies this card. @return pan
[ "Primary", "account", "number", "that", "uniquely", "identifies", "this", "card", "." ]
2b731ab4eecf458e9ec869338c9cf2df2e86f986
https://github.com/electrumpayments/service-interface-base/blob/2b731ab4eecf458e9ec869338c9cf2df2e86f986/src/main/java/io/electrum/vas/model/CardPayment.java#L41-L48
144,795
duracloud/snapshot
snapshot-bridge-webapp/src/main/java/org/duracloud/snapshot/bridge/rest/SnapshotResource.java
SnapshotResource.complete
@Path("{snapshotId}/complete") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response complete(@PathParam("snapshotId") String snapshotId, CompleteSnapshotBridgeParameters params) { try { Snapshot snapshot = this.snapshotRepo.findByName(snapshotId); // parse alternate IDs if provided List<String> alternateIds = params.getAlternateIds(); String altIds = "[]"; if (alternateIds != null && !alternateIds.isEmpty()) { // add alternate IDs to snapshot snapshot = this.snapshotManager.addAlternateSnapshotIds(snapshot, alternateIds); // build alternate IDs for history StringBuilder history = new StringBuilder(); history.append("["); boolean first = true; for (String id : alternateIds) { if (!first) { history.append(","); } history.append("'" + id + "'"); first = false; } history.append("]"); altIds = history.toString(); } // Add history event String history = "[{'" + SNAPSHOT_ACTION_TITLE + "':'" + SNAPSHOT_ACTION_COMPLETED + "'}," + "{'" + SNAPSHOT_ID_TITLE + "':'" + snapshotId + "'}," + "{'" + SNAPSHOT_ALT_IDS_TITLE + "':" + altIds + "}]"; snapshotManager.updateHistory(snapshot, history); snapshot = this.snapshotManager.transferToStorageComplete(snapshotId); log.info("successfully processed snapshot complete notification: {}", snapshot); return Response.ok(null) .entity(new CompleteSnapshotBridgeResult(snapshot.getStatus(), snapshot.getStatusText())) .build(); } catch (AlternateIdAlreadyExistsException ex) { log.warn(ex.getMessage()); return Response.status(HttpStatus.SC_BAD_REQUEST) .entity(new ResponseDetails(ex.getMessage())) .build(); } catch (Exception ex) { log.error(ex.getMessage(), ex); return Response.serverError() .entity(new ResponseDetails(ex.getMessage())) .build(); } }
java
@Path("{snapshotId}/complete") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response complete(@PathParam("snapshotId") String snapshotId, CompleteSnapshotBridgeParameters params) { try { Snapshot snapshot = this.snapshotRepo.findByName(snapshotId); // parse alternate IDs if provided List<String> alternateIds = params.getAlternateIds(); String altIds = "[]"; if (alternateIds != null && !alternateIds.isEmpty()) { // add alternate IDs to snapshot snapshot = this.snapshotManager.addAlternateSnapshotIds(snapshot, alternateIds); // build alternate IDs for history StringBuilder history = new StringBuilder(); history.append("["); boolean first = true; for (String id : alternateIds) { if (!first) { history.append(","); } history.append("'" + id + "'"); first = false; } history.append("]"); altIds = history.toString(); } // Add history event String history = "[{'" + SNAPSHOT_ACTION_TITLE + "':'" + SNAPSHOT_ACTION_COMPLETED + "'}," + "{'" + SNAPSHOT_ID_TITLE + "':'" + snapshotId + "'}," + "{'" + SNAPSHOT_ALT_IDS_TITLE + "':" + altIds + "}]"; snapshotManager.updateHistory(snapshot, history); snapshot = this.snapshotManager.transferToStorageComplete(snapshotId); log.info("successfully processed snapshot complete notification: {}", snapshot); return Response.ok(null) .entity(new CompleteSnapshotBridgeResult(snapshot.getStatus(), snapshot.getStatusText())) .build(); } catch (AlternateIdAlreadyExistsException ex) { log.warn(ex.getMessage()); return Response.status(HttpStatus.SC_BAD_REQUEST) .entity(new ResponseDetails(ex.getMessage())) .build(); } catch (Exception ex) { log.error(ex.getMessage(), ex); return Response.serverError() .entity(new ResponseDetails(ex.getMessage())) .build(); } }
[ "@", "Path", "(", "\"{snapshotId}/complete\"", ")", "@", "POST", "@", "Consumes", "(", "MediaType", ".", "APPLICATION_JSON", ")", "@", "Produces", "(", "MediaType", ".", "APPLICATION_JSON", ")", "public", "Response", "complete", "(", "@", "PathParam", "(", "\"snapshotId\"", ")", "String", "snapshotId", ",", "CompleteSnapshotBridgeParameters", "params", ")", "{", "try", "{", "Snapshot", "snapshot", "=", "this", ".", "snapshotRepo", ".", "findByName", "(", "snapshotId", ")", ";", "// parse alternate IDs if provided", "List", "<", "String", ">", "alternateIds", "=", "params", ".", "getAlternateIds", "(", ")", ";", "String", "altIds", "=", "\"[]\"", ";", "if", "(", "alternateIds", "!=", "null", "&&", "!", "alternateIds", ".", "isEmpty", "(", ")", ")", "{", "// add alternate IDs to snapshot", "snapshot", "=", "this", ".", "snapshotManager", ".", "addAlternateSnapshotIds", "(", "snapshot", ",", "alternateIds", ")", ";", "// build alternate IDs for history", "StringBuilder", "history", "=", "new", "StringBuilder", "(", ")", ";", "history", ".", "append", "(", "\"[\"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "String", "id", ":", "alternateIds", ")", "{", "if", "(", "!", "first", ")", "{", "history", ".", "append", "(", "\",\"", ")", ";", "}", "history", ".", "append", "(", "\"'\"", "+", "id", "+", "\"'\"", ")", ";", "first", "=", "false", ";", "}", "history", ".", "append", "(", "\"]\"", ")", ";", "altIds", "=", "history", ".", "toString", "(", ")", ";", "}", "// Add history event", "String", "history", "=", "\"[{'\"", "+", "SNAPSHOT_ACTION_TITLE", "+", "\"':'\"", "+", "SNAPSHOT_ACTION_COMPLETED", "+", "\"'},\"", "+", "\"{'\"", "+", "SNAPSHOT_ID_TITLE", "+", "\"':'\"", "+", "snapshotId", "+", "\"'},\"", "+", "\"{'\"", "+", "SNAPSHOT_ALT_IDS_TITLE", "+", "\"':\"", "+", "altIds", "+", "\"}]\"", ";", "snapshotManager", ".", "updateHistory", "(", "snapshot", ",", "history", ")", ";", "snapshot", "=", "this", ".", "snapshotManager", ".", "transferToStorageComplete", "(", "snapshotId", ")", ";", "log", ".", "info", "(", "\"successfully processed snapshot complete notification: {}\"", ",", "snapshot", ")", ";", "return", "Response", ".", "ok", "(", "null", ")", ".", "entity", "(", "new", "CompleteSnapshotBridgeResult", "(", "snapshot", ".", "getStatus", "(", ")", ",", "snapshot", ".", "getStatusText", "(", ")", ")", ")", ".", "build", "(", ")", ";", "}", "catch", "(", "AlternateIdAlreadyExistsException", "ex", ")", "{", "log", ".", "warn", "(", "ex", ".", "getMessage", "(", ")", ")", ";", "return", "Response", ".", "status", "(", "HttpStatus", ".", "SC_BAD_REQUEST", ")", ".", "entity", "(", "new", "ResponseDetails", "(", "ex", ".", "getMessage", "(", ")", ")", ")", ".", "build", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "return", "Response", ".", "serverError", "(", ")", ".", "entity", "(", "new", "ResponseDetails", "(", "ex", ".", "getMessage", "(", ")", ")", ")", ".", "build", "(", ")", ";", "}", "}" ]
Notifies the bridge that the snapshot transfer from the bridge storage to the preservation storage is complete. Also sets a snapshot's alternate id's if they are passed in. @param snapshotId @param params @return
[ "Notifies", "the", "bridge", "that", "the", "snapshot", "transfer", "from", "the", "bridge", "storage", "to", "the", "preservation", "storage", "is", "complete", ".", "Also", "sets", "a", "snapshot", "s", "alternate", "id", "s", "if", "they", "are", "passed", "in", "." ]
7cb387b22fd4a9425087f654276138727c2c0b73
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-bridge-webapp/src/main/java/org/duracloud/snapshot/bridge/rest/SnapshotResource.java#L440-L497
144,796
duracloud/snapshot
snapshot-bridge-webapp/src/main/java/org/duracloud/snapshot/bridge/rest/SnapshotResource.java
SnapshotResource.error
@Path("{snapshotId}/error") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response error(@PathParam("snapshotId") String snapshotId, SnapshotErrorBridgeParameters params) { try { Snapshot snapshot = snapshotManager.transferError(snapshotId, params.getError()); log.info("Processed snapshot error notification: {}", snapshot); return Response.ok(new SnapshotErrorBridgeResult(snapshot.getStatus(), snapshot.getStatusText())) .build(); } catch (Exception ex) { log.error(ex.getMessage(), ex); return Response.serverError() .entity(new ResponseDetails(ex.getMessage())) .build(); } }
java
@Path("{snapshotId}/error") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response error(@PathParam("snapshotId") String snapshotId, SnapshotErrorBridgeParameters params) { try { Snapshot snapshot = snapshotManager.transferError(snapshotId, params.getError()); log.info("Processed snapshot error notification: {}", snapshot); return Response.ok(new SnapshotErrorBridgeResult(snapshot.getStatus(), snapshot.getStatusText())) .build(); } catch (Exception ex) { log.error(ex.getMessage(), ex); return Response.serverError() .entity(new ResponseDetails(ex.getMessage())) .build(); } }
[ "@", "Path", "(", "\"{snapshotId}/error\"", ")", "@", "POST", "@", "Consumes", "(", "MediaType", ".", "APPLICATION_JSON", ")", "@", "Produces", "(", "MediaType", ".", "APPLICATION_JSON", ")", "public", "Response", "error", "(", "@", "PathParam", "(", "\"snapshotId\"", ")", "String", "snapshotId", ",", "SnapshotErrorBridgeParameters", "params", ")", "{", "try", "{", "Snapshot", "snapshot", "=", "snapshotManager", ".", "transferError", "(", "snapshotId", ",", "params", ".", "getError", "(", ")", ")", ";", "log", ".", "info", "(", "\"Processed snapshot error notification: {}\"", ",", "snapshot", ")", ";", "return", "Response", ".", "ok", "(", "new", "SnapshotErrorBridgeResult", "(", "snapshot", ".", "getStatus", "(", ")", ",", "snapshot", ".", "getStatusText", "(", ")", ")", ")", ".", "build", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "return", "Response", ".", "serverError", "(", ")", ".", "entity", "(", "new", "ResponseDetails", "(", "ex", ".", "getMessage", "(", ")", ")", ")", ".", "build", "(", ")", ";", "}", "}" ]
Notifies the bridge that the snapshot process is not able to continue due to an error which cannot be resolved by the system processing the snapshot data. @param snapshotId @param params @return
[ "Notifies", "the", "bridge", "that", "the", "snapshot", "process", "is", "not", "able", "to", "continue", "due", "to", "an", "error", "which", "cannot", "be", "resolved", "by", "the", "system", "processing", "the", "snapshot", "data", "." ]
7cb387b22fd4a9425087f654276138727c2c0b73
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-bridge-webapp/src/main/java/org/duracloud/snapshot/bridge/rest/SnapshotResource.java#L508-L528
144,797
duracloud/snapshot
snapshot-bridge-webapp/src/main/java/org/duracloud/snapshot/bridge/rest/SnapshotResource.java
SnapshotResource.updateHistory
@Path("{snapshotId}/history") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateHistory(@PathParam("snapshotId") String snapshotId, UpdateSnapshotHistoryBridgeParameters params) { try { if (params.getAlternate() == null) { return Response.serverError() .entity(new ResponseDetails("Incorrect parameters submitted!")) .build(); } Snapshot snapshot = (params.getAlternate() ? this.snapshotRepo.findBySnapshotAlternateIds(snapshotId) : this.snapshotRepo.findByName(snapshotId)); // sanity check to make sure snapshot exists if (snapshot != null) { // sanity check input from history if (params.getHistory() != null && params.getHistory().length() > 0) { // set history, and refresh our variable from the DB snapshot = this.snapshotManager.updateHistory(snapshot, params.getHistory()); log.info("successfully processed snapshot " + "history update: {}", snapshot); } else { log.info("did not process empty or null snapshot " + "history update: {}", snapshot); } SnapshotSummary snapSummary = createSnapshotSummary(snapshot); List<SnapshotHistory> snapMeta = snapshot.getSnapshotHistory(); String history = // retrieve latest history update ((snapMeta != null && snapMeta.size() > 0) ? snapMeta.get(snapMeta.size() - 1).getHistory() : ""); UpdateSnapshotHistoryBridgeResult result = new UpdateSnapshotHistoryBridgeResult(snapSummary, history); log.debug("Returning results of update snapshot history: {}", result); return Response.ok(null) .entity(result) .build(); } else { String error = "Snapshot with " + (params.getAlternate() ? "alternate " : "") + "id [" + snapshotId + "] not found!"; return Response.serverError() .entity(new ResponseDetails(error)) .build(); } } catch (Exception ex) { log.error(ex.getMessage(), ex); return Response.serverError() .entity(new ResponseDetails(ex.getMessage())) .build(); } }
java
@Path("{snapshotId}/history") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateHistory(@PathParam("snapshotId") String snapshotId, UpdateSnapshotHistoryBridgeParameters params) { try { if (params.getAlternate() == null) { return Response.serverError() .entity(new ResponseDetails("Incorrect parameters submitted!")) .build(); } Snapshot snapshot = (params.getAlternate() ? this.snapshotRepo.findBySnapshotAlternateIds(snapshotId) : this.snapshotRepo.findByName(snapshotId)); // sanity check to make sure snapshot exists if (snapshot != null) { // sanity check input from history if (params.getHistory() != null && params.getHistory().length() > 0) { // set history, and refresh our variable from the DB snapshot = this.snapshotManager.updateHistory(snapshot, params.getHistory()); log.info("successfully processed snapshot " + "history update: {}", snapshot); } else { log.info("did not process empty or null snapshot " + "history update: {}", snapshot); } SnapshotSummary snapSummary = createSnapshotSummary(snapshot); List<SnapshotHistory> snapMeta = snapshot.getSnapshotHistory(); String history = // retrieve latest history update ((snapMeta != null && snapMeta.size() > 0) ? snapMeta.get(snapMeta.size() - 1).getHistory() : ""); UpdateSnapshotHistoryBridgeResult result = new UpdateSnapshotHistoryBridgeResult(snapSummary, history); log.debug("Returning results of update snapshot history: {}", result); return Response.ok(null) .entity(result) .build(); } else { String error = "Snapshot with " + (params.getAlternate() ? "alternate " : "") + "id [" + snapshotId + "] not found!"; return Response.serverError() .entity(new ResponseDetails(error)) .build(); } } catch (Exception ex) { log.error(ex.getMessage(), ex); return Response.serverError() .entity(new ResponseDetails(ex.getMessage())) .build(); } }
[ "@", "Path", "(", "\"{snapshotId}/history\"", ")", "@", "POST", "@", "Consumes", "(", "MediaType", ".", "APPLICATION_JSON", ")", "@", "Produces", "(", "MediaType", ".", "APPLICATION_JSON", ")", "public", "Response", "updateHistory", "(", "@", "PathParam", "(", "\"snapshotId\"", ")", "String", "snapshotId", ",", "UpdateSnapshotHistoryBridgeParameters", "params", ")", "{", "try", "{", "if", "(", "params", ".", "getAlternate", "(", ")", "==", "null", ")", "{", "return", "Response", ".", "serverError", "(", ")", ".", "entity", "(", "new", "ResponseDetails", "(", "\"Incorrect parameters submitted!\"", ")", ")", ".", "build", "(", ")", ";", "}", "Snapshot", "snapshot", "=", "(", "params", ".", "getAlternate", "(", ")", "?", "this", ".", "snapshotRepo", ".", "findBySnapshotAlternateIds", "(", "snapshotId", ")", ":", "this", ".", "snapshotRepo", ".", "findByName", "(", "snapshotId", ")", ")", ";", "// sanity check to make sure snapshot exists", "if", "(", "snapshot", "!=", "null", ")", "{", "// sanity check input from history", "if", "(", "params", ".", "getHistory", "(", ")", "!=", "null", "&&", "params", ".", "getHistory", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "// set history, and refresh our variable from the DB", "snapshot", "=", "this", ".", "snapshotManager", ".", "updateHistory", "(", "snapshot", ",", "params", ".", "getHistory", "(", ")", ")", ";", "log", ".", "info", "(", "\"successfully processed snapshot \"", "+", "\"history update: {}\"", ",", "snapshot", ")", ";", "}", "else", "{", "log", ".", "info", "(", "\"did not process empty or null snapshot \"", "+", "\"history update: {}\"", ",", "snapshot", ")", ";", "}", "SnapshotSummary", "snapSummary", "=", "createSnapshotSummary", "(", "snapshot", ")", ";", "List", "<", "SnapshotHistory", ">", "snapMeta", "=", "snapshot", ".", "getSnapshotHistory", "(", ")", ";", "String", "history", "=", "// retrieve latest history update", "(", "(", "snapMeta", "!=", "null", "&&", "snapMeta", ".", "size", "(", ")", ">", "0", ")", "?", "snapMeta", ".", "get", "(", "snapMeta", ".", "size", "(", ")", "-", "1", ")", ".", "getHistory", "(", ")", ":", "\"\"", ")", ";", "UpdateSnapshotHistoryBridgeResult", "result", "=", "new", "UpdateSnapshotHistoryBridgeResult", "(", "snapSummary", ",", "history", ")", ";", "log", ".", "debug", "(", "\"Returning results of update snapshot history: {}\"", ",", "result", ")", ";", "return", "Response", ".", "ok", "(", "null", ")", ".", "entity", "(", "result", ")", ".", "build", "(", ")", ";", "}", "else", "{", "String", "error", "=", "\"Snapshot with \"", "+", "(", "params", ".", "getAlternate", "(", ")", "?", "\"alternate \"", ":", "\"\"", ")", "+", "\"id [\"", "+", "snapshotId", "+", "\"] not found!\"", ";", "return", "Response", ".", "serverError", "(", ")", ".", "entity", "(", "new", "ResponseDetails", "(", "error", ")", ")", ".", "build", "(", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "return", "Response", ".", "serverError", "(", ")", ".", "entity", "(", "new", "ResponseDetails", "(", "ex", ".", "getMessage", "(", ")", ")", ")", ".", "build", "(", ")", ";", "}", "}" ]
Updates a snapshot's history @param snapshotId - a snapshot's ID or it's alternate ID @param params - JSON object that contains the history String and a Boolean of whether this request is using a snapshot's ID or an alternate ID @return
[ "Updates", "a", "snapshot", "s", "history" ]
7cb387b22fd4a9425087f654276138727c2c0b73
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-bridge-webapp/src/main/java/org/duracloud/snapshot/bridge/rest/SnapshotResource.java#L653-L709
144,798
duracloud/snapshot
snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/SpaceItemWriter.java
SpaceItemWriter.onWriteError
@Override public void onWriteError(Exception e, List<? extends ContentItem> items) { StringBuilder sb = new StringBuilder(); for (ContentItem item : items) { sb.append(item.getContentId() + ", "); } String message = "Error writing item(s): " + e.getMessage() + ": items=" + sb.toString(); this.errors.add(message); log.error(message, e); }
java
@Override public void onWriteError(Exception e, List<? extends ContentItem> items) { StringBuilder sb = new StringBuilder(); for (ContentItem item : items) { sb.append(item.getContentId() + ", "); } String message = "Error writing item(s): " + e.getMessage() + ": items=" + sb.toString(); this.errors.add(message); log.error(message, e); }
[ "@", "Override", "public", "void", "onWriteError", "(", "Exception", "e", ",", "List", "<", "?", "extends", "ContentItem", ">", "items", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "ContentItem", "item", ":", "items", ")", "{", "sb", ".", "append", "(", "item", ".", "getContentId", "(", ")", "+", "\", \"", ")", ";", "}", "String", "message", "=", "\"Error writing item(s): \"", "+", "e", ".", "getMessage", "(", ")", "+", "\": items=\"", "+", "sb", ".", "toString", "(", ")", ";", "this", ".", "errors", ".", "add", "(", "message", ")", ";", "log", ".", "error", "(", "message", ",", "e", ")", ";", "}" ]
Method defined in ItemWriteListener interface
[ "Method", "defined", "in", "ItemWriteListener", "interface" ]
7cb387b22fd4a9425087f654276138727c2c0b73
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/SpaceItemWriter.java#L532-L542
144,799
duracloud/snapshot
snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/RestoreJobExecutionListener.java
RestoreJobExecutionListener.changeRestoreStatus
private Date changeRestoreStatus(Restoration restoration, RestoreStatus status, String msg, Date currentDate) { log.info("Changing restore status to: " + status + " with message: " + msg); restoration.setStatus(status); restoration.setStatusText(msg); Date expirationDate = getExpirationDate(currentDate, daysToExpire); if (status.equals(RestoreStatus.RESTORATION_COMPLETE)) { restoration.setEndDate(currentDate); restoration.setExpirationDate(expirationDate); } restoreRepo.save(restoration); eventLog.logRestoreUpdate(restoration); return expirationDate; }
java
private Date changeRestoreStatus(Restoration restoration, RestoreStatus status, String msg, Date currentDate) { log.info("Changing restore status to: " + status + " with message: " + msg); restoration.setStatus(status); restoration.setStatusText(msg); Date expirationDate = getExpirationDate(currentDate, daysToExpire); if (status.equals(RestoreStatus.RESTORATION_COMPLETE)) { restoration.setEndDate(currentDate); restoration.setExpirationDate(expirationDate); } restoreRepo.save(restoration); eventLog.logRestoreUpdate(restoration); return expirationDate; }
[ "private", "Date", "changeRestoreStatus", "(", "Restoration", "restoration", ",", "RestoreStatus", "status", ",", "String", "msg", ",", "Date", "currentDate", ")", "{", "log", ".", "info", "(", "\"Changing restore status to: \"", "+", "status", "+", "\" with message: \"", "+", "msg", ")", ";", "restoration", ".", "setStatus", "(", "status", ")", ";", "restoration", ".", "setStatusText", "(", "msg", ")", ";", "Date", "expirationDate", "=", "getExpirationDate", "(", "currentDate", ",", "daysToExpire", ")", ";", "if", "(", "status", ".", "equals", "(", "RestoreStatus", ".", "RESTORATION_COMPLETE", ")", ")", "{", "restoration", ".", "setEndDate", "(", "currentDate", ")", ";", "restoration", ".", "setExpirationDate", "(", "expirationDate", ")", ";", "}", "restoreRepo", ".", "save", "(", "restoration", ")", ";", "eventLog", ".", "logRestoreUpdate", "(", "restoration", ")", ";", "return", "expirationDate", ";", "}" ]
Updates the restore details in the database @param restoration the restoration being worked @param status the new status of the restoration @param msg status text
[ "Updates", "the", "restore", "details", "in", "the", "database" ]
7cb387b22fd4a9425087f654276138727c2c0b73
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/RestoreJobExecutionListener.java#L237-L253