idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
27,500 | public boolean performItemClick ( View view , int position , long id ) { if ( mOnItemClickListener != null ) { playSoundEffect ( SoundEffectConstants . CLICK ) ; if ( view != null ) { view . sendAccessibilityEvent ( AccessibilityEvent . TYPE_VIEW_CLICKED ) ; } mOnItemClickListener . onItemClick ( null , view , position... | Call the OnItemClickListener if it is defined . |
27,501 | public int getPositionForView ( View view ) { View listItem = view ; try { View v ; while ( ! ( v = ( View ) listItem . getParent ( ) ) . equals ( this ) ) { listItem = v ; } } catch ( ClassCastException e ) { return INVALID_POSITION ; } final int childCount = getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++... | Get the position within the adapter s data set for the view where view is a an adapter item or a descendant of an adapter item . |
27,502 | public Object getItemAtPosition ( int position ) { T adapter = getAdapter ( ) ; return ( adapter == null || position < 0 ) ? null : adapter . getItem ( position ) ; } | Gets the data associated with the specified position in the list . |
27,503 | public static int loadLogoFromManifest ( Activity activity ) { int logo = 0 ; try { final String thisPackage = activity . getClass ( ) . getName ( ) ; if ( ActionBarSherlock . DEBUG ) Log . i ( TAG , "Parsing AndroidManifest.xml for " + thisPackage ) ; final String packageName = activity . getApplicationInfo ( ) . pack... | Attempt to programmatically load the logo from the manifest file of an activity by using an XML pull parser . This should allow us to read the logo attribute regardless of the platform it is being run on . |
27,504 | private void setActivityChooserPolicyIfNeeded ( ) { if ( mOnShareTargetSelectedListener == null ) { return ; } if ( mOnChooseActivityListener == null ) { mOnChooseActivityListener = new ShareAcitivityChooserModelPolicy ( ) ; } ActivityChooserModel dataModel = ActivityChooserModel . get ( mContext , mShareHistoryFileNam... | Set the activity chooser policy of the model backed by the current share history file if needed which is if there is a registered callback . |
27,505 | private void sortActivities ( ) { synchronized ( mInstanceLock ) { if ( mActivitySorter != null && ! mActivites . isEmpty ( ) ) { mActivitySorter . sort ( mIntent , mActivites , Collections . unmodifiableList ( mHistoricalRecords ) ) ; notifyChanged ( ) ; } } } | Sorts the activities based on history and an intent . If a sorter is not specified this a default implementation is used . |
27,506 | private void loadActivitiesLocked ( ) { mActivites . clear ( ) ; if ( mIntent != null ) { List < ResolveInfo > resolveInfos = mContext . getPackageManager ( ) . queryIntentActivities ( mIntent , 0 ) ; final int resolveInfoCount = resolveInfos . size ( ) ; for ( int i = 0 ; i < resolveInfoCount ; i ++ ) { ResolveInfo re... | Loads the activities . |
27,507 | public boolean onKeyDown ( int keyCode , KeyEvent event ) { if ( mSearchable == null ) { return false ; } return super . onKeyDown ( keyCode , event ) ; } | Handles the key down event for dealing with action keys . |
27,508 | private boolean onSuggestionsKey ( View v , int keyCode , KeyEvent event ) { if ( mSearchable == null ) { return false ; } if ( mSuggestionsAdapter == null ) { return false ; } if ( event . getAction ( ) == KeyEvent . ACTION_DOWN && KeyEventCompat . hasNoModifiers ( event ) ) { if ( keyCode == KeyEvent . KEYCODE_ENTER ... | React to the user typing while in the suggestions list . First check for action keys . If not handled try refocusing regular characters into the EditText . |
27,509 | private void updateVoiceButton ( boolean empty ) { int visibility = GONE ; if ( mVoiceButtonEnabled && ! isIconified ( ) && empty ) { visibility = VISIBLE ; mSubmitButton . setVisibility ( GONE ) ; } mVoiceButton . setVisibility ( visibility ) ; } | Update the visibility of the voice button . There are actually two voice search modes either of which will activate the button . |
27,510 | private void rewriteQueryFromSuggestion ( int position ) { CharSequence oldQuery = mQueryTextView . getText ( ) ; Cursor c = mSuggestionsAdapter . getCursor ( ) ; if ( c == null ) { return ; } if ( c . moveToPosition ( position ) ) { CharSequence newQuery = mSuggestionsAdapter . convertToString ( c ) ; if ( newQuery !=... | Query rewriting . |
27,511 | private boolean launchSuggestion ( int position , int actionKey , String actionMsg ) { Cursor c = mSuggestionsAdapter . getCursor ( ) ; if ( ( c != null ) && c . moveToPosition ( position ) ) { Intent intent = createIntentFromSuggestion ( c , actionKey , actionMsg ) ; launchIntent ( intent ) ; return true ; } return fa... | Launches an intent based on a suggestion . |
27,512 | private void launchIntent ( Intent intent ) { if ( intent == null ) { return ; } try { getContext ( ) . startActivity ( intent ) ; } catch ( RuntimeException ex ) { Log . e ( LOG_TAG , "Failed launch activity: " + intent , ex ) ; } } | Launches an intent including any special intent handling . |
27,513 | private Intent createIntent ( String action , Uri data , String extraData , String query , int actionKey , String actionMsg ) { Intent intent = new Intent ( action ) ; intent . addFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ) ; if ( data != null ) { intent . setData ( data ) ; } intent . putExtra ( SearchManager . USER_QUE... | Constructs an intent from the given information and the search dialog state . |
27,514 | private Intent createVoiceWebSearchIntent ( Intent baseIntent , SearchableInfo searchable ) { Intent voiceIntent = new Intent ( baseIntent ) ; ComponentName searchActivity = searchable . getSearchActivity ( ) ; voiceIntent . putExtra ( RecognizerIntent . EXTRA_CALLING_PACKAGE , searchActivity == null ? null : searchAct... | Create and return an Intent that can launch the voice search activity for web search . |
27,515 | private Intent createVoiceAppSearchIntent ( Intent baseIntent , SearchableInfo searchable ) { ComponentName searchActivity = searchable . getSearchActivity ( ) ; Intent queryIntent = new Intent ( Intent . ACTION_SEARCH ) ; queryIntent . setComponent ( searchActivity ) ; PendingIntent pending = PendingIntent . getActivi... | Create and return an Intent that can launch the voice search activity perform a specific voice transcription and forward the results to the searchable activity . |
27,516 | void updateFragmentVisibility ( ) { FragmentTransaction ft = getSupportFragmentManager ( ) . beginTransaction ( ) ; if ( mCheckBox1 . isChecked ( ) ) ft . show ( mFragment1 ) ; else ft . hide ( mFragment1 ) ; if ( mCheckBox2 . isChecked ( ) ) ft . show ( mFragment2 ) ; else ft . hide ( mFragment2 ) ; ft . commit ( ) ; ... | Update fragment visibility based on current check box state . |
27,517 | private Drawable tileifyIndeterminate ( Drawable drawable ) { if ( drawable instanceof AnimationDrawable ) { AnimationDrawable background = ( AnimationDrawable ) drawable ; final int N = background . getNumberOfFrames ( ) ; AnimationDrawable newBg = new AnimationDrawable ( ) ; newBg . setOneShot ( background . isOneSho... | Convert a AnimationDrawable for use as a barberpole animation . Each frame of the animation is wrapped in a ClipDrawable and given a tiling BitmapShader . |
27,518 | public void setGravity ( int gravity ) { if ( mGravity != gravity ) { if ( ( gravity & Gravity . HORIZONTAL_GRAVITY_MASK ) == 0 ) { gravity |= Gravity . LEFT ; } mGravity = gravity ; requestLayout ( ) ; } } | Describes how the selected item view is positioned . Currently only the horizontal component is used . The default is determined by the current theme . |
27,519 | private void setUpChild ( View child ) { ViewGroup . LayoutParams lp = child . getLayoutParams ( ) ; if ( lp == null ) { lp = generateDefaultLayoutParams ( ) ; } addViewInLayout ( child , 0 , lp ) ; child . setSelected ( hasFocus ( ) ) ; if ( mDisableChildrenWhenDisabled ) { child . setEnabled ( isEnabled ( ) ) ; } int... | Helper for makeAndAddView to set the position of a view and fill out its layout paramters . |
27,520 | static int measureChildForCells ( View child , int cellSize , int cellsRemaining , int parentHeightMeasureSpec , int parentHeightPadding ) { final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; final int childHeightSize = MeasureSpec . getSize ( parentHeightMeasureSpec ) - parentHeightPadding ; final ... | Measure a child view to fit within cell - based formatting . The child s width will be measured to a whole multiple of cellSize . |
27,521 | public void setValues ( PropertyValuesHolder ... values ) { int numValues = values . length ; mValues = values ; mValuesMap = new HashMap < String , PropertyValuesHolder > ( numValues ) ; for ( int i = 0 ; i < numValues ; ++ i ) { PropertyValuesHolder valuesHolder = values [ i ] ; mValuesMap . put ( valuesHolder . getP... | Sets the values per property being animated between . This function is called internally by the constructors of ValueAnimator that take a list of values . But an ValueAnimator can be constructed without values and this method can be called to set the values manually instead . |
27,522 | private void setupValue ( Object target , Keyframe kf ) { try { if ( mGetter == null ) { Class targetClass = target . getClass ( ) ; setupGetter ( targetClass ) ; } kf . setValue ( mGetter . invoke ( target ) ) ; } catch ( InvocationTargetException e ) { Log . e ( "PropertyValuesHolder" , e . toString ( ) ) ; } catch (... | Utility function to set the value stored in a particular Keyframe . The value used is whatever the value is for the property name specified in the keyframe on the target object . |
27,523 | void setAnimatedValue ( Object target ) { if ( mSetter != null ) { try { mTmpValueArray [ 0 ] = getAnimatedValue ( ) ; mSetter . invoke ( target , mTmpValueArray ) ; } catch ( InvocationTargetException e ) { Log . e ( "PropertyValuesHolder" , e . toString ( ) ) ; } catch ( IllegalAccessException e ) { Log . e ( "Proper... | Internal function to set the value on the target object using the setter set up earlier on this PropertyValuesHolder object . This function is called by ObjectAnimator to handle turning the value calculated by ValueAnimator into a value set on the object according to the name of the property . |
27,524 | public void removeMenuPresenter ( MenuPresenter presenter ) { for ( WeakReference < MenuPresenter > ref : mPresenters ) { final MenuPresenter item = ref . get ( ) ; if ( item == null || item == presenter ) { mPresenters . remove ( ref ) ; } } } | Remove a presenter from this menu . That presenter will no longer receive notifications of updates to this menu s data . |
27,525 | final void close ( boolean allMenusAreClosing ) { if ( mIsClosing ) return ; mIsClosing = true ; for ( WeakReference < MenuPresenter > ref : mPresenters ) { final MenuPresenter presenter = ref . get ( ) ; if ( presenter == null ) { mPresenters . remove ( ref ) ; } else { presenter . onCloseMenu ( this , allMenusAreClos... | Closes the visible menu . |
27,526 | void onItemsChanged ( boolean structureChanged ) { if ( ! mPreventDispatchingItemsChanged ) { if ( structureChanged ) { mIsVisibleItemsStale = true ; mIsActionItemsStale = true ; } dispatchPresenterUpdate ( structureChanged ) ; } else { mItemsChangedWhileDispatchPrevented = true ; } } | Called when an item is added or removed . |
27,527 | public static void registerImplementation ( Class < ? extends ActionBarSherlock > implementationClass ) { if ( ! implementationClass . isAnnotationPresent ( Implementation . class ) ) { throw new IllegalArgumentException ( "Class " + implementationClass . getSimpleName ( ) + " is not annotated with @Implementation" ) ;... | Register an ActionBarSherlock implementation . |
27,528 | protected final boolean callbackCreateOptionsMenu ( Menu menu ) { if ( DEBUG ) Log . d ( TAG , "[callbackCreateOptionsMenu] menu: " + menu ) ; boolean result = true ; if ( mActivity instanceof OnCreatePanelMenuListener ) { OnCreatePanelMenuListener listener = ( OnCreatePanelMenuListener ) mActivity ; result = listener ... | Internal method to trigger the menu creation process . |
27,529 | protected final boolean callbackPrepareOptionsMenu ( Menu menu ) { if ( DEBUG ) Log . d ( TAG , "[callbackPrepareOptionsMenu] menu: " + menu ) ; boolean result = true ; if ( mActivity instanceof OnPreparePanelListener ) { OnPreparePanelListener listener = ( OnPreparePanelListener ) mActivity ; result = listener . onPre... | Internal method to trigger the menu preparation process . |
27,530 | protected final boolean callbackOptionsItemSelected ( MenuItem item ) { if ( DEBUG ) Log . d ( TAG , "[callbackOptionsItemSelected] item: " + item . getTitleCondensed ( ) ) ; boolean result = false ; if ( mActivity instanceof OnMenuItemSelectedListener ) { OnMenuItemSelectedListener listener = ( OnMenuItemSelectedListe... | Internal method for dispatching options menu selection to the owning activity callback . |
27,531 | public void setContentView ( View view ) { if ( DEBUG ) Log . d ( TAG , "[setContentView] view: " + view ) ; setContentView ( view , new ViewGroup . LayoutParams ( MATCH_PARENT , MATCH_PARENT ) ) ; } | Set the content of the activity inside the action bar . |
27,532 | public void setTitle ( int resId ) { if ( DEBUG ) Log . d ( TAG , "[setTitle] resId: " + resId ) ; setTitle ( mActivity . getString ( resId ) ) ; } | Change the title associated with this activity . |
27,533 | public MenuInflater getMenuInflater ( ) { if ( DEBUG ) Log . d ( TAG , "[getMenuInflater]" ) ; if ( mMenuInflater == null ) { if ( getActionBar ( ) != null ) { mMenuInflater = new MenuInflater ( getThemedContext ( ) , mActivity ) ; } else { mMenuInflater = new MenuInflater ( mActivity ) ; } } return mMenuInflater ; } | Get a menu inflater instance which supports the newer menu attributes . |
27,534 | public void setAdapter ( SpinnerAdapter adapter ) { if ( null != mAdapter ) { mAdapter . unregisterDataSetObserver ( mDataSetObserver ) ; resetList ( ) ; } mAdapter = adapter ; mOldSelectedPosition = INVALID_POSITION ; mOldSelectedRowId = INVALID_ROW_ID ; if ( mAdapter != null ) { mOldItemCount = mItemCount ; mItemCoun... | The Adapter is used to provide the data which backs this Spinner . It also provides methods to transform spinner items based on their position relative to the selected item . |
27,535 | void resetList ( ) { mDataChanged = false ; mNeedSync = false ; removeAllViewsInLayout ( ) ; mOldSelectedPosition = INVALID_POSITION ; mOldSelectedRowId = INVALID_ROW_ID ; setSelectedPositionInt ( INVALID_POSITION ) ; setNextSelectedPositionInt ( INVALID_POSITION ) ; invalidate ( ) ; } | Clear out all children from the list |
27,536 | public void setSelection ( int position , boolean animate ) { boolean shouldAnimate = animate && mFirstPosition <= position && position <= mFirstPosition + getChildCount ( ) - 1 ; setSelectionInt ( position , shouldAnimate ) ; } | Jump directly to a specific item in the adapter data . |
27,537 | void setSelectionInt ( int position , boolean animate ) { if ( position != mOldSelectedPosition ) { mBlockLayoutRequests = true ; int delta = position - mSelectedPosition ; setNextSelectedPositionInt ( position ) ; layout ( delta , animate ) ; mBlockLayoutRequests = false ; } } | Makes the item at the supplied position selected . |
27,538 | public int pointToPosition ( int x , int y ) { Rect frame = mTouchFrame ; if ( frame == null ) { mTouchFrame = new Rect ( ) ; frame = mTouchFrame ; } final int count = getChildCount ( ) ; for ( int i = count - 1 ; i >= 0 ; i -- ) { View child = getChildAt ( i ) ; if ( child . getVisibility ( ) == View . VISIBLE ) { chi... | Maps a point to a position in the list . |
27,539 | public void setDividerDrawable ( Drawable divider ) { if ( divider == mDivider ) { return ; } if ( divider instanceof ColorDrawable && Build . VERSION . SDK_INT < Build . VERSION_CODES . HONEYCOMB ) { divider = new IcsColorDrawable ( ( ColorDrawable ) divider ) ; } mDivider = divider ; if ( divider != null ) { mDivider... | Set a drawable to be used as a divider between items . |
27,540 | protected boolean hasDividerBeforeChildAt ( int childIndex ) { if ( childIndex == 0 ) { return ( mShowDividers & SHOW_DIVIDER_BEGINNING ) != 0 ; } else if ( childIndex == getChildCount ( ) ) { return ( mShowDividers & SHOW_DIVIDER_END ) != 0 ; } else if ( ( mShowDividers & SHOW_DIVIDER_MIDDLE ) != 0 ) { boolean hasVisi... | Determines where to position dividers between children . |
27,541 | private void showPopupUnchecked ( int maxActivityCount ) { if ( mAdapter . getDataModel ( ) == null ) { throw new IllegalStateException ( "No data model. Did you call #setDataModel?" ) ; } getViewTreeObserver ( ) . addOnGlobalLayoutListener ( mOnGlobalLayoutListener ) ; final boolean defaultActivityButtonShown = mDefau... | Shows the popup no matter if it was already showing . |
27,542 | public boolean dismissPopup ( ) { if ( isShowingPopup ( ) ) { getListPopupWindow ( ) . dismiss ( ) ; ViewTreeObserver viewTreeObserver = getViewTreeObserver ( ) ; if ( viewTreeObserver . isAlive ( ) ) { viewTreeObserver . removeGlobalOnLayoutListener ( mOnGlobalLayoutListener ) ; } } return true ; } | Dismisses the popup window with activities . |
27,543 | private IcsListPopupWindow getListPopupWindow ( ) { if ( mListPopupWindow == null ) { mListPopupWindow = new IcsListPopupWindow ( getContext ( ) ) ; mListPopupWindow . setAdapter ( mAdapter ) ; mListPopupWindow . setAnchorView ( ActivityChooserView . this ) ; mListPopupWindow . setModal ( true ) ; mListPopupWindow . se... | Gets the list popup window which is lazily initialized . |
27,544 | private void updateAppearance ( ) { if ( mAdapter . getCount ( ) > 0 ) { mExpandActivityOverflowButton . setEnabled ( true ) ; } else { mExpandActivityOverflowButton . setEnabled ( false ) ; } final int activityCount = mAdapter . getActivityCount ( ) ; final int historySize = mAdapter . getHistorySize ( ) ; if ( activi... | Updates the buttons state . |
27,545 | public boolean invoke ( ) { if ( mClickListener != null && mClickListener . onMenuItemClick ( this ) ) { return true ; } if ( mMenu . dispatchMenuItemSelected ( mMenu . getRootMenu ( ) , this ) ) { return true ; } if ( mItemCallback != null ) { mItemCallback . run ( ) ; return true ; } if ( mIntent != null ) { try { mM... | Invokes the item by calling various listeners or callbacks . |
27,546 | public String getText ( final String toTest , final int group ) { Matcher m = pattern . matcher ( toTest ) ; StringBuilder result = new StringBuilder ( ) ; while ( m . find ( ) ) { result . append ( m . group ( group ) ) ; } return result . toString ( ) ; } | Extract exact group from string |
27,547 | public List < String > getTextGroups ( final String toTest , final int group ) { List < String > groups = new ArrayList < > ( ) ; Matcher m = pattern . matcher ( toTest ) ; while ( m . find ( ) ) { groups . add ( m . group ( group ) ) ; } return groups ; } | Extract exact group from string and add it to list |
27,548 | public static Builder regex ( final Builder pBuilder ) { Builder builder = new Builder ( ) ; builder . prefixes . append ( pBuilder . prefixes ) ; builder . source . append ( pBuilder . source ) ; builder . suffixes . append ( pBuilder . suffixes ) ; builder . modifiers = pBuilder . modifiers ; return builder ; } | Creates new instance of VerbalExpression builder from cloned builder |
27,549 | public FieldConstraintsBuilder forField ( final CronFieldName field ) { switch ( field ) { case SECOND : case MINUTE : endRange = 59 ; return this ; case HOUR : endRange = 23 ; return this ; case DAY_OF_WEEK : stringMapping = daysOfWeekMapping ( ) ; endRange = 6 ; return this ; case DAY_OF_MONTH : startRange = 1 ; endR... | Creates range constraints according to CronFieldName parameter . |
27,550 | private static Map < String , Integer > daysOfWeekMapping ( ) { final Map < String , Integer > stringMapping = new HashMap < > ( ) ; stringMapping . put ( "MON" , 1 ) ; stringMapping . put ( "TUE" , 2 ) ; stringMapping . put ( "WED" , 3 ) ; stringMapping . put ( "THU" , 4 ) ; stringMapping . put ( "FRI" , 5 ) ; stringM... | Creates days of week mapping . |
27,551 | private static Map < String , Integer > monthsMapping ( ) { final Map < String , Integer > stringMapping = new HashMap < > ( ) ; stringMapping . put ( "JAN" , 1 ) ; stringMapping . put ( "FEB" , 2 ) ; stringMapping . put ( "MAR" , 3 ) ; stringMapping . put ( "APR" , 4 ) ; stringMapping . put ( "MAY" , 5 ) ; stringMappi... | Creates months mapping . |
27,552 | public static String checkNotNullNorEmpty ( final String reference , final Object errorMessage ) { if ( reference == null ) { throw new NullPointerException ( String . valueOf ( errorMessage ) ) ; } if ( reference . isEmpty ( ) ) { throw new IllegalArgumentException ( String . valueOf ( errorMessage ) ) ; } return refe... | Ensures that a string reference passed as a parameter to the calling method is not null . nor empty . |
27,553 | public Cron map ( final Cron cron ) { Preconditions . checkNotNull ( cron , "Cron must not be null" ) ; final List < CronField > fields = new ArrayList < > ( ) ; for ( final CronFieldName name : CronFieldName . values ( ) ) { if ( mappings . containsKey ( name ) ) { fields . add ( mappings . get ( name ) . apply ( cron... | Maps given cron to target cron definition . |
27,554 | public static CronMapper fromCron4jToQuartz ( ) { return new CronMapper ( CronDefinitionBuilder . instanceDefinitionFor ( CronType . CRON4J ) , CronDefinitionBuilder . instanceDefinitionFor ( CronType . QUARTZ ) , setQuestionMark ( ) ) ; } | Creates a CronMapper that maps a cron4j expression to a quartz expression . |
27,555 | private void buildMappings ( final CronDefinition from , final CronDefinition to ) { final Map < CronFieldName , FieldDefinition > sourceFieldDefinitions = getFieldDefinitions ( from ) ; final Map < CronFieldName , FieldDefinition > destFieldDefinitions = getFieldDefinitions ( to ) ; boolean startedDestMapping = false ... | Builds functions that map the fields from source CronDefinition to target . |
27,556 | static Function < CronField , CronField > returnOnZeroExpression ( final CronFieldName name ) { return field -> { final FieldConstraints constraints = FieldConstraintsBuilder . instance ( ) . forField ( name ) . createConstraintsInstance ( ) ; return new CronField ( name , new On ( new IntegerFieldValue ( 0 ) ) , const... | Creates a Function that returns a On instance with zero value . |
27,557 | static Function < CronField , CronField > returnAlwaysExpression ( final CronFieldName name ) { return field -> new CronField ( name , always ( ) , FieldConstraintsBuilder . instance ( ) . forField ( name ) . createConstraintsInstance ( ) ) ; } | Creates a Function that returns an Always instance . |
27,558 | public static DescriptionStrategy daysOfWeekInstance ( final ResourceBundle bundle , final FieldExpression expression , final FieldDefinition definition ) { final Function < Integer , String > nominal = integer -> { final int diff = definition instanceof DayOfWeekFieldDefinition ? DayOfWeek . MONDAY . getValue ( ) - ( ... | Creates description strategy for days of week . |
27,559 | public static DescriptionStrategy daysOfMonthInstance ( final ResourceBundle bundle , final FieldExpression expression ) { final NominalDescriptionStrategy dom = new NominalDescriptionStrategy ( bundle , null , expression ) ; dom . addDescription ( fieldExpression -> { if ( fieldExpression instanceof On ) { final On on... | Creates description strategy for days of month . |
27,560 | public static DescriptionStrategy monthsInstance ( final ResourceBundle bundle , final FieldExpression expression ) { return new NominalDescriptionStrategy ( bundle , integer -> Month . of ( integer ) . getDisplayName ( TextStyle . FULL , bundle . getLocale ( ) ) , expression ) ; } | Creates description strategy for months . |
27,561 | public static DescriptionStrategy plainInstance ( final ResourceBundle bundle , final FieldExpression expression ) { return new NominalDescriptionStrategy ( bundle , null , expression ) ; } | Creates nominal description strategy . |
27,562 | protected String describe ( final FieldExpression fieldExpression , final boolean and ) { Preconditions . checkNotNull ( fieldExpression , "CronFieldExpression should not be null!" ) ; if ( fieldExpression instanceof Always ) { return describe ( fieldExpression , and ) ; } if ( fieldExpression instanceof And ) { return... | Given a CronFieldExpression provide a String with a human readable description . Will identify CronFieldExpression subclasses and delegate . |
27,563 | protected String describe ( final And and ) { final List < FieldExpression > expressions = new ArrayList < > ( ) ; final List < FieldExpression > onExpressions = new ArrayList < > ( ) ; for ( final FieldExpression fieldExpression : and . getExpressions ( ) ) { if ( fieldExpression instanceof On ) { onExpressions . add ... | Provide a human readable description for And instance . |
27,564 | protected String describe ( final On on , final boolean and ) { if ( and ) { return nominalValue ( on . getTime ( ) ) ; } return String . format ( "%s %s " , bundle . getString ( "at" ) , nominalValue ( on . getTime ( ) ) ) + "%s" ; } | Provide a human readable description for On instance . |
27,565 | protected void isInRange ( final FieldValue < ? > fieldValue ) { if ( fieldValue instanceof IntegerFieldValue ) { final int value = ( ( IntegerFieldValue ) fieldValue ) . getValue ( ) ; if ( ! constraints . isInRange ( value ) ) { throw new IllegalArgumentException ( String . format ( OORANGE , value , constraints . ge... | Check if given number is greater or equal to start range and minor or equal to end range . |
27,566 | public String describe ( final Cron cron ) { Preconditions . checkNotNull ( cron , "Cron must not be null" ) ; final Map < CronFieldName , CronField > expressions = cron . retrieveFieldsAsMap ( ) ; final Map < CronFieldName , FieldDefinition > fieldDefinitions = cron . getCronDefinition ( ) . retrieveFieldDefinitionsAs... | Provide a description of given CronFieldParseResult list . |
27,567 | public String describeHHmmss ( final Map < CronFieldName , CronField > fields ) { return DescriptionStrategyFactory . hhMMssInstance ( resourceBundle , fields . containsKey ( CronFieldName . HOUR ) ? fields . get ( CronFieldName . HOUR ) . getExpression ( ) : null , fields . containsKey ( CronFieldName . MINUTE ) ? fie... | Provide description for hours minutes and seconds . |
27,568 | public String describeDayOfMonth ( final Map < CronFieldName , CronField > fields ) { final String description = DescriptionStrategyFactory . daysOfMonthInstance ( resourceBundle , fields . containsKey ( CronFieldName . DAY_OF_MONTH ) ? fields . get ( CronFieldName . DAY_OF_MONTH ) . getExpression ( ) : null ) . descri... | Provide description for day of month . |
27,569 | public String describeMonth ( final Map < CronFieldName , CronField > fields ) { final String description = DescriptionStrategyFactory . monthsInstance ( resourceBundle , fields . containsKey ( CronFieldName . MONTH ) ? fields . get ( CronFieldName . MONTH ) . getExpression ( ) : null ) . describe ( ) ; return addTimeE... | Provide description for month . |
27,570 | public String describeDayOfWeek ( final Map < CronFieldName , CronField > fields , final Map < CronFieldName , FieldDefinition > definitions ) { final String description = DescriptionStrategyFactory . daysOfWeekInstance ( resourceBundle , fields . containsKey ( CronFieldName . DAY_OF_WEEK ) ? fields . get ( CronFieldNa... | Provide description for day of week . |
27,571 | public String describeYear ( final Map < CronFieldName , CronField > fields ) { final String description = DescriptionStrategyFactory . plainInstance ( resourceBundle , fields . containsKey ( CronFieldName . YEAR ) ? fields . get ( CronFieldName . YEAR ) . getExpression ( ) : null ) . describe ( ) ; return addExpressio... | Provide description for a year . |
27,572 | private int generateNoneValues ( final On on , final int year , final int month , final int reference ) { final int dowForFirstDoM = LocalDate . of ( year , month , 1 ) . getDayOfWeek ( ) . getValue ( ) ; final int requiredDoW = ConstantsMapper . weekDayMapping ( mondayDoWValue , ConstantsMapper . JAVA8 , on . getTime ... | Generate valid days of the month for the days of week expression . This method requires that you pass it a - 1 for the reference value when starting to generate a sequence of day values . That allows it to handle the special case of which day of the month is the initial matching value . |
27,573 | public static CronConstraint ensureEitherDayOfYearOrMonth ( ) { return new CronConstraint ( "Both, a day-of-year AND a day-of-month or day-of-week, are not supported." ) { private static final long serialVersionUID = 520379111876897579L ; public boolean validate ( Cron cron ) { CronField dayOfYearField = cron . retriev... | Creates CronConstraint to ensure that either day - of - year or month is assigned a specific value . |
27,574 | public Cron validate ( ) { for ( final Map . Entry < CronFieldName , CronField > field : retrieveFieldsAsMap ( ) . entrySet ( ) ) { final CronFieldName fieldName = field . getKey ( ) ; field . getValue ( ) . getExpression ( ) . accept ( new ValidationFieldExpressionVisitor ( getCronDefinition ( ) . getFieldDefinition (... | Validates this Cron instance by validating its cron expression . |
27,575 | public boolean equivalent ( final CronMapper cronMapper , final Cron cron ) { return asString ( ) . equals ( cronMapper . map ( cron ) . asString ( ) ) ; } | Provides means to compare if two cron expressions are equivalent . |
27,576 | private FieldExpression ensureInstance ( final FieldExpression expression , final FieldExpression defaultExpression ) { Preconditions . checkNotNull ( defaultExpression , "Default expression must not be null" ) ; if ( expression != null ) { return expression ; } else { return defaultExpression ; } } | Give an expression instance will return it if is not null . Otherwise will return the defaultExpression ; |
27,577 | public void register ( final FieldDefinition definition ) { boolean hasOptionalField = false ; for ( final FieldDefinition fieldDefinition : fields . values ( ) ) { if ( fieldDefinition . isOptional ( ) ) { hasOptionalField = true ; break ; } } if ( ! definition . isOptional ( ) && hasOptionalField ) { throw new Illega... | Registers a certain FieldDefinition . |
27,578 | public CronDefinition instance ( ) { final Set < CronConstraint > validations = new HashSet < > ( ) ; validations . addAll ( cronConstraints ) ; final List < FieldDefinition > values = new ArrayList < > ( fields . values ( ) ) ; values . sort ( FieldDefinition . createFieldDefinitionComparator ( ) ) ; return new CronDe... | Creates a new CronDefinition instance with provided field definitions . |
27,579 | private static CronDefinition cron4j ( ) { return CronDefinitionBuilder . defineCron ( ) . withMinutes ( ) . and ( ) . withHours ( ) . and ( ) . withDayOfMonth ( ) . supportsL ( ) . and ( ) . withMonth ( ) . and ( ) . withDayOfWeek ( ) . withValidRange ( 0 , 6 ) . withMondayDoWValue ( 1 ) . and ( ) . enforceStrictRange... | Creates CronDefinition instance matching cron4j specification . |
27,580 | private static CronDefinition quartz ( ) { return CronDefinitionBuilder . defineCron ( ) . withSeconds ( ) . and ( ) . withMinutes ( ) . and ( ) . withHours ( ) . and ( ) . withDayOfMonth ( ) . withValidRange ( 1 , 32 ) . supportsL ( ) . supportsW ( ) . supportsLW ( ) . supportsQuestionMark ( ) . and ( ) . withMonth ( ... | Creates CronDefinition instance matching Quartz specification . |
27,581 | private static CronDefinition spring ( ) { return CronDefinitionBuilder . defineCron ( ) . withSeconds ( ) . and ( ) . withMinutes ( ) . and ( ) . withHours ( ) . and ( ) . withDayOfMonth ( ) . supportsQuestionMark ( ) . and ( ) . withMonth ( ) . and ( ) . withDayOfWeek ( ) . withValidRange ( 1 , 7 ) . withMondayDoWVal... | Creates CronDefinition instance matching Spring specification . |
27,582 | private static CronDefinition unixCrontab ( ) { return CronDefinitionBuilder . defineCron ( ) . withMinutes ( ) . and ( ) . withHours ( ) . and ( ) . withDayOfMonth ( ) . and ( ) . withMonth ( ) . and ( ) . withDayOfWeek ( ) . withValidRange ( 0 , 7 ) . withMondayDoWValue ( 1 ) . withIntMapping ( 7 , 0 ) . and ( ) . en... | Creates CronDefinition instance matching unix crontab specification . |
27,583 | public static CronDefinition instanceDefinitionFor ( final CronType cronType ) { switch ( cronType ) { case CRON4J : return cron4j ( ) ; case QUARTZ : return quartz ( ) ; case UNIX : return unixCrontab ( ) ; case SPRING : return spring ( ) ; default : throw new IllegalArgumentException ( String . format ( "No cron defi... | Creates CronDefinition instance matching cronType specification . |
27,584 | public int mapTo ( final int dayOfWeek , final WeekDay targetWeekDayDefinition ) { if ( firstDayZero && targetWeekDayDefinition . isFirstDayZero ( ) ) { return bothSameStartOfRange ( 0 , 6 , this , targetWeekDayDefinition ) . apply ( dayOfWeek ) ; } if ( ! firstDayZero && ! targetWeekDayDefinition . isFirstDayZero ( ) ... | Maps given WeekDay to representation hold by this instance . |
27,585 | public static int weekDayMapping ( final WeekDay source , final WeekDay target , final int weekday ) { return source . mapTo ( weekday , target ) ; } | Performs weekday mapping between two weekday definitions . |
27,586 | public CronField parse ( final String expression ) { return new CronField ( field , parser . parse ( expression ) , constraints ) ; } | Parses a String cron expression . |
27,587 | private void buildPossibleExpressions ( final CronDefinition cronDefinition ) { final List < CronParserField > sortedExpression = cronDefinition . getFieldDefinitions ( ) . stream ( ) . map ( this :: toCronParserField ) . sorted ( CronParserField . createFieldTypeComparator ( ) ) . collect ( Collectors . toList ( ) ) ;... | Build possible cron expressions from definitions . One is built for sure . A second one may be build if last field is optional . |
27,588 | public FieldExpression parse ( final String expression ) { if ( ! StringUtils . containsAny ( expression , SPECIAL_CHARS_MINUS_STAR ) ) { if ( expression . contains ( QUESTION_MARK_STRING ) && ! fieldConstraints . getSpecialChars ( ) . contains ( QUESTION_MARK ) ) { throw new IllegalArgumentException ( "Invalid express... | Parse given expression for a single cron field . |
27,589 | protected int stringToInt ( final String exp ) { final Integer value = fieldConstraints . getStringMappingValue ( exp ) ; if ( value != null ) { return value ; } else { try { return Integer . parseInt ( exp ) ; } catch ( final NumberFormatException e ) { final String invalidChars = new StringValidations ( fieldConstrai... | Maps string expression to integer . If no mapping is found will try to parse String as Integer |
27,590 | public Optional < ZonedDateTime > nextExecution ( final ZonedDateTime date ) { Preconditions . checkNotNull ( date ) ; try { ZonedDateTime nextMatch = nextClosestMatch ( date ) ; if ( nextMatch . equals ( date ) ) { nextMatch = nextClosestMatch ( date . plusSeconds ( 1 ) ) ; } return Optional . of ( nextMatch ) ; } cat... | Provide nearest date for next execution . |
27,591 | private ZonedDateTime nextClosestMatch ( final ZonedDateTime date ) throws NoSuchValueException { ExecutionTimeResult result = new ExecutionTimeResult ( date , false ) ; for ( int i = 0 ; i < MAX_ITERATIONS ; i ++ ) { result = potentialNextClosestMatch ( result . getTime ( ) ) ; if ( result . isMatch ( ) ) { return res... | If date is not match will return next closest match . If date is match will return this date . |
27,592 | private ZonedDateTime previousClosestMatch ( final ZonedDateTime date ) throws NoSuchValueException { ExecutionTimeResult result = new ExecutionTimeResult ( date , false ) ; for ( int i = 0 ; i < MAX_ITERATIONS ; i ++ ) { result = potentialPreviousClosestMatch ( result . getTime ( ) ) ; if ( result . isMatch ( ) ) { re... | If date is not match will return previous closest match . If date is match will return this date . |
27,593 | public Optional < ZonedDateTime > lastExecution ( final ZonedDateTime date ) { Preconditions . checkNotNull ( date ) ; try { ZonedDateTime previousMatch = previousClosestMatch ( date ) ; if ( previousMatch . equals ( date ) ) { previousMatch = previousClosestMatch ( date . minusSeconds ( 1 ) ) ; } return Optional . of ... | Provide nearest date for last execution . |
27,594 | public boolean isMatch ( ZonedDateTime date ) { final boolean isSecondGranularity = cronDefinition . containsFieldDefinition ( SECOND ) ; if ( isSecondGranularity ) { date = date . truncatedTo ( SECONDS ) ; } else { date = date . truncatedTo ( ChronoUnit . MINUTES ) ; } final Optional < ZonedDateTime > last = lastExecu... | Provide feedback if a given date matches the cron expression . |
27,595 | public synchronized EmbeddedElastic start ( ) throws IOException , InterruptedException { if ( ! started ) { started = true ; installElastic ( ) ; startElastic ( ) ; createRestClient ( ) ; createTemplates ( ) ; createIndices ( ) ; } return this ; } | Downloads Elasticsearch with specified plugins setups them and starts |
27,596 | @ SuppressWarnings ( "unchecked" ) public static < T extends Comparable < ? super T > > ComparatorCompat < T > naturalOrder ( ) { return ( ComparatorCompat < T > ) NATURAL_ORDER ; } | Returns a comparator with natural order . |
27,597 | @ SuppressWarnings ( "unchecked" ) public static < T extends Comparable < ? super T > > ComparatorCompat < T > reverseOrder ( ) { return ( ComparatorCompat < T > ) REVERSE_ORDER ; } | Returns a comparator with reverse order . |
27,598 | public static < T , U > ComparatorCompat < T > comparing ( final Function < ? super T , ? extends U > keyExtractor , final Comparator < ? super U > keyComparator ) { Objects . requireNonNull ( keyExtractor ) ; Objects . requireNonNull ( keyComparator ) ; return new ComparatorCompat < T > ( new Comparator < T > ( ) { pu... | Returns a comparator that uses a function that extracts a sort key to be compared with the specified comparator . |
27,599 | public ComparatorCompat < T > thenComparing ( final Comparator < ? super T > other ) { return new ComparatorCompat < T > ( thenComparing ( comparator , other ) ) ; } | Adds the given comparator to the chain . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.