idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
26,200 | @ NonNull public List < RouterTransaction > getBackstack ( ) { List < RouterTransaction > list = new ArrayList <> ( backstack . size ( ) ) ; Iterator < RouterTransaction > backstackIterator = backstack . reverseIterator ( ) ; while ( backstackIterator . hasNext ( ) ) { list . add ( backstackIterator . next ( ) ) ; } return list ; } | Returns the current backstack ordered from root to most recently pushed . | 84 | 13 |
26,201 | @ UiThread public void rebindIfNeeded ( ) { ThreadUtils . ensureMainThread ( ) ; Iterator < RouterTransaction > backstackIterator = backstack . reverseIterator ( ) ; while ( backstackIterator . hasNext ( ) ) { RouterTransaction transaction = backstackIterator . next ( ) ; if ( transaction . controller . getNeedsAttach ( ) ) { performControllerChange ( transaction , null , true , new SimpleSwapChangeHandler ( false ) ) ; } else { setControllerRouter ( transaction . controller ) ; } } } | Attaches this Router s existing backstack to its container if one exists . | 117 | 15 |
26,202 | private void ensureOrderedTransactionIndices ( List < RouterTransaction > backstack ) { List < Integer > indices = new ArrayList <> ( backstack . size ( ) ) ; for ( RouterTransaction transaction : backstack ) { transaction . ensureValidIndex ( getTransactionIndexer ( ) ) ; indices . add ( transaction . transactionIndex ) ; } Collections . sort ( indices ) ; for ( int i = 0 ; i < backstack . size ( ) ; i ++ ) { backstack . get ( i ) . transactionIndex = indices . get ( i ) ; } } | developer rearranging the backstack at runtime . | 120 | 10 |
26,203 | @ NonNull public Bundle saveInstanceState ( ) { Bundle bundle = new Bundle ( ) ; bundle . putBundle ( KEY_VIEW_CONTROLLER_BUNDLE , controller . saveInstanceState ( ) ) ; if ( pushControllerChangeHandler != null ) { bundle . putBundle ( KEY_PUSH_TRANSITION , pushControllerChangeHandler . toBundle ( ) ) ; } if ( popControllerChangeHandler != null ) { bundle . putBundle ( KEY_POP_TRANSITION , popControllerChangeHandler . toBundle ( ) ) ; } bundle . putString ( KEY_TAG , tag ) ; bundle . putInt ( KEY_INDEX , transactionIndex ) ; bundle . putBoolean ( KEY_ATTACHED_TO_ROUTER , attachedToRouter ) ; return bundle ; } | Used to serialize this transaction into a Bundle | 179 | 9 |
26,204 | protected ActionBar getActionBar ( ) { ActionBarProvider actionBarProvider = ( ( ActionBarProvider ) getActivity ( ) ) ; return actionBarProvider != null ? actionBarProvider . getSupportActionBar ( ) : null ; } | be accessed . In a production app this would use Dagger instead . | 49 | 13 |
26,205 | private static String driverVersion ( ) { // "Session" is arbitrary - the only thing that matters is that the class we use here is in the // 'org.neo4j.driver' package, because that is where the jar manifest specifies the version. // This is done as part of the build, adding a MANIFEST.MF file to the generated jarfile. Package pkg = Session . class . getPackage ( ) ; if ( pkg != null && pkg . getImplementationVersion ( ) != null ) { return pkg . getImplementationVersion ( ) ; } // If there is no version, we're not running from a jar file, but from raw compiled class files. // This should only happen during development, so call the version 'dev'. return "dev" ; } | Extracts the driver version from the driver jar MANIFEST . MF file . | 167 | 17 |
26,206 | private StatementResult addCompany ( final Transaction tx , final String name ) { return tx . run ( "CREATE (:Company {name: $name})" , parameters ( "name" , name ) ) ; } | Create a company node | 45 | 4 |
26,207 | private StatementResult addPerson ( final Transaction tx , final String name ) { return tx . run ( "CREATE (:Person {name: $name})" , parameters ( "name" , name ) ) ; } | Create a person node | 45 | 4 |
26,208 | private StatementResult employ ( final Transaction tx , final String person , final String company ) { return tx . run ( "MATCH (person:Person {name: $person_name}) " + "MATCH (company:Company {name: $company_name}) " + "CREATE (person)-[:WORKS_FOR]->(company)" , parameters ( "person_name" , person , "company_name" , company ) ) ; } | This relies on the person first having been created . | 96 | 10 |
26,209 | private StatementResult makeFriends ( final Transaction tx , final String person1 , final String person2 ) { return tx . run ( "MATCH (a:Person {name: $person_1}) " + "MATCH (b:Person {name: $person_2}) " + "MERGE (a)-[:KNOWS]->(b)" , parameters ( "person_1" , person1 , "person_2" , person2 ) ) ; } | Create a friendship between two people . | 99 | 7 |
26,210 | private StatementResult printFriends ( final Transaction tx ) { StatementResult result = tx . run ( "MATCH (a)-[:KNOWS]->(b) RETURN a.name, b.name" ) ; while ( result . hasNext ( ) ) { Record record = result . next ( ) ; System . out . println ( String . format ( "%s knows %s" , record . get ( "a.name" ) . asString ( ) , record . get ( "b.name" ) . toString ( ) ) ) ; } return result ; } | Match and display all friendships . | 121 | 6 |
26,211 | public static void checkArgument ( Object argument , Class < ? > expectedClass ) { if ( ! expectedClass . isInstance ( argument ) ) { throw new IllegalArgumentException ( "Argument expected to be of type: " + expectedClass . getName ( ) + " but was: " + argument ) ; } } | Assert that given argument is of expected type . | 68 | 10 |
26,212 | public static AuthToken kerberos ( String base64EncodedTicket ) { Objects . requireNonNull ( base64EncodedTicket , "Ticket can't be null" ) ; Map < String , Value > map = newHashMapWithSize ( 3 ) ; map . put ( SCHEME_KEY , value ( "kerberos" ) ) ; map . put ( PRINCIPAL_KEY , value ( "" ) ) ; // This empty string is required for backwards compatibility. map . put ( CREDENTIALS_KEY , value ( base64EncodedTicket ) ) ; return new InternalAuthToken ( map ) ; } | The kerberos authentication scheme using a base64 encoded ticket | 137 | 12 |
26,213 | public static < T > Publisher < T > createEmptyPublisher ( Supplier < CompletionStage < Void > > supplier ) { return Mono . create ( sink -> supplier . get ( ) . whenComplete ( ( ignore , completionError ) -> { Throwable error = Futures . completionExceptionCause ( completionError ) ; if ( error != null ) { sink . error ( error ) ; } else { sink . success ( ) ; } } ) ) ; } | The publisher created by this method will either succeed without publishing anything or fail with an error . | 94 | 18 |
26,214 | private void load ( ) throws IOException { if ( ! knownHosts . exists ( ) ) { return ; } assertKnownHostFileReadable ( ) ; try ( BufferedReader reader = new BufferedReader ( new FileReader ( knownHosts ) ) ) { String line ; while ( ( line = reader . readLine ( ) ) != null ) { if ( ( ! line . trim ( ) . startsWith ( "#" ) ) ) { String [ ] strings = line . split ( " " ) ; if ( strings [ 0 ] . trim ( ) . equals ( serverId ) ) { // load the certificate fingerprint = strings [ 1 ] . trim ( ) ; return ; } } } } } | Try to load the certificate form the file if the server we ve connected is a known server . | 147 | 19 |
26,215 | public static String fingerprint ( X509Certificate cert ) throws CertificateException { try { MessageDigest md = MessageDigest . getInstance ( "SHA-512" ) ; md . update ( cert . getEncoded ( ) ) ; return ByteBufUtil . hexDump ( md . digest ( ) ) ; } catch ( NoSuchAlgorithmException e ) { // SHA-1 not available throw new CertificateException ( "Cannot use TLS on this platform, because SHA-512 message digest algorithm is not available: " + e . getMessage ( ) , e ) ; } } | Calculate the certificate fingerprint - simply the SHA - 512 hash of the DER - encoded certificate . | 123 | 21 |
26,216 | public CompletionStage < ClusterComposition > lookupClusterComposition ( RoutingTable routingTable , ConnectionPool connectionPool ) { CompletableFuture < ClusterComposition > result = new CompletableFuture <> ( ) ; lookupClusterComposition ( routingTable , connectionPool , 0 , 0 , result ) ; return result ; } | Given the current routing table and connection pool use the connection composition provider to fetch a new cluster composition which would be used to update the routing table and connection pool . | 71 | 32 |
26,217 | public static void saveX509Cert ( String certStr , File certFile ) throws IOException { try ( BufferedWriter writer = new BufferedWriter ( new FileWriter ( certFile ) ) ) { writer . write ( BEGIN_CERT ) ; writer . newLine ( ) ; writer . write ( certStr ) ; writer . newLine ( ) ; writer . write ( END_CERT ) ; writer . newLine ( ) ; } } | Save a certificate to a file in base 64 binary format with BEGIN and END strings | 94 | 17 |
26,218 | public static void saveX509Cert ( Certificate cert , File certFile ) throws GeneralSecurityException , IOException { saveX509Cert ( new Certificate [ ] { cert } , certFile ) ; } | Save a certificate to a file . Remove all the content in the file if there is any before . | 41 | 20 |
26,219 | public static void saveX509Cert ( Certificate [ ] certs , File certFile ) throws GeneralSecurityException , IOException { try ( BufferedWriter writer = new BufferedWriter ( new FileWriter ( certFile ) ) ) { for ( Certificate cert : certs ) { String certStr = Base64 . getEncoder ( ) . encodeToString ( cert . getEncoded ( ) ) . replaceAll ( "(.{64})" , "$1\n" ) ; writer . write ( BEGIN_CERT ) ; writer . newLine ( ) ; writer . write ( certStr ) ; writer . newLine ( ) ; writer . write ( END_CERT ) ; writer . newLine ( ) ; } } } | Save a list of certificates into a file | 151 | 8 |
26,220 | public static void loadX509Cert ( File certFile , KeyStore keyStore ) throws GeneralSecurityException , IOException { try ( BufferedInputStream inputStream = new BufferedInputStream ( new FileInputStream ( certFile ) ) ) { CertificateFactory certFactory = CertificateFactory . getInstance ( "X.509" ) ; int certCount = 0 ; // The file might contain multiple certs while ( inputStream . available ( ) > 0 ) { try { Certificate cert = certFactory . generateCertificate ( inputStream ) ; certCount ++ ; loadX509Cert ( cert , "neo4j.javadriver.trustedcert." + certCount , keyStore ) ; } catch ( CertificateException e ) { if ( e . getCause ( ) != null && e . getCause ( ) . getMessage ( ) . equals ( "Empty input" ) ) { // This happens if there is whitespace at the end of the certificate - we load one cert, and then try and load a // second cert, at which point we fail return ; } throw new IOException ( "Failed to load certificate from `" + certFile . getAbsolutePath ( ) + "`: " + certCount + " : " + e . getMessage ( ) , e ) ; } } } } | Load the certificates written in X . 509 format in a file to a key store . | 273 | 18 |
26,221 | public static void loadX509Cert ( Certificate cert , String certAlias , KeyStore keyStore ) throws KeyStoreException { keyStore . setCertificateEntry ( certAlias , cert ) ; } | Load a certificate to a key store with a name | 40 | 10 |
26,222 | public static String X509CertToString ( String cert ) { String cert64CharPerLine = cert . replaceAll ( "(.{64})" , "$1\n" ) ; return BEGIN_CERT + "\n" + cert64CharPerLine + "\n" + END_CERT + "\n" ; } | Convert a certificate in base 64 binary format with BEGIN and END strings | 70 | 15 |
26,223 | public Statement withUpdatedParameters ( Value updates ) { if ( updates == null || updates . isEmpty ( ) ) { return this ; } else { Map < String , Value > newParameters = newHashMapWithSize ( Math . max ( parameters . size ( ) , updates . size ( ) ) ) ; newParameters . putAll ( parameters . asMap ( ofValue ( ) ) ) ; for ( Map . Entry < String , Value > entry : updates . asMap ( ofValue ( ) ) . entrySet ( ) ) { Value value = entry . getValue ( ) ; if ( value . isNull ( ) ) { newParameters . remove ( entry . getKey ( ) ) ; } else { newParameters . put ( entry . getKey ( ) , value ) ; } } return withParameters ( value ( newParameters ) ) ; } } | Create a new statement with new parameters derived by updating this statement s parameters using the given updates . | 176 | 19 |
26,224 | public BoltServerAddress resolve ( ) throws UnknownHostException { String ipAddress = InetAddress . getByName ( host ) . getHostAddress ( ) ; if ( ipAddress . equals ( host ) ) { return this ; } else { return new BoltServerAddress ( host , ipAddress , port ) ; } } | Resolve the host name down to an IP address if not already resolved . | 66 | 15 |
26,225 | public static GoogleConnector getInstance ( ) { if ( instance == null ) { try { instance = new GoogleConnector ( ) ; } catch ( Exception e ) { throw new RuntimeException ( "The GoogleConnector could not be instanced!" , e ) ; } } return instance ; } | On demand instance creator method used to get the single instance of this google authenticator class . | 58 | 18 |
26,226 | synchronized void removeCredential ( String accountId ) throws IOException { DataStore < StoredCredential > sc = StoredCredential . getDefaultDataStore ( dataStoreFactory ) ; sc . delete ( accountId ) ; calendarService = null ; geoService = null ; } | Deletes the stored credentials for the given account id . This means the next time the user must authorize the app to access his calendars . | 63 | 27 |
26,227 | boolean isAuthorized ( String accountId ) { try { DataStore < StoredCredential > sc = StoredCredential . getDefaultDataStore ( dataStoreFactory ) ; return sc . containsKey ( accountId ) ; } catch ( IOException e ) { return false ; } } | Checks if the given account id has already been authorized and the user granted access to his calendars info . | 63 | 21 |
26,228 | public synchronized GoogleCalendarService getCalendarService ( String accountId ) throws IOException { if ( calendarService == null ) { Credential credential = impl_getStoredCredential ( accountId ) ; if ( credential == null ) { throw new UnsupportedOperationException ( "The account has not been authorized yet!" ) ; } calendarService = new GoogleCalendarService ( impl_createService ( credential ) ) ; } return calendarService ; } | Instances a new calendar service for the given google account user name . This requires previous authorization to get the service so if the user has not granted access to his data this method will start the authorization process automatically ; this attempts to open the login google page in the default browser . | 95 | 55 |
26,229 | GoogleAccount getAccountInfo ( String accountId ) throws IOException { Credential credential = impl_getStoredCredential ( accountId ) ; if ( credential == null ) { throw new UnsupportedOperationException ( "The account has not been authorized yet!" ) ; } Userinfoplus info = impl_requestUserInfo ( credential ) ; GoogleAccount account = new GoogleAccount ( ) ; account . setId ( accountId ) ; account . setName ( info . getName ( ) ) ; return account ; } | Requests the user info for the given account . This requires previous authorization from the user so this might start the process . | 109 | 24 |
26,230 | public final ObjectProperty < Insets > extraPaddingProperty ( ) { if ( extraPadding == null ) { extraPadding = new StyleableObjectProperty < Insets > ( new Insets ( 2 , 0 , 9 , 0 ) ) { @ Override public CssMetaData < AllDayView , Insets > getCssMetaData ( ) { return StyleableProperties . EXTRA_PADDING ; } @ Override public Object getBean ( ) { return AllDayView . this ; } @ Override public String getName ( ) { return "extraPadding" ; //$NON-NLS-1$ } } ; } return extraPadding ; } | Extra padding to be used inside of the view above and below the full day entries . This is required as the regular padding is already used for other styling purposes . | 146 | 32 |
26,231 | public final DoubleProperty rowHeightProperty ( ) { if ( rowHeight == null ) { rowHeight = new StyleableDoubleProperty ( 20 ) { @ Override public CssMetaData < AllDayView , Number > getCssMetaData ( ) { return StyleableProperties . ROW_HEIGHT ; } @ Override public Object getBean ( ) { return AllDayView . this ; } @ Override public String getName ( ) { return "rowHeight" ; //$NON-NLS-1$ } } ; } return rowHeight ; } | The height for each row shown by the view . This value determines the total height of the view . | 120 | 20 |
26,232 | public final DoubleProperty rowSpacingProperty ( ) { if ( rowSpacing == null ) { rowSpacing = new StyleableDoubleProperty ( 2 ) { @ Override public CssMetaData < AllDayView , Number > getCssMetaData ( ) { return StyleableProperties . ROW_SPACING ; } @ Override public Object getBean ( ) { return AllDayView . this ; } @ Override public String getName ( ) { return "rowSpacing" ; //$NON-NLS-1$ } } ; } return rowSpacing ; } | Stores the spacing between rows in the view . | 126 | 10 |
26,233 | public final DoubleProperty columnSpacingProperty ( ) { if ( columnSpacing == null ) { columnSpacing = new StyleableDoubleProperty ( 2 ) { @ Override public CssMetaData < AllDayView , Number > getCssMetaData ( ) { return StyleableProperties . COLUMN_SPACING ; } @ Override public Object getBean ( ) { return AllDayView . this ; } @ Override public String getName ( ) { return "columnSpacing" ; //$NON-NLS-1$ } } ; } return columnSpacing ; } | Stores the spacing between columns in the view . | 127 | 10 |
26,234 | public void show ( Window owner ) { InvalidationListener viewTypeListener = obs -> loadDropDownValues ( getDate ( ) ) ; if ( dialog != null ) { dialog . show ( ) ; } else { TimeRangeView timeRange = getSettingsView ( ) . getTimeRangeView ( ) ; Scene scene = new Scene ( this ) ; dialog = new Stage ( ) ; dialog . initOwner ( owner ) ; dialog . setScene ( scene ) ; dialog . sizeToScene ( ) ; dialog . centerOnScreen ( ) ; dialog . setTitle ( Messages . getString ( "PrintView.TITLE_LABEL" ) ) ; dialog . initModality ( Modality . APPLICATION_MODAL ) ; if ( getPrintIcon ( ) != null ) dialog . getIcons ( ) . add ( getPrintIcon ( ) ) ; dialog . setOnHidden ( obs -> { timeRange . cleanOldValues ( ) ; timeRange . viewTypeProperty ( ) . removeListener ( viewTypeListener ) ; } ) ; dialog . setOnShown ( obs -> timeRange . viewTypeProperty ( ) . addListener ( viewTypeListener ) ) ; dialog . show ( ) ; } } | Creates an application - modal dialog and shows it after adding the print view to it . | 250 | 19 |
26,235 | public int approximateIntervalInDays ( ) { int freqLengthDays ; int nPerPeriod = 0 ; switch ( this . freq ) { case DAILY : freqLengthDays = 1 ; break ; case WEEKLY : freqLengthDays = 7 ; if ( ! this . byDay . isEmpty ( ) ) { nPerPeriod = this . byDay . size ( ) ; } break ; case MONTHLY : freqLengthDays = 30 ; if ( ! this . byDay . isEmpty ( ) ) { for ( WeekdayNum day : byDay ) { // if it's every weekday in the month, assume four of that weekday, // otherwise there is one of that week-in-month,weekday pair nPerPeriod += 0 != day . num ? 1 : 4 ; } } else { nPerPeriod = this . byMonthDay . length ; } break ; case YEARLY : freqLengthDays = 365 ; int monthCount = 12 ; if ( 0 != this . byMonth . length ) { monthCount = this . byMonth . length ; } if ( ! this . byDay . isEmpty ( ) ) { for ( WeekdayNum day : byDay ) { // if it's every weekend in the months in the year, // assume 4 of that weekday per month, // otherwise there is one of that week-in-month,weekday pair per // month nPerPeriod += ( 0 != day . num ? 1 : 4 ) * monthCount ; } } else if ( 0 != this . byMonthDay . length ) { nPerPeriod += monthCount * this . byMonthDay . length ; } else { nPerPeriod += this . byYearDay . length ; } break ; default : freqLengthDays = 0 ; } if ( 0 == nPerPeriod ) { nPerPeriod = 1 ; } return ( ( freqLengthDays / nPerPeriod ) * this . interval ) ; } | an approximate number of days between occurences . | 416 | 10 |
26,236 | public String toIcal ( ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( this . getName ( ) . toUpperCase ( ) ) ; buf . append ( ";TZID=\"" ) . append ( tzid . getID ( ) ) . append ( ' ' ) ; buf . append ( ";VALUE=" ) . append ( valueType . toIcal ( ) ) ; if ( hasExtParams ( ) ) { for ( Map . Entry < String , String > param : getExtParams ( ) . entrySet ( ) ) { String k = param . getKey ( ) , v = param . getValue ( ) ; if ( ICAL_SPECIALS . matcher ( v ) . find ( ) ) { v = "\"" + v + "\"" ; } buf . append ( ' ' ) . append ( k ) . append ( ' ' ) . append ( v ) ; } } buf . append ( ' ' ) ; for ( int i = 0 ; i < datesUtc . length ; ++ i ) { if ( 0 != i ) { buf . append ( ' ' ) ; } DateValue v = datesUtc [ i ] ; buf . append ( v ) ; if ( v instanceof TimeValue ) { buf . append ( ' ' ) ; } } return buf . toString ( ) ; } | returns a String containing ical content lines . | 292 | 10 |
26,237 | static Predicate < DateValue > byDayFilter ( final WeekdayNum [ ] days , final boolean weeksInYear , final Weekday wkst ) { return new Predicate < DateValue > ( ) { public boolean apply ( DateValue date ) { Weekday dow = Weekday . valueOf ( date ) ; int nDays ; // first day of the week in the given year or month Weekday dow0 ; // where does date appear in the year or month? // in [0, lengthOfMonthOrYear - 1] int instance ; if ( weeksInYear ) { nDays = TimeUtils . yearLength ( date . year ( ) ) ; dow0 = Weekday . firstDayOfWeekInMonth ( date . year ( ) , 1 ) ; instance = TimeUtils . dayOfYear ( date . year ( ) , date . month ( ) , date . day ( ) ) ; } else { nDays = TimeUtils . monthLength ( date . year ( ) , date . month ( ) ) ; dow0 = Weekday . firstDayOfWeekInMonth ( date . year ( ) , date . month ( ) ) ; instance = date . day ( ) - 1 ; } // which week of the year or month does this date fall on? // one-indexed int dateWeekNo ; if ( wkst . javaDayNum <= dow . javaDayNum ) { dateWeekNo = 1 + ( instance / 7 ) ; } else { dateWeekNo = ( instance / 7 ) ; } // TODO(msamuel): according to section 4.3.10 // Week number one of the calendar year is the first week which // contains at least four (4) days in that calendar year. This // rule part is only valid for YEARLY rules. // That's mentioned under the BYWEEKNO rule, and there's no mention // of it in the earlier discussion of the BYDAY rule. // Does it apply to yearly week numbers calculated for BYDAY rules in // a FREQ=YEARLY rule? for ( int i = days . length ; -- i >= 0 ; ) { WeekdayNum day = days [ i ] ; if ( day . wday == dow ) { int weekNo = day . num ; if ( 0 == weekNo ) { return true ; } if ( weekNo < 0 ) { weekNo = Util . invertWeekdayNum ( day , dow0 , nDays ) ; } if ( dateWeekNo == weekNo ) { return true ; } } } return false ; } } ; } | constructs a day filter based on a BYDAY rule . | 537 | 12 |
26,238 | static Predicate < DateValue > weekIntervalFilter ( final int interval , final Weekday wkst , final DateValue dtStart ) { return new Predicate < DateValue > ( ) { DateValue wkStart ; { // the latest day with day of week wkst on or before dtStart DTBuilder wkStartB = new DTBuilder ( dtStart ) ; wkStartB . day -= ( 7 + Weekday . valueOf ( dtStart ) . javaDayNum - wkst . javaDayNum ) % 7 ; wkStart = wkStartB . toDate ( ) ; } public boolean apply ( DateValue date ) { int daysBetween = TimeUtils . daysBetween ( date , wkStart ) ; if ( daysBetween < 0 ) { // date must be before dtStart. Shouldn't occur in practice. daysBetween += ( interval * 7 * ( 1 + daysBetween / ( - 7 * interval ) ) ) ; } int off = ( daysBetween / 7 ) % interval ; return 0 == off ; } } ; } | constructs a filter that accepts only every interval - th week from the week containing dtStart . | 229 | 20 |
26,239 | static Predicate < DateValue > byMinuteFilter ( int [ ] minutes ) { long minutesByBit = 0 ; for ( int minute : minutes ) { minutesByBit |= 1L << minute ; } if ( ( minutesByBit & LOW_60_BITS ) == LOW_60_BITS ) { return Predicates . alwaysTrue ( ) ; } final long bitField = minutesByBit ; return new Predicate < DateValue > ( ) { public boolean apply ( DateValue date ) { if ( ! ( date instanceof TimeValue ) ) { return false ; } TimeValue tv = ( TimeValue ) date ; return ( bitField & ( 1L << tv . minute ( ) ) ) != 0 ; } } ; } | constructs a minute filter based on a BYMINUTE rule . | 155 | 13 |
26,240 | static Predicate < DateValue > bySecondFilter ( int [ ] seconds ) { long secondsByBit = 0 ; for ( int second : seconds ) { secondsByBit |= 1L << second ; } if ( ( secondsByBit & LOW_60_BITS ) == LOW_60_BITS ) { return Predicates . alwaysTrue ( ) ; } final long bitField = secondsByBit ; return new Predicate < DateValue > ( ) { public boolean apply ( DateValue date ) { if ( ! ( date instanceof TimeValue ) ) { return false ; } TimeValue tv = ( TimeValue ) date ; return ( bitField & ( 1L << tv . second ( ) ) ) != 0 ; } } ; } | constructs a second filter based on a BYMINUTE rule . | 154 | 13 |
26,241 | public final boolean isExtendedMonth ( YearMonth month ) { if ( month != null ) { YearMonth extendedStart = getExtendedStartMonth ( ) ; if ( ( month . equals ( extendedStart ) || month . isAfter ( extendedStart ) ) && month . isBefore ( getStartMonth ( ) ) ) { return true ; } YearMonth extendedEnd = getExtendedEndMonth ( ) ; if ( ( month . equals ( extendedEnd ) || month . isBefore ( extendedEnd ) ) && month . isAfter ( getEndMonth ( ) ) ) { return true ; } } return false ; } | A simple check to see if the given month is part of the extended months . | 127 | 16 |
26,242 | public final boolean isVisibleDate ( LocalDate date ) { if ( date != null ) { YearMonth extendedStart = getExtendedStartMonth ( ) ; YearMonth extendedEnd = getExtendedEndMonth ( ) ; LocalDate startDate = extendedStart . atDay ( 1 ) ; LocalDate endDate = extendedEnd . atEndOfMonth ( ) ; if ( ( date . equals ( startDate ) || date . isAfter ( startDate ) ) && ( date . equals ( endDate ) || date . isBefore ( endDate ) ) ) { return true ; } } return false ; } | Determines if the given date is currently showing is part of the view . This method uses the extended start and end months . | 125 | 26 |
26,243 | public static long secsSinceEpoch ( DateValue date ) { long result = fixedFromGregorian ( date ) * SECS_PER_DAY ; if ( date instanceof TimeValue ) { TimeValue time = ( TimeValue ) date ; result += time . second ( ) + 60 * ( time . minute ( ) + 60 * time . hour ( ) ) ; } return result ; } | Compute the number of seconds from the Proleptic Gregorian epoch to the given time . | 82 | 19 |
26,244 | public static DateValue toDateValue ( DateValue dv ) { return ( ! ( dv instanceof TimeValue ) ? dv : new DateValueImpl ( dv . year ( ) , dv . month ( ) , dv . day ( ) ) ) ; } | a DateValue with the same year month and day as the given instance that is not a TimeValue . | 58 | 21 |
26,245 | public static String getString ( String key ) { try { return RESOURCE_BUNDLE . getString ( key ) ; } catch ( MissingResourceException e ) { return ' ' + key + ' ' ; } } | Returns the translation for the given key . | 47 | 8 |
26,246 | protected void updateStyles ( ) { DayEntryView view = getSkinnable ( ) ; Entry < ? > entry = getEntry ( ) ; Calendar calendar = entry . getCalendar ( ) ; if ( entry instanceof DraggedEntry ) { calendar = ( ( DraggedEntry ) entry ) . getOriginalCalendar ( ) ; } // when the entry gets removed from its calendar then the calendar can // be null if ( calendar == null ) { return ; } view . getStyleClass ( ) . setAll ( "default-style-entry" , calendar . getStyle ( ) + "-entry" ) ; if ( entry . isRecurrence ( ) ) { view . getStyleClass ( ) . add ( "recurrence" ) ; //$NON-NLS-1$ } startTimeLabel . getStyleClass ( ) . setAll ( "start-time-label" , "default-style-entry-time-label" , calendar . getStyle ( ) + "-entry-time-label" ) ; titleLabel . getStyleClass ( ) . setAll ( "title-label" , "default-style-entry-title-label" , calendar . getStyle ( ) + "-entry-title-label" ) ; } | This methods updates the styles of the node according to the entry settings . | 262 | 14 |
26,247 | protected Label createTitleLabel ( ) { Label label = new Label ( ) ; label . setWrapText ( true ) ; label . setMinSize ( 0 , 0 ) ; return label ; } | The label used to show the title . | 41 | 8 |
26,248 | protected void updateLabels ( ) { Entry < ? > entry = getEntry ( ) ; startTimeLabel . setText ( formatTime ( entry . getStartTime ( ) ) ) ; titleLabel . setText ( formatTitle ( entry . getTitle ( ) ) ) ; } | This method will be called if the labels need to be updated . | 58 | 13 |
26,249 | static void rollToNextWeekStart ( DTBuilder builder , Weekday wkst ) { DateValue bd = builder . toDate ( ) ; builder . day += ( 7 - ( ( 7 + ( Weekday . valueOf ( bd ) . javaDayNum - wkst . javaDayNum ) ) % 7 ) ) % 7 ; builder . normalize ( ) ; } | advances builder to the earliest day on or after builder that falls on wkst . | 81 | 18 |
26,250 | static DateValue nextWeekStart ( DateValue d , Weekday wkst ) { DTBuilder builder = new DTBuilder ( d ) ; builder . day += ( 7 - ( ( 7 + ( Weekday . valueOf ( d ) . javaDayNum - wkst . javaDayNum ) ) % 7 ) ) % 7 ; return builder . toDate ( ) ; } | the earliest day on or after d that falls on wkst . | 79 | 14 |
26,251 | static int [ ] uniquify ( int [ ] ints , int start , int end ) { IntSet iset = new IntSet ( ) ; for ( int i = end ; -- i >= start ; ) { iset . add ( ints [ i ] ) ; } return iset . toIntArray ( ) ; } | returns a sorted unique copy of ints . | 70 | 10 |
26,252 | static int dayNumToDate ( Weekday dow0 , int nDays , int weekNum , Weekday dow , int d0 , int nDaysInMonth ) { // if dow is wednesday, then this is the date of the first wednesday int firstDateOfGivenDow = 1 + ( ( 7 + dow . javaDayNum - dow0 . javaDayNum ) % 7 ) ; int date ; if ( weekNum > 0 ) { date = ( ( weekNum - 1 ) * 7 ) + firstDateOfGivenDow - d0 ; } else { // count weeks from end of month // calculate last day of the given dow. // Since nDays <= 366, this should be > nDays int lastDateOfGivenDow = firstDateOfGivenDow + ( 7 * 54 ) ; lastDateOfGivenDow -= 7 * ( ( lastDateOfGivenDow - nDays + 6 ) / 7 ) ; date = lastDateOfGivenDow + 7 * ( weekNum + 1 ) - d0 ; } if ( date <= 0 || date > nDaysInMonth ) { return 0 ; } return date ; } | given a weekday number such as - 1SU returns the day of the month that it falls on . The weekday number may be refer to a week in the current month in some contexts or a week in the current year in other contexts . | 241 | 47 |
26,253 | static int invertWeekdayNum ( WeekdayNum weekdayNum , Weekday dow0 , int nDays ) { assert weekdayNum . num < 0 ; // how many are there of that week? return countInPeriod ( weekdayNum . wday , dow0 , nDays ) + weekdayNum . num + 1 ; } | Compute an absolute week number given a relative one . The day number - 1SU refers to the last Sunday so if there are 5 Sundays in a period that starts on dow0 with nDays then - 1SU is 5SU . Depending on where its used it may refer to the last Sunday of the year or of the month . | 68 | 67 |
26,254 | static int countInPeriod ( Weekday dow , Weekday dow0 , int nDays ) { // Two cases // (1a) dow >= dow0: count === (nDays - (dow - dow0)) / 7 // (1b) dow < dow0: count === (nDays - (7 - dow0 - dow)) / 7 if ( dow . javaDayNum >= dow0 . javaDayNum ) { return 1 + ( ( nDays - ( dow . javaDayNum - dow0 . javaDayNum ) - 1 ) / 7 ) ; } else { return 1 + ( ( nDays - ( 7 - ( dow0 . javaDayNum - dow . javaDayNum ) ) - 1 ) / 7 ) ; } } | the number of occurences of dow in a period nDays long where the first day of the period has day of week dow0 . | 158 | 28 |
26,255 | public List < Slice > getUnloadedSlices ( List < Slice > slices ) { List < Slice > unloadedSlices = new ArrayList <> ( slices ) ; unloadedSlices . removeAll ( loadedSlices ) ; unloadedSlices . removeAll ( inProgressSlices ) ; return unloadedSlices ; } | Takes the list of slices and removes those already loaded . | 76 | 12 |
26,256 | public static RecurrenceIterator createRecurrenceIterator ( String rdata , DateValue dtStart , TimeZone tzid , boolean strict ) throws ParseException { return createRecurrenceIterable ( rdata , dtStart , tzid , strict ) . iterator ( ) ; } | given a block of RRULE EXRULE RDATE and EXDATE content lines parse them into a single recurrence iterator . | 60 | 26 |
26,257 | public static RecurrenceIterator createRecurrenceIterator ( RDateList rdates ) { DateValue [ ] dates = rdates . getDatesUtc ( ) ; Arrays . sort ( dates ) ; int k = 0 ; for ( int i = 1 ; i < dates . length ; ++ i ) { if ( ! dates [ i ] . equals ( dates [ k ] ) ) { dates [ ++ k ] = dates [ i ] ; } } if ( ++ k < dates . length ) { DateValue [ ] uniqueDates = new DateValue [ k ] ; System . arraycopy ( dates , 0 , uniqueDates , 0 , k ) ; dates = uniqueDates ; } return new RDateIteratorImpl ( dates ) ; } | create a recurrence iterator from an rdate or exdate list . | 155 | 14 |
26,258 | public static RecurrenceIterator join ( RecurrenceIterator a , RecurrenceIterator ... b ) { List < RecurrenceIterator > incl = new ArrayList < RecurrenceIterator > ( ) ; incl . add ( a ) ; incl . addAll ( Arrays . asList ( b ) ) ; return new CompoundIteratorImpl ( incl , Collections . < RecurrenceIterator > emptyList ( ) ) ; } | a recurrence iterator that returns the union of the given recurrence iterators . | 83 | 16 |
26,259 | private static int [ ] filterBySetPos ( int [ ] members , int [ ] bySetPos ) { members = Util . uniquify ( members ) ; IntSet iset = new IntSet ( ) ; for ( int pos : bySetPos ) { if ( pos == 0 ) { continue ; } if ( pos < 0 ) { pos += members . length ; } else { -- pos ; // Zero-index. } if ( pos >= 0 && pos < members . length ) { iset . add ( members [ pos ] ) ; } } return iset . toIntArray ( ) ; } | Given an array like BYMONTH = 2 3 4 5 and a set pos like BYSETPOS = 1 - 1 reduce both clauses to a single one BYMONTH = 2 5 in the preceding . | 128 | 41 |
26,260 | public static DateIterator createDateIterator ( String rdata , Date start , TimeZone tzid , boolean strict ) throws ParseException { return new RecurrenceIteratorWrapper ( RecurrenceIteratorFactory . createRecurrenceIterator ( rdata , dateToDateValue ( start , true ) , tzid , strict ) ) ; } | given a block of RRULE EXRULE RDATE and EXDATE content lines parse them into a single date iterator . | 69 | 25 |
26,261 | public static DateIterable createDateIterable ( String rdata , Date start , TimeZone tzid , boolean strict ) throws ParseException { return new RecurrenceIterableWrapper ( RecurrenceIteratorFactory . createRecurrenceIterable ( rdata , dateToDateValue ( start , true ) , tzid , strict ) ) ; } | given a block of RRULE EXRULE RDATE and EXDATE content lines parse them into a single date iterable . | 73 | 26 |
26,262 | public final GoogleEntry createEntry ( ZonedDateTime start , boolean fullDay ) { GoogleEntry entry = new GoogleEntry ( ) ; entry . setTitle ( "New Entry " + generateEntryConsecutive ( ) ) ; entry . setInterval ( new Interval ( start . toLocalDate ( ) , start . toLocalTime ( ) , start . toLocalDate ( ) , start . toLocalTime ( ) . plusHours ( 1 ) ) ) ; entry . setFullDay ( fullDay ) ; entry . setAttendeesCanInviteOthers ( true ) ; entry . setAttendeesCanSeeOthers ( true ) ; return entry ; } | Creates a new google entry by using the given parameters this assigns a default name by using a consecutive number . The entry is of course associated to this calendar but it is not sent to google for storing . | 138 | 41 |
26,263 | static Predicate < DateValue > countCondition ( final int count ) { return new Predicate < DateValue > ( ) { int count_ = count ; public boolean apply ( DateValue value ) { return -- count_ >= 0 ; } @ Override public String toString ( ) { return "CountCondition:" + count_ ; } } ; } | constructs a condition that fails after passing count dates . | 72 | 11 |
26,264 | static Predicate < DateValue > untilCondition ( final DateValue until ) { return new Predicate < DateValue > ( ) { public boolean apply ( DateValue date ) { return date . compareTo ( until ) <= 0 ; } @ Override public String toString ( ) { return "UntilCondition:" + until ; } } ; } | constructs a condition that passes for every date on or before until . | 70 | 14 |
26,265 | public static PeriodValue createFromDuration ( DateValue start , DateValue dur ) { DateValue end = TimeUtils . add ( start , dur ) ; if ( end instanceof TimeValue && ! ( start instanceof TimeValue ) ) { start = TimeUtils . dayStart ( start ) ; } return new PeriodValueImpl ( start , end ) ; } | returns a period with the given start date and duration . | 75 | 12 |
26,266 | public boolean intersects ( PeriodValue pv ) { DateValue sa = this . start , ea = this . end , sb = pv . start ( ) , eb = pv . end ( ) ; return sa . compareTo ( eb ) < 0 && sb . compareTo ( ea ) < 0 ; } | true iff this period overlaps the given period . | 69 | 11 |
26,267 | public static LocalDate adjustToFirstDayOfWeek ( LocalDate date , DayOfWeek firstDayOfWeek ) { LocalDate newDate = date . with ( DAY_OF_WEEK , firstDayOfWeek . getValue ( ) ) ; if ( newDate . isAfter ( date ) ) { newDate = newDate . minusWeeks ( 1 ) ; } return newDate ; } | Adjusts the given date to a new date that marks the beginning of the week where the given date is located . If Monday is the first day of the week and the given date is a Wednesday then this method will return a date that is two days earlier than the given date . | 82 | 56 |
26,268 | public static LocalDate adjustToLastDayOfWeek ( LocalDate date , DayOfWeek firstDayOfWeek ) { LocalDate startOfWeek = adjustToFirstDayOfWeek ( date , firstDayOfWeek ) ; return startOfWeek . plusDays ( 6 ) ; } | Adjusts the given date to a new date that marks the end of the week where the given date is located . If Monday is the first day of the week and the given date is a Wednesday then this method will return a date that is four days later than the given date . This method calculates the first day of the week and then adds six days to it . | 57 | 73 |
26,269 | public Instant adjustTime ( Instant instant , ZoneId zoneId , boolean roundUp , DayOfWeek firstDayOfWeek ) { requireNonNull ( instant ) ; requireNonNull ( zoneId ) ; requireNonNull ( firstDayOfWeek ) ; ZonedDateTime zonedDateTime = ZonedDateTime . ofInstant ( instant , zoneId ) ; if ( roundUp ) { zonedDateTime = zonedDateTime . plus ( getAmount ( ) , getUnit ( ) ) ; } zonedDateTime = Util . truncate ( zonedDateTime , getUnit ( ) , getAmount ( ) , firstDayOfWeek ) ; return Instant . from ( zonedDateTime ) ; } | Adjusts the given instant either rounding it up or down . | 148 | 12 |
26,270 | public final ReadOnlyObjectProperty < T > dateControlProperty ( ) { if ( dateControl == null ) { dateControl = new ReadOnlyObjectWrapper <> ( this , "dateControl" , _dateControl ) ; //$NON-NLS-1$ } return dateControl . getReadOnlyProperty ( ) ; } | The date control where the entry view is shown . | 70 | 10 |
26,271 | public final boolean isReadOnly ( ) { Entry < ? > entry = getEntry ( ) ; Calendar calendar = entry . getCalendar ( ) ; if ( calendar != null ) { return calendar . isReadOnly ( ) ; } return false ; } | Convenience method to determine whether the entry belongs to a calendar that is read - only . | 52 | 19 |
26,272 | public static DateValue parseDateValue ( String s , TimeZone tzid ) throws ParseException { Matcher m = DATE_VALUE . matcher ( s ) ; if ( ! m . matches ( ) ) { throw new ParseException ( s , 0 ) ; } int year = Integer . parseInt ( m . group ( 1 ) ) , month = Integer . parseInt ( m . group ( 2 ) ) , day = Integer . parseInt ( m . group ( 3 ) ) ; if ( null != m . group ( 4 ) ) { int hour = Integer . parseInt ( m . group ( 4 ) ) , minute = Integer . parseInt ( m . group ( 5 ) ) , second = Integer . parseInt ( m . group ( 6 ) ) ; boolean utc = null != m . group ( 7 ) ; DateValue dv = new DTBuilder ( year , month , day , hour , minute , second ) . toDateTime ( ) ; if ( ! utc && null != tzid ) { dv = TimeUtils . toUtc ( dv , tzid ) ; } return dv ; } else { return new DTBuilder ( year , month , day ) . toDate ( ) ; } } | parses a date of the form yyyymmdd or yyyymmdd T hhMMss converting from the given timezone to UTC . | 263 | 31 |
26,273 | public void insertCalendar ( GoogleCalendar calendar ) throws IOException { com . google . api . services . calendar . model . Calendar cal ; cal = converter . convert ( calendar , com . google . api . services . calendar . model . Calendar . class ) ; cal = dao . calendars ( ) . insert ( cal ) . execute ( ) ; calendar . setId ( cal . getId ( ) ) ; } | Inserts a calendar into the google calendar . | 87 | 9 |
26,274 | public void updateCalendar ( GoogleCalendar calendar ) throws IOException { CalendarListEntry calendarListEntry = converter . convert ( calendar , CalendarListEntry . class ) ; dao . calendarList ( ) . update ( calendarListEntry . getId ( ) , calendarListEntry ) . execute ( ) ; } | Saves the updates done on the calendar into google calendar api . | 64 | 13 |
26,275 | public void deleteCalendar ( GoogleCalendar calendar ) throws IOException { dao . calendars ( ) . delete ( calendar . getId ( ) ) . execute ( ) ; } | Performs an immediate delete request on the google calendar api . | 37 | 12 |
26,276 | public GoogleEntry insertEntry ( GoogleEntry entry , GoogleCalendar calendar ) throws IOException { Event event = converter . convert ( entry , Event . class ) ; event = dao . events ( ) . insert ( calendar . getId ( ) , event ) . execute ( ) ; entry . setId ( event . getId ( ) ) ; entry . setUserObject ( event ) ; return entry ; } | Performs an immediate insert operation on google server by sending the information provided by the given google entry . The entry is associated to this calendar . | 84 | 28 |
26,277 | public GoogleEntry updateEntry ( GoogleEntry entry ) throws IOException { GoogleCalendar calendar = ( GoogleCalendar ) entry . getCalendar ( ) ; Event event = converter . convert ( entry , Event . class ) ; dao . events ( ) . update ( calendar . getId ( ) , event . getId ( ) , event ) . execute ( ) ; return entry ; } | Performs an immediate update operation on google server by sending the information stored by the given google entry . | 80 | 20 |
26,278 | public void deleteEntry ( GoogleEntry entry , GoogleCalendar calendar ) throws IOException { dao . events ( ) . delete ( calendar . getId ( ) , entry . getId ( ) ) . execute ( ) ; } | Sends a delete request to the google server for the given entry . | 47 | 14 |
26,279 | public GoogleEntry moveEntry ( GoogleEntry entry , GoogleCalendar from , GoogleCalendar to ) throws IOException { dao . events ( ) . move ( from . getId ( ) , entry . getId ( ) , to . getId ( ) ) . execute ( ) ; return entry ; } | Moves an entry from one calendar to another . | 63 | 10 |
26,280 | public List < GoogleCalendar > getCalendars ( ) throws IOException { List < CalendarListEntry > calendarListEntries = dao . calendarList ( ) . list ( ) . execute ( ) . getItems ( ) ; List < GoogleCalendar > calendars = new ArrayList <> ( ) ; if ( calendarListEntries != null && ! calendarListEntries . isEmpty ( ) ) { for ( int i = 0 ; i < calendarListEntries . size ( ) ; i ++ ) { CalendarListEntry calendarListEntry = calendarListEntries . get ( i ) ; GoogleCalendar calendar = converter . convert ( calendarListEntry , GoogleCalendar . class ) ; calendar . setStyle ( com . calendarfx . model . Calendar . Style . getStyle ( i ) ) ; calendars . add ( calendar ) ; } } return calendars ; } | Gets the list of all calendars available in the account . | 180 | 12 |
26,281 | public List < GoogleEntry > getEntries ( GoogleCalendar calendar , LocalDate startDate , LocalDate endDate , ZoneId zoneId ) throws IOException { if ( ! calendar . existsInGoogle ( ) ) { return new ArrayList <> ( 0 ) ; } ZonedDateTime st = ZonedDateTime . of ( startDate , LocalTime . MIN , zoneId ) ; ZonedDateTime et = ZonedDateTime . of ( endDate , LocalTime . MAX , zoneId ) ; String calendarId = URLDecoder . decode ( calendar . getId ( ) , "UTF-8" ) ; List < Event > events = dao . events ( ) . list ( calendarId ) . setTimeMin ( new DateTime ( Date . from ( st . toInstant ( ) ) ) ) . setTimeMax ( new DateTime ( Date . from ( et . toInstant ( ) ) ) ) . setSingleEvents ( false ) . setShowDeleted ( false ) . execute ( ) . getItems ( ) ; return toGoogleEntries ( events ) ; } | Gets a list of entries belonging to the given calendar defined between the given range of time . Recurring events are not expanded always recurrence is handled manually within the framework . | 228 | 35 |
26,282 | public List < GoogleEntry > getEntries ( GoogleCalendar calendar , String searchText ) throws IOException { if ( ! calendar . existsInGoogle ( ) ) { return new ArrayList <> ( 0 ) ; } String calendarId = URLDecoder . decode ( calendar . getId ( ) , "UTF-8" ) ; List < Event > events = dao . events ( ) . list ( calendarId ) . setQ ( searchText ) . setSingleEvents ( false ) . setShowDeleted ( false ) . execute ( ) . getItems ( ) ; return toGoogleEntries ( events ) ; } | Gets a list of entries that matches the given text . Recurring events are not expanded always recurrence is handled manually within the framework . | 130 | 28 |
26,283 | public final GoogleCalendar createCalendar ( String name , Calendar . Style style ) { GoogleCalendar calendar = new GoogleCalendar ( ) ; calendar . setName ( name ) ; calendar . setStyle ( style ) ; return calendar ; } | Creates one single calendar with the given name and style . | 50 | 12 |
26,284 | public GoogleCalendar getPrimaryCalendar ( ) { return ( GoogleCalendar ) getCalendars ( ) . stream ( ) . filter ( calendar -> ( ( GoogleCalendar ) calendar ) . isPrimary ( ) ) . findFirst ( ) . orElse ( null ) ; } | Gets the calendar marked as primary calendar for the google account . | 58 | 13 |
26,285 | public List < GoogleCalendar > getGoogleCalendars ( ) { List < GoogleCalendar > googleCalendars = new ArrayList <> ( ) ; for ( Calendar calendar : getCalendars ( ) ) { if ( ! ( calendar instanceof GoogleCalendar ) ) { continue ; } googleCalendars . add ( ( GoogleCalendar ) calendar ) ; } return googleCalendars ; } | Gets all the google calendars hold by this source . | 81 | 11 |
26,286 | @ SafeVarargs public final void removeCalendarListeners ( ListChangeListener < Calendar > ... listeners ) { if ( listeners != null ) { for ( ListChangeListener < Calendar > listener : listeners ) { getCalendars ( ) . removeListener ( listener ) ; } } } | Removes the listener from the ones being notified . | 58 | 10 |
26,287 | public final Map < LocalDate , List < Entry < ? > > > findEntries ( LocalDate startDate , LocalDate endDate , ZoneId zoneId ) { fireEvents = false ; Map < LocalDate , List < Entry < ? > > > result ; try { result = doGetEntries ( startDate , endDate , zoneId ) ; } finally { fireEvents = true ; } return result ; } | Queries the calendar for all entries within the time interval defined by the start date and end date . | 87 | 20 |
26,288 | public final void addEventHandler ( EventHandler < CalendarEvent > l ) { if ( l != null ) { if ( MODEL . isLoggable ( FINER ) ) { MODEL . finer ( getName ( ) + ": adding event handler: " + l ) ; //$NON-NLS-1$ } eventHandlers . add ( l ) ; } } | Adds an event handler for calendar events . Handlers will be called when an entry gets added removed changes etc . | 81 | 22 |
26,289 | public final void removeEventHandler ( EventHandler < CalendarEvent > l ) { if ( l != null ) { if ( MODEL . isLoggable ( FINER ) ) { MODEL . finer ( getName ( ) + ": removing event handler: " + l ) ; //$NON-NLS-1$ } eventHandlers . remove ( l ) ; } } | Removes an event handler from the calendar . | 81 | 9 |
26,290 | public final void fireEvent ( CalendarEvent evt ) { if ( fireEvents && ! batchUpdates ) { if ( MODEL . isLoggable ( FINER ) ) { MODEL . finer ( getName ( ) + ": fireing event: " + evt ) ; //$NON-NLS-1$ } requireNonNull ( evt ) ; Event . fireEvent ( this , evt ) ; } } | Fires the given calendar event to all event handlers currently registered with this calendar . | 92 | 16 |
26,291 | public static List < Slice > split ( LocalDate start , LocalDate end ) { Objects . requireNonNull ( start ) ; Objects . requireNonNull ( end ) ; Preconditions . checkArgument ( ! start . isAfter ( end ) ) ; List < Slice > slices = Lists . newArrayList ( ) ; LocalDate startOfMonth = start . withDayOfMonth ( 1 ) ; LocalDate endOfMonth = YearMonth . from ( end ) . atEndOfMonth ( ) ; do { slices . add ( new Slice ( startOfMonth , YearMonth . from ( startOfMonth ) . atEndOfMonth ( ) ) ) ; startOfMonth = startOfMonth . plus ( 1 , ChronoUnit . MONTHS ) ; } while ( startOfMonth . isBefore ( endOfMonth ) || startOfMonth . isEqual ( endOfMonth ) ) ; return slices ; } | Splits the given period into multiple slices of one month long . | 193 | 13 |
26,292 | public final boolean contains ( E entry ) { TreeEntry < E > e = getEntry ( entry ) ; return e != null ; } | Method to determine if the interval tree contains the given entry . | 28 | 12 |
26,293 | private TreeEntry < E > getEntry ( Entry < ? > entry ) { TreeEntry < E > t = root ; while ( t != null ) { int cmp = compareLongs ( getLow ( entry ) , t . low ) ; if ( cmp == 0 ) cmp = compareLongs ( getHigh ( entry ) , t . high ) ; if ( cmp == 0 ) cmp = entry . hashCode ( ) - t . value . hashCode ( ) ; if ( cmp < 0 ) { t = t . left ; } else if ( cmp > 0 ) { t = t . right ; } else { return t ; } } return null ; } | Method to find entry by period . Period start period end and object key are used to identify each entry . | 144 | 21 |
26,294 | private void setDateControl ( DateControl control ) { requireNonNull ( control ) ; control . addEventFilter ( RequestEvent . REQUEST , evt -> addEvent ( evt , LogEntryType . REQUEST_EVENT ) ) ; control . addEventFilter ( LoadEvent . LOAD , evt -> addEvent ( evt , LogEntryType . LOAD_EVENT ) ) ; // listen to calendars for ( Calendar calendar : control . getCalendars ( ) ) { calendar . addEventHandler ( calendarListener ) ; } ListChangeListener < ? super Calendar > l = change -> { while ( change . next ( ) ) { if ( change . wasAdded ( ) ) { for ( Calendar c : change . getAddedSubList ( ) ) { c . addEventHandler ( calendarListener ) ; } } else if ( change . wasRemoved ( ) ) { for ( Calendar c : change . getRemoved ( ) ) { c . removeEventHandler ( calendarListener ) ; } } } } ; control . getCalendars ( ) . addListener ( l ) ; Bindings . bindBidirectional ( datePicker . valueProperty ( ) , control . dateProperty ( ) ) ; Bindings . bindBidirectional ( todayPicker . valueProperty ( ) , control . todayProperty ( ) ) ; Bindings . bindBidirectional ( timeField . valueProperty ( ) , control . timeProperty ( ) ) ; timeField . setDisable ( false ) ; } | Sets the control that will be monitored by the developer console . | 312 | 13 |
26,295 | public void setDayDateTimeFormatter ( DateTimeFormatter formatter ) { if ( getFormatterMap ( ) . get ( ViewType . DAY_VIEW ) == null ) { getFormatterMap ( ) . put ( ViewType . DAY_VIEW , formatter ) ; } else { getFormatterMap ( ) . replace ( ViewType . DAY_VIEW , formatter ) ; } } | Sets the DateTimeFormatter on the Day Label located in the day page . Notice that this is also affecting the page that is going to be printed . | 84 | 32 |
26,296 | public void setWeekDateTimeFormatter ( DateTimeFormatter formatter ) { if ( getFormatterMap ( ) . get ( ViewType . WEEK_VIEW ) == null ) { getFormatterMap ( ) . put ( ViewType . WEEK_VIEW , formatter ) ; } else { getFormatterMap ( ) . replace ( ViewType . WEEK_VIEW , formatter ) ; } } | Sets the DateTimeFormatter on the Week Label located in the week page . Notice that this is also affecting the page that is going to be printed . | 84 | 32 |
26,297 | public void setMonthDateTimeFormatter ( DateTimeFormatter formatter ) { if ( getFormatterMap ( ) . get ( ViewType . MONTH_VIEW ) == null ) { getFormatterMap ( ) . put ( ViewType . MONTH_VIEW , formatter ) ; } else { getFormatterMap ( ) . replace ( ViewType . MONTH_VIEW , formatter ) ; } } | Sets the DateTimeFormatter on the Month Label located in the month page . Notice that this is also affecting the page that is going to be printed . | 87 | 32 |
26,298 | private void removeDataBindings ( ) { Bindings . unbindContent ( detailedDayView . getCalendarSources ( ) , getCalendarSources ( ) ) ; Bindings . unbindContentBidirectional ( detailedDayView . getCalendarVisibilityMap ( ) , getCalendarVisibilityMap ( ) ) ; Bindings . unbindContent ( detailedWeekView . getCalendarSources ( ) , getCalendarSources ( ) ) ; Bindings . unbindContentBidirectional ( detailedWeekView . getCalendarVisibilityMap ( ) , getCalendarVisibilityMap ( ) ) ; Bindings . unbindContent ( monthView . getCalendarSources ( ) , getCalendarSources ( ) ) ; Bindings . unbindContentBidirectional ( monthView . getCalendarVisibilityMap ( ) , getCalendarVisibilityMap ( ) ) ; } | Removes all bindings related with the calendar sources and visibility map . | 188 | 13 |
26,299 | private DetailedDayView createDetailedDayView ( ) { DetailedDayView newDetailedDayView = new DetailedDayView ( ) ; newDetailedDayView . setShowScrollBar ( false ) ; newDetailedDayView . setShowToday ( false ) ; newDetailedDayView . setEnableCurrentTimeMarker ( false ) ; newDetailedDayView . weekFieldsProperty ( ) . bind ( weekFieldsProperty ( ) ) ; newDetailedDayView . showAllDayViewProperty ( ) . bind ( showAllDayEntriesProperty ( ) ) ; newDetailedDayView . showAgendaViewProperty ( ) . bind ( showEntryDetailsProperty ( ) ) ; newDetailedDayView . layoutProperty ( ) . bind ( layoutProperty ( ) ) ; newDetailedDayView . dateProperty ( ) . bind ( pageStartDateProperty ( ) ) ; newDetailedDayView . addEventFilter ( MouseEvent . ANY , weakMouseHandler ) ; configureDetailedDayView ( newDetailedDayView , true ) ; return newDetailedDayView ; } | Default configuration for Detailed Day view in the preview Pane . | 216 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.