idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
27,600 | public OptionalDouble average ( ) { long count = 0 ; double sum = 0d ; while ( iterator . hasNext ( ) ) { sum += iterator . nextDouble ( ) ; count ++ ; } if ( count == 0 ) return OptionalDouble . empty ( ) ; return OptionalDouble . of ( sum / ( double ) count ) ; } | Returns the average of elements in this stream . |
27,601 | public void close ( ) { if ( params != null && params . closeHandler != null ) { params . closeHandler . run ( ) ; params . closeHandler = null ; } } | Causes close handler to be invoked if it exists . Since most of the stream providers are lists or arrays it is not necessary to close the stream . |
27,602 | public static IntStream of ( final int ... values ) { Objects . requireNonNull ( values ) ; if ( values . length == 0 ) { return IntStream . empty ( ) ; } return new IntStream ( new IntArray ( values ) ) ; } | Returns stream whose elements are the specified values . |
27,603 | public static IntStream concat ( final IntStream a , final IntStream b ) { Objects . requireNonNull ( a ) ; Objects . requireNonNull ( b ) ; IntStream result = new IntStream ( new IntConcat ( a . iterator , b . iterator ) ) ; return result . onClose ( Compose . closeables ( a , b ) ) ; } | Creates a lazily concatenated stream whose elements are all the elements of the first stream followed by all the elements of the second stream . |
27,604 | public < R > R custom ( final Function < IntStream , R > function ) { Objects . requireNonNull ( function ) ; return function . apply ( this ) ; } | Applies custom operator on stream . |
27,605 | public IntStream filterNot ( final IntPredicate predicate ) { return filter ( IntPredicate . Util . negate ( predicate ) ) ; } | Returns a stream consisting of the elements of this stream that don t match the given predicate . |
27,606 | public IntStream peek ( final IntConsumer action ) { return new IntStream ( params , new IntPeek ( iterator , action ) ) ; } | Returns a stream consisting of the elements of this stream additionally performing the provided action on each element as elements are consumed from the resulting stream . Handy method for debugging purposes . |
27,607 | public static < F , S , R > Stream < R > zip ( final Iterator < ? extends F > iterator1 , final Iterator < ? extends S > iterator2 , final BiFunction < ? super F , ? super S , ? extends R > combiner ) { Objects . requireNonNull ( iterator1 ) ; Objects . requireNonNull ( iterator2 ) ; return new Stream < R > ( new ObjZip < F , S , R > ( iterator1 , iterator2 , combiner ) ) ; } | Combines two iterators to a stream by applying specified combiner function to each element at same position . |
27,608 | public Stream < T > dropWhile ( final Predicate < ? super T > predicate ) { return new Stream < T > ( params , new ObjDropWhile < T > ( iterator , predicate ) ) ; } | Drops elements while the predicate is true then returns the rest . |
27,609 | public void forEach ( final Consumer < ? super T > action ) { while ( iterator . hasNext ( ) ) { action . accept ( iterator . next ( ) ) ; } } | Performs the given action on each element . |
27,610 | public Object [ ] toArray ( ) { return toArray ( new IntFunction < Object [ ] > ( ) { public Object [ ] apply ( int value ) { return new Object [ value ] ; } } ) ; } | Collects elements to an array . |
27,611 | private static int [ ] getHijrahDateInfo ( long gregorianDays ) { int era , year , month , date , dayOfWeek , dayOfYear ; int cycleNumber , yearInCycle , dayOfCycle ; long epochDay = gregorianDays - HIJRAH_JAN_1_1_GREGORIAN_DAY ; if ( epochDay >= 0 ) { cycleNumber = getCycleNumber ( epochDay ) ; dayOfCycle = getDayOfCycle ( epochDay , cycleNumber ) ; yearInCycle = getYearInCycle ( cycleNumber , dayOfCycle ) ; dayOfYear = getDayOfYear ( cycleNumber , dayOfCycle , yearInCycle ) ; year = cycleNumber * 30 + yearInCycle + 1 ; month = getMonthOfYear ( dayOfYear , year ) ; date = getDayOfMonth ( dayOfYear , month , year ) ; ++ date ; era = HijrahEra . AH . getValue ( ) ; } else { cycleNumber = ( int ) epochDay / 10631 ; dayOfCycle = ( int ) epochDay % 10631 ; if ( dayOfCycle == 0 ) { dayOfCycle = - 10631 ; cycleNumber ++ ; } yearInCycle = getYearInCycle ( cycleNumber , dayOfCycle ) ; dayOfYear = getDayOfYear ( cycleNumber , dayOfCycle , yearInCycle ) ; year = cycleNumber * 30 - yearInCycle ; year = 1 - year ; dayOfYear = ( isLeapYear ( year ) ? ( dayOfYear + 355 ) : ( dayOfYear + 354 ) ) ; month = getMonthOfYear ( dayOfYear , year ) ; date = getDayOfMonth ( dayOfYear , month , year ) ; ++ date ; era = HijrahEra . BEFORE_AH . getValue ( ) ; } dayOfWeek = ( int ) ( ( epochDay + 5 ) % 7 ) ; dayOfWeek += ( dayOfWeek <= 0 ) ? 7 : 0 ; int dateInfo [ ] = new int [ 6 ] ; dateInfo [ 0 ] = era ; dateInfo [ 1 ] = year ; dateInfo [ 2 ] = month + 1 ; dateInfo [ 3 ] = date ; dateInfo [ 4 ] = dayOfYear + 1 ; dateInfo [ 5 ] = dayOfWeek ; return dateInfo ; } | Returns the int array containing the following field from the julian day . |
27,612 | private static long getGregorianEpochDay ( int prolepticYear , int monthOfYear , int dayOfMonth ) { long day = yearToGregorianEpochDay ( prolepticYear ) ; day += getMonthDays ( monthOfYear - 1 , prolepticYear ) ; day += dayOfMonth ; return day ; } | Return Gregorian epoch day from Hijrah year month and day . |
27,613 | private static long yearToGregorianEpochDay ( int prolepticYear ) { int cycleNumber = ( prolepticYear - 1 ) / 30 ; int yearInCycle = ( prolepticYear - 1 ) % 30 ; int dayInCycle = getAdjustedCycle ( cycleNumber ) [ Math . abs ( yearInCycle ) ] . intValue ( ) ; if ( yearInCycle < 0 ) { dayInCycle = - dayInCycle ; } Long cycleDays ; try { cycleDays = ADJUSTED_CYCLES [ cycleNumber ] ; } catch ( ArrayIndexOutOfBoundsException e ) { cycleDays = null ; } if ( cycleDays == null ) { cycleDays = Long . valueOf ( cycleNumber * 10631 ) ; } return ( cycleDays . longValue ( ) + dayInCycle + HIJRAH_JAN_1_1_GREGORIAN_DAY - 1 ) ; } | Returns the Gregorian epoch day from the proleptic year |
27,614 | private static int getCycleNumber ( long epochDay ) { Long [ ] days = ADJUSTED_CYCLES ; int cycleNumber ; try { for ( int i = 0 ; i < days . length ; i ++ ) { if ( epochDay < days [ i ] . longValue ( ) ) { return i - 1 ; } } cycleNumber = ( int ) epochDay / 10631 ; } catch ( ArrayIndexOutOfBoundsException e ) { cycleNumber = ( int ) epochDay / 10631 ; } return cycleNumber ; } | Returns the 30 year cycle number from the epoch day . |
27,615 | private static int getDayOfCycle ( long epochDay , int cycleNumber ) { Long day ; try { day = ADJUSTED_CYCLES [ cycleNumber ] ; } catch ( ArrayIndexOutOfBoundsException e ) { day = null ; } if ( day == null ) { day = Long . valueOf ( cycleNumber * 10631 ) ; } return ( int ) ( epochDay - day . longValue ( ) ) ; } | Returns day of cycle from the epoch day and cycle number . |
27,616 | private static int getYearInCycle ( int cycleNumber , long dayOfCycle ) { Integer [ ] cycles = getAdjustedCycle ( cycleNumber ) ; if ( dayOfCycle == 0 ) { return 0 ; } if ( dayOfCycle > 0 ) { for ( int i = 0 ; i < cycles . length ; i ++ ) { if ( dayOfCycle < cycles [ i ] . intValue ( ) ) { return i - 1 ; } } return 29 ; } else { dayOfCycle = - dayOfCycle ; for ( int i = 0 ; i < cycles . length ; i ++ ) { if ( dayOfCycle <= cycles [ i ] . intValue ( ) ) { return i - 1 ; } } return 29 ; } } | Returns the year in cycle from the cycle number and day of cycle . |
27,617 | private static Integer [ ] getAdjustedCycle ( int cycleNumber ) { Integer [ ] cycles ; try { cycles = ADJUSTED_CYCLE_YEARS . get ( Integer . valueOf ( cycleNumber ) ) ; } catch ( ArrayIndexOutOfBoundsException e ) { cycles = null ; } if ( cycles == null ) { cycles = DEFAULT_CYCLE_YEARS ; } return cycles ; } | Returns adjusted 30 year cycle startind day as Integer array from the cycle number specified . |
27,618 | private static Integer [ ] getAdjustedMonthDays ( int year ) { Integer [ ] newMonths ; try { newMonths = ADJUSTED_MONTH_DAYS . get ( Integer . valueOf ( year ) ) ; } catch ( ArrayIndexOutOfBoundsException e ) { newMonths = null ; } if ( newMonths == null ) { if ( isLeapYear ( year ) ) { newMonths = DEFAULT_LEAP_MONTH_DAYS ; } else { newMonths = DEFAULT_MONTH_DAYS ; } } return newMonths ; } | Returns adjusted month days as Integer array form the year specified . |
27,619 | private static Integer [ ] getAdjustedMonthLength ( int year ) { Integer [ ] newMonths ; try { newMonths = ADJUSTED_MONTH_LENGTHS . get ( Integer . valueOf ( year ) ) ; } catch ( ArrayIndexOutOfBoundsException e ) { newMonths = null ; } if ( newMonths == null ) { if ( isLeapYear ( year ) ) { newMonths = DEFAULT_LEAP_MONTH_LENGTHS ; } else { newMonths = DEFAULT_MONTH_LENGTHS ; } } return newMonths ; } | Returns adjusted month length as Integer array form the year specified . |
27,620 | private static int getDayOfYear ( int cycleNumber , int dayOfCycle , int yearInCycle ) { Integer [ ] cycles = getAdjustedCycle ( cycleNumber ) ; if ( dayOfCycle > 0 ) { return dayOfCycle - cycles [ yearInCycle ] . intValue ( ) ; } else { return cycles [ yearInCycle ] . intValue ( ) + dayOfCycle ; } } | Returns day - of - year . |
27,621 | private static int getMonthOfYear ( int dayOfYear , int year ) { Integer [ ] newMonths = getAdjustedMonthDays ( year ) ; if ( dayOfYear >= 0 ) { for ( int i = 0 ; i < newMonths . length ; i ++ ) { if ( dayOfYear < newMonths [ i ] . intValue ( ) ) { return i - 1 ; } } return 11 ; } else { dayOfYear = ( isLeapYear ( year ) ? ( dayOfYear + 355 ) : ( dayOfYear + 354 ) ) ; for ( int i = 0 ; i < newMonths . length ; i ++ ) { if ( dayOfYear < newMonths [ i ] . intValue ( ) ) { return i - 1 ; } } return 11 ; } } | Returns month - of - year . 0 - based . |
27,622 | private static int getDayOfMonth ( int dayOfYear , int month , int year ) { Integer [ ] newMonths = getAdjustedMonthDays ( year ) ; if ( dayOfYear >= 0 ) { if ( month > 0 ) { return dayOfYear - newMonths [ month ] . intValue ( ) ; } else { return dayOfYear ; } } else { dayOfYear = ( isLeapYear ( year ) ? ( dayOfYear + 355 ) : ( dayOfYear + 354 ) ) ; if ( month > 0 ) { return dayOfYear - newMonths [ month ] . intValue ( ) ; } else { return dayOfYear ; } } } | Returns day - of - month . |
27,623 | private static int getMonthDays ( int month , int year ) { Integer [ ] newMonths = getAdjustedMonthDays ( year ) ; return newMonths [ month ] . intValue ( ) ; } | Returns month days from the beginning of year . |
27,624 | static int getMonthLength ( int month , int year ) { Integer [ ] newMonths = getAdjustedMonthLength ( year ) ; return newMonths [ month ] . intValue ( ) ; } | Returns month length . |
27,625 | static int getYearLength ( int year ) { int cycleNumber = ( year - 1 ) / 30 ; Integer [ ] cycleYears ; try { cycleYears = ADJUSTED_CYCLE_YEARS . get ( cycleNumber ) ; } catch ( ArrayIndexOutOfBoundsException e ) { cycleYears = null ; } if ( cycleYears != null ) { int yearInCycle = ( year - 1 ) % 30 ; if ( yearInCycle == 29 ) { return ADJUSTED_CYCLES [ cycleNumber + 1 ] . intValue ( ) - ADJUSTED_CYCLES [ cycleNumber ] . intValue ( ) - cycleYears [ yearInCycle ] . intValue ( ) ; } return cycleYears [ yearInCycle + 1 ] . intValue ( ) - cycleYears [ yearInCycle ] . intValue ( ) ; } else { return isLeapYear ( year ) ? 355 : 354 ; } } | Returns year length . |
27,626 | private static void readDeviationConfig ( ) throws IOException , ParseException { InputStream is = getConfigFileInputStream ( ) ; if ( is != null ) { BufferedReader br = null ; try { br = new BufferedReader ( new InputStreamReader ( is ) ) ; String line = "" ; int num = 0 ; while ( ( line = br . readLine ( ) ) != null ) { num ++ ; line = line . trim ( ) ; parseLine ( line , num ) ; } } finally { if ( br != null ) { br . close ( ) ; } } } } | Read hijrah_deviation . cfg file . The config file contains the deviation data with following format . |
27,627 | private boolean load ( ClassLoader classLoader ) { boolean updated = false ; URL url = null ; try { Enumeration < URL > en = classLoader . getResources ( "org/threeten/bp/TZDB.dat" ) ; while ( en . hasMoreElements ( ) ) { url = en . nextElement ( ) ; updated |= load ( url ) ; } } catch ( Exception ex ) { throw new ZoneRulesException ( "Unable to load TZDB time-zone rules: " + url , ex ) ; } return updated ; } | Loads the rules . |
27,628 | private boolean load ( URL url ) throws ClassNotFoundException , IOException , ZoneRulesException { boolean updated = false ; if ( loadedUrls . add ( url . toExternalForm ( ) ) ) { InputStream in = null ; try { in = url . openStream ( ) ; updated |= load ( in ) ; } finally { if ( in != null ) { in . close ( ) ; } } } return updated ; } | Loads the rules from a URL often in a jar file . |
27,629 | static void initialize ( ) { if ( INITIALIZED . getAndSet ( true ) ) { throw new IllegalStateException ( "Already initialized" ) ; } INITIALIZER . compareAndSet ( null , new ServiceLoaderZoneRulesInitializer ( ) ) ; INITIALIZER . get ( ) . initializeProviders ( ) ; } | initialize the providers |
27,630 | private static void outputHelp ( ) { System . out . println ( "Usage: TzdbZoneRulesCompiler <options> <tzdb source filenames>" ) ; System . out . println ( "where options include:" ) ; System . out . println ( " -srcdir <directory> Where to find source directories (required)" ) ; System . out . println ( " -dstdir <directory> Where to output generated files (default srcdir)" ) ; System . out . println ( " -version <version> Specify the version, such as 2009a (optional)" ) ; System . out . println ( " -unpacked Generate dat files without jar files" ) ; System . out . println ( " -help Print this usage message" ) ; System . out . println ( " -verbose Output verbose information during compilation" ) ; System . out . println ( " There must be one directory for each version in srcdir" ) ; System . out . println ( " Each directory must have the name of the version, such as 2009a" ) ; System . out . println ( " Each directory must contain the unpacked tzdb files, such as asia or europe" ) ; System . out . println ( " Directories must match the regex [12][0-9][0-9][0-9][A-Za-z0-9._-]+" ) ; System . out . println ( " There will be one jar file for each version and one combined jar in dstdir" ) ; System . out . println ( " If the version is specified, only that version is processed" ) ; } | Output usage text for the command line . |
27,631 | private static void outputFilesDat ( File dstDir , Map < String , SortedMap < String , ZoneRules > > allBuiltZones , Set < String > allRegionIds , Set < ZoneRules > allRules , SortedMap < LocalDate , Byte > leapSeconds ) { File tzdbFile = new File ( dstDir , "TZDB.dat" ) ; tzdbFile . delete ( ) ; try { FileOutputStream fos = null ; try { fos = new FileOutputStream ( tzdbFile ) ; outputTzdbDat ( fos , allBuiltZones , allRegionIds , allRules ) ; } finally { if ( fos != null ) { fos . close ( ) ; } } } catch ( Exception ex ) { System . out . println ( "Failed: " + ex . toString ( ) ) ; ex . printStackTrace ( ) ; System . exit ( 1 ) ; } } | Outputs the DAT files . |
27,632 | private static void outputTzdbEntry ( JarOutputStream jos , Map < String , SortedMap < String , ZoneRules > > allBuiltZones , Set < String > allRegionIds , Set < ZoneRules > allRules ) { try { jos . putNextEntry ( new ZipEntry ( "org/threeten/bp/TZDB.dat" ) ) ; outputTzdbDat ( jos , allBuiltZones , allRegionIds , allRules ) ; jos . closeEntry ( ) ; } catch ( Exception ex ) { System . out . println ( "Failed: " + ex . toString ( ) ) ; ex . printStackTrace ( ) ; System . exit ( 1 ) ; } } | Outputs the timezone entry in the JAR file . |
27,633 | private static void outputTzdbDat ( OutputStream jos , Map < String , SortedMap < String , ZoneRules > > allBuiltZones , Set < String > allRegionIds , Set < ZoneRules > allRules ) throws IOException { DataOutputStream out = new DataOutputStream ( jos ) ; out . writeByte ( 1 ) ; out . writeUTF ( "TZDB" ) ; String [ ] versionArray = allBuiltZones . keySet ( ) . toArray ( new String [ allBuiltZones . size ( ) ] ) ; out . writeShort ( versionArray . length ) ; for ( String version : versionArray ) { out . writeUTF ( version ) ; } String [ ] regionArray = allRegionIds . toArray ( new String [ allRegionIds . size ( ) ] ) ; out . writeShort ( regionArray . length ) ; for ( String regionId : regionArray ) { out . writeUTF ( regionId ) ; } List < ZoneRules > rulesList = new ArrayList < ZoneRules > ( allRules ) ; out . writeShort ( rulesList . size ( ) ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( 1024 ) ; for ( ZoneRules rules : rulesList ) { baos . reset ( ) ; DataOutputStream dataos = new DataOutputStream ( baos ) ; Ser . write ( rules , dataos ) ; dataos . close ( ) ; byte [ ] bytes = baos . toByteArray ( ) ; out . writeShort ( bytes . length ) ; out . write ( bytes ) ; } for ( String version : allBuiltZones . keySet ( ) ) { out . writeShort ( allBuiltZones . get ( version ) . size ( ) ) ; for ( Map . Entry < String , ZoneRules > entry : allBuiltZones . get ( version ) . entrySet ( ) ) { int regionIndex = Arrays . binarySearch ( regionArray , entry . getKey ( ) ) ; int rulesIndex = rulesList . indexOf ( entry . getValue ( ) ) ; out . writeShort ( regionIndex ) ; out . writeShort ( rulesIndex ) ; } } out . flush ( ) ; } | Outputs the timezone DAT file . |
27,634 | private void parseLeapSecondsFile ( ) throws Exception { printVerbose ( "Parsing leap second file: " + leapSecondsFile ) ; int lineNumber = 1 ; String line = null ; BufferedReader in = null ; try { in = new BufferedReader ( new FileReader ( leapSecondsFile ) ) ; for ( ; ( line = in . readLine ( ) ) != null ; lineNumber ++ ) { int index = line . indexOf ( '#' ) ; if ( index >= 0 ) { line = line . substring ( 0 , index ) ; } if ( line . trim ( ) . length ( ) == 0 ) { continue ; } LeapSecondRule secondRule = parseLeapSecondRule ( line ) ; leapSeconds . put ( secondRule . leapDate , secondRule . secondAdjustment ) ; } } catch ( Exception ex ) { throw new Exception ( "Failed while processing file '" + leapSecondsFile + "' on line " + lineNumber + " '" + line + "'" , ex ) ; } finally { try { if ( in != null ) { in . close ( ) ; } } catch ( Exception ex ) { } } } | Parses the leap seconds file . |
27,635 | private void parseFile ( File file ) throws Exception { int lineNumber = 1 ; String line = null ; BufferedReader in = null ; try { in = new BufferedReader ( new FileReader ( file ) ) ; List < TZDBZone > openZone = null ; for ( ; ( line = in . readLine ( ) ) != null ; lineNumber ++ ) { int index = line . indexOf ( '#' ) ; if ( index >= 0 ) { line = line . substring ( 0 , index ) ; } if ( line . trim ( ) . length ( ) == 0 ) { continue ; } StringTokenizer st = new StringTokenizer ( line , " \t" ) ; if ( openZone != null && Character . isWhitespace ( line . charAt ( 0 ) ) && st . hasMoreTokens ( ) ) { if ( parseZoneLine ( st , openZone ) ) { openZone = null ; } } else { if ( st . hasMoreTokens ( ) ) { String first = st . nextToken ( ) ; if ( first . equals ( "Zone" ) ) { if ( st . countTokens ( ) < 3 ) { printVerbose ( "Invalid Zone line in file: " + file + ", line: " + line ) ; throw new IllegalArgumentException ( "Invalid Zone line" ) ; } openZone = new ArrayList < TZDBZone > ( ) ; zones . put ( st . nextToken ( ) , openZone ) ; if ( parseZoneLine ( st , openZone ) ) { openZone = null ; } } else { openZone = null ; if ( first . equals ( "Rule" ) ) { if ( st . countTokens ( ) < 9 ) { printVerbose ( "Invalid Rule line in file: " + file + ", line: " + line ) ; throw new IllegalArgumentException ( "Invalid Rule line" ) ; } parseRuleLine ( st ) ; } else if ( first . equals ( "Link" ) ) { if ( st . countTokens ( ) < 2 ) { printVerbose ( "Invalid Link line in file: " + file + ", line: " + line ) ; throw new IllegalArgumentException ( "Invalid Link line" ) ; } String realId = st . nextToken ( ) ; String aliasId = st . nextToken ( ) ; links . put ( aliasId , realId ) ; } else { throw new IllegalArgumentException ( "Unknown line" ) ; } } } } } } catch ( Exception ex ) { throw new Exception ( "Failed while processing file '" + file + "' on line " + lineNumber + " '" + line + "'" , ex ) ; } finally { if ( in != null ) { in . close ( ) ; } } } | Parses a source file . |
27,636 | private boolean parseZoneLine ( StringTokenizer st , List < TZDBZone > zoneList ) { TZDBZone zone = new TZDBZone ( ) ; zoneList . add ( zone ) ; zone . standardOffset = parseOffset ( st . nextToken ( ) ) ; String savingsRule = parseOptional ( st . nextToken ( ) ) ; if ( savingsRule == null ) { zone . fixedSavingsSecs = 0 ; zone . savingsRule = null ; } else { try { zone . fixedSavingsSecs = parsePeriod ( savingsRule ) ; zone . savingsRule = null ; } catch ( Exception ex ) { zone . fixedSavingsSecs = null ; zone . savingsRule = savingsRule ; } } zone . text = st . nextToken ( ) ; if ( st . hasMoreTokens ( ) ) { zone . year = Year . of ( Integer . parseInt ( st . nextToken ( ) ) ) ; if ( st . hasMoreTokens ( ) ) { parseMonthDayTime ( st , zone ) ; } return false ; } else { return true ; } } | Parses a Zone line . |
27,637 | private void buildZoneRules ( ) throws Exception { for ( String zoneId : zones . keySet ( ) ) { printVerbose ( "Building zone " + zoneId ) ; zoneId = deduplicate ( zoneId ) ; List < TZDBZone > tzdbZones = zones . get ( zoneId ) ; ZoneRulesBuilder bld = new ZoneRulesBuilder ( ) ; for ( TZDBZone tzdbZone : tzdbZones ) { bld = tzdbZone . addToBuilder ( bld , rules ) ; } ZoneRules buildRules = bld . toRules ( zoneId , deduplicateMap ) ; builtZones . put ( zoneId , deduplicate ( buildRules ) ) ; } for ( String aliasId : links . keySet ( ) ) { aliasId = deduplicate ( aliasId ) ; String realId = links . get ( aliasId ) ; printVerbose ( "Linking alias " + aliasId + " to " + realId ) ; ZoneRules realRules = builtZones . get ( realId ) ; if ( realRules == null ) { realId = links . get ( realId ) ; printVerbose ( "Relinking alias " + aliasId + " to " + realId ) ; realRules = builtZones . get ( realId ) ; if ( realRules == null ) { throw new IllegalArgumentException ( "Alias '" + aliasId + "' links to invalid zone '" + realId + "' for '" + version + "'" ) ; } } builtZones . put ( aliasId , realRules ) ; } builtZones . remove ( "UTC" ) ; builtZones . remove ( "GMT" ) ; builtZones . remove ( "GMT0" ) ; builtZones . remove ( "GMT+0" ) ; builtZones . remove ( "GMT-0" ) ; } | Build the rules zones and links into real zones . |
27,638 | @ SuppressWarnings ( "unchecked" ) < T > T deduplicate ( T object ) { if ( deduplicateMap . containsKey ( object ) == false ) { deduplicateMap . put ( object , object ) ; } return ( T ) deduplicateMap . get ( object ) ; } | Deduplicates an object instance . |
27,639 | static < R extends ChronoLocalDate > ChronoZonedDateTime < R > ofBest ( ChronoLocalDateTimeImpl < R > localDateTime , ZoneId zone , ZoneOffset preferredOffset ) { Jdk8Methods . requireNonNull ( localDateTime , "localDateTime" ) ; Jdk8Methods . requireNonNull ( zone , "zone" ) ; if ( zone instanceof ZoneOffset ) { return new ChronoZonedDateTimeImpl < R > ( localDateTime , ( ZoneOffset ) zone , zone ) ; } ZoneRules rules = zone . getRules ( ) ; LocalDateTime isoLDT = LocalDateTime . from ( localDateTime ) ; List < ZoneOffset > validOffsets = rules . getValidOffsets ( isoLDT ) ; ZoneOffset offset ; if ( validOffsets . size ( ) == 1 ) { offset = validOffsets . get ( 0 ) ; } else if ( validOffsets . size ( ) == 0 ) { ZoneOffsetTransition trans = rules . getTransition ( isoLDT ) ; localDateTime = localDateTime . plusSeconds ( trans . getDuration ( ) . getSeconds ( ) ) ; offset = trans . getOffsetAfter ( ) ; } else { if ( preferredOffset != null && validOffsets . contains ( preferredOffset ) ) { offset = preferredOffset ; } else { offset = validOffsets . get ( 0 ) ; } } Jdk8Methods . requireNonNull ( offset , "offset" ) ; return new ChronoZonedDateTimeImpl < R > ( localDateTime , offset , zone ) ; } | Obtains an instance from a local date - time using the preferred offset if possible . |
27,640 | static < R extends ChronoLocalDate > ChronoZonedDateTimeImpl < R > ofInstant ( Chronology chrono , Instant instant , ZoneId zone ) { ZoneRules rules = zone . getRules ( ) ; ZoneOffset offset = rules . getOffset ( instant ) ; Jdk8Methods . requireNonNull ( offset , "offset" ) ; LocalDateTime ldt = LocalDateTime . ofEpochSecond ( instant . getEpochSecond ( ) , instant . getNano ( ) , offset ) ; @ SuppressWarnings ( "unchecked" ) ChronoLocalDateTimeImpl < R > cldt = ( ChronoLocalDateTimeImpl < R > ) chrono . localDateTime ( ldt ) ; return new ChronoZonedDateTimeImpl < R > ( cldt , offset , zone ) ; } | Obtains an instance from an instant using the specified time - zone . |
27,641 | public ChronoLocalDate date ( Era era , int yearOfEra , int month , int dayOfMonth ) { return date ( prolepticYear ( era , yearOfEra ) , month , dayOfMonth ) ; } | Obtains a local date in this chronology from the era year - of - era month - of - year and day - of - month fields . |
27,642 | public ChronoLocalDate dateYearDay ( Era era , int yearOfEra , int dayOfYear ) { return dateYearDay ( prolepticYear ( era , yearOfEra ) , dayOfYear ) ; } | Obtains a local date in this chronology from the era year - of - era and day - of - year fields . |
27,643 | void updateResolveMap ( Map < TemporalField , Long > fieldValues , ChronoField field , long value ) { Long current = fieldValues . get ( field ) ; if ( current != null && current . longValue ( ) != value ) { throw new DateTimeException ( "Invalid state, field: " + field + " " + current + " conflicts with " + field + " " + value ) ; } fieldValues . put ( field , value ) ; } | Updates the map of field - values during resolution . |
27,644 | private DateTimeFormatterBuilder appendValue ( NumberPrinterParser pp ) { if ( active . valueParserIndex >= 0 && active . printerParsers . get ( active . valueParserIndex ) instanceof NumberPrinterParser ) { final int activeValueParser = active . valueParserIndex ; NumberPrinterParser basePP = ( NumberPrinterParser ) active . printerParsers . get ( activeValueParser ) ; if ( pp . minWidth == pp . maxWidth && pp . signStyle == SignStyle . NOT_NEGATIVE ) { basePP = basePP . withSubsequentWidth ( pp . maxWidth ) ; appendInternal ( pp . withFixedWidth ( ) ) ; active . valueParserIndex = activeValueParser ; } else { basePP = basePP . withFixedWidth ( ) ; active . valueParserIndex = appendInternal ( pp ) ; } active . printerParsers . set ( activeValueParser , basePP ) ; } else { active . valueParserIndex = appendInternal ( pp ) ; } return this ; } | Appends a fixed width printer - parser . |
27,645 | private static void registerProvider0 ( ZoneRulesProvider provider ) { for ( String zoneId : provider . provideZoneIds ( ) ) { Jdk8Methods . requireNonNull ( zoneId , "zoneId" ) ; ZoneRulesProvider old = ZONES . putIfAbsent ( zoneId , provider ) ; if ( old != null ) { throw new ZoneRulesException ( "Unable to register zone as one already registered with that ID: " + zoneId + ", currently loading from provider: " + provider ) ; } } } | Registers the provider . |
27,646 | private void readObject ( ObjectInputStream stream ) throws IOException , ClassNotFoundException { stream . defaultReadObject ( ) ; this . era = JapaneseEra . from ( isoDate ) ; int yearOffset = this . era . startDate ( ) . getYear ( ) - 1 ; this . yearOfEra = isoDate . getYear ( ) - yearOffset ; } | Reconstitutes this object from a stream . |
27,647 | private static LocalDate resolvePreviousValid ( int year , int month , int day ) { switch ( month ) { case 2 : day = Math . min ( day , IsoChronology . INSTANCE . isLeapYear ( year ) ? 29 : 28 ) ; break ; case 4 : case 6 : case 9 : case 11 : day = Math . min ( day , 30 ) ; break ; } return LocalDate . of ( year , month , day ) ; } | Resolves the date resolving days past the end of month . |
27,648 | LocalDate endDate ( ) { int ordinal = ordinal ( eraValue ) ; JapaneseEra [ ] eras = values ( ) ; if ( ordinal >= eras . length - 1 ) { return LocalDate . MAX ; } return eras [ ordinal + 1 ] . startDate ( ) . minusDays ( 1 ) ; } | Returns the end date of the era . |
27,649 | public static < T > T requireNonNull ( T value , String parameterName ) { if ( value == null ) { throw new NullPointerException ( parameterName + " must not be null" ) ; } return value ; } | Ensures that the argument is non - null . |
27,650 | public static int safeAdd ( int a , int b ) { int sum = a + b ; if ( ( a ^ sum ) < 0 && ( a ^ b ) >= 0 ) { throw new ArithmeticException ( "Addition overflows an int: " + a + " + " + b ) ; } return sum ; } | Safely adds two int values . |
27,651 | public static int safeSubtract ( int a , int b ) { int result = a - b ; if ( ( a ^ result ) < 0 && ( a ^ b ) < 0 ) { throw new ArithmeticException ( "Subtraction overflows an int: " + a + " - " + b ) ; } return result ; } | Safely subtracts one int from another . |
27,652 | public static int safeMultiply ( int a , int b ) { long total = ( long ) a * ( long ) b ; if ( total < Integer . MIN_VALUE || total > Integer . MAX_VALUE ) { throw new ArithmeticException ( "Multiplication overflows an int: " + a + " * " + b ) ; } return ( int ) total ; } | Safely multiply one int by another . |
27,653 | public static long safeMultiply ( long a , int b ) { switch ( b ) { case - 1 : if ( a == Long . MIN_VALUE ) { throw new ArithmeticException ( "Multiplication overflows a long: " + a + " * " + b ) ; } return - a ; case 0 : return 0L ; case 1 : return a ; } long total = a * b ; if ( total / b != a ) { throw new ArithmeticException ( "Multiplication overflows a long: " + a + " * " + b ) ; } return total ; } | Safely multiply a long by an int . |
27,654 | public static int safeToInt ( long value ) { if ( value > Integer . MAX_VALUE || value < Integer . MIN_VALUE ) { throw new ArithmeticException ( "Calculation overflows an int: " + value ) ; } return ( int ) value ; } | Safely convert a long to an int . |
27,655 | public AqlQueryOptions shardIds ( final String ... shardIds ) { getOptions ( ) . getShardIds ( ) . addAll ( Arrays . asList ( shardIds ) ) ; return this ; } | Restrict query to shards by given ids . This is an internal option . Use at your own risk . |
27,656 | public static boolean verifySignature ( byte [ ] publicKey , byte [ ] message , byte [ ] signature ) { return curve_sigs . curve25519_verify ( SHA512Provider , signature , publicKey , message , message . length ) == 0 ; } | Verification of signature |
27,657 | @ ObjectiveCName ( "isLargeDialogMessage:" ) public boolean isLargeDialogMessage ( ContentType contentType ) { switch ( contentType ) { case SERVICE : case SERVICE_AVATAR : case SERVICE_AVATAR_REMOVED : case SERVICE_CREATED : case SERVICE_TITLE : case SERVICE_LEAVE : case SERVICE_REGISTERED : case SERVICE_KICK : case SERVICE_ADD : case SERVICE_JOINED : case SERVICE_CALL_ENDED : case SERVICE_CALL_MISSED : case SERVICE_ABOUT : case SERVICE_TOPIC : return true ; default : return false ; } } | If Dialog List message need to be wide in group chat as it is already includes performer in it s body . |
27,658 | @ ObjectiveCName ( "formatNotificationText:" ) public String formatNotificationText ( Notification pendingNotification ) { return formatContentText ( pendingNotification . getSender ( ) , pendingNotification . getContentDescription ( ) . getContentType ( ) , pendingNotification . getContentDescription ( ) . getText ( ) , pendingNotification . getContentDescription ( ) . getRelatedUser ( ) , pendingNotification . isChannel ( ) ) ; } | Formatting Pending notification text |
27,659 | @ ObjectiveCName ( "formatContentTextWithSenderId:withContentType:withText:withRelatedUid:withIsChannel:" ) public String formatContentText ( int senderId , ContentType contentType , String text , int relatedUid , boolean isChannel ) { String groupKey = isChannel ? "channels" : "groups" ; switch ( contentType ) { case TEXT : return text ; case DOCUMENT : if ( text == null || text . length ( ) == 0 ) { return get ( "content.document" ) ; } return text ; case DOCUMENT_PHOTO : return get ( "content.photo" ) ; case DOCUMENT_VIDEO : return get ( "content.video" ) ; case DOCUMENT_AUDIO : return get ( "content.audio" ) ; case CONTACT : return get ( "content.contact" ) ; case LOCATION : return get ( "content.location" ) ; case STICKER : if ( text != null && ! "" . equals ( text ) ) { return text + " " + get ( "content.sticker" ) ; } else { return get ( "content.sticker" ) ; } case SERVICE : return text ; case SERVICE_REGISTERED : return getTemplateNamed ( senderId , "content.service.registered.compact" ) . replace ( "{app_name}" , getAppName ( ) ) ; case SERVICE_CREATED : return getTemplateNamed ( senderId , "content.service." + groupKey + ".created" ) ; case SERVICE_ADD : return getTemplateNamed ( senderId , "content.service." + groupKey + ".invited" ) . replace ( "{name_added}" , getSubjectName ( relatedUid ) ) ; case SERVICE_LEAVE : return getTemplateNamed ( senderId , "content.service." + groupKey + ".left" ) ; case SERVICE_KICK : return getTemplateNamed ( senderId , "content.service." + groupKey + ".kicked" ) . replace ( "{name_kicked}" , getSubjectName ( relatedUid ) ) ; case SERVICE_AVATAR : return getTemplateNamed ( senderId , "content.service." + groupKey + ".avatar_changed" ) ; case SERVICE_AVATAR_REMOVED : return getTemplateNamed ( senderId , "content.service." + groupKey + ".avatar_removed" ) ; case SERVICE_TITLE : return getTemplateNamed ( senderId , "content.service." + groupKey + ".title_changed.compact" ) ; case SERVICE_TOPIC : return getTemplateNamed ( senderId , "content.service." + groupKey + ".topic_changed.compact" ) ; case SERVICE_ABOUT : return getTemplateNamed ( senderId , "content.service." + groupKey + ".about_changed.compact" ) ; case SERVICE_JOINED : return getTemplateNamed ( senderId , "content.service." + groupKey + ".joined" ) ; case SERVICE_CALL_ENDED : return get ( "content.service.calls.ended" ) ; case SERVICE_CALL_MISSED : return get ( "content.service.calls.missed" ) ; case NONE : return "" ; default : case UNKNOWN_CONTENT : return get ( "content.unsupported" ) ; } } | Formatting content for Dialog List and Notifications |
27,660 | @ ObjectiveCName ( "formatFullServiceMessageWithSenderId:withContent:withIsChannel:" ) public String formatFullServiceMessage ( int senderId , ServiceContent content , boolean isChannel ) { String groupKey = isChannel ? "channels" : "groups" ; if ( content instanceof ServiceUserRegistered ) { return getTemplateNamed ( senderId , "content.service.registered.full" ) . replace ( "{app_name}" , getAppName ( ) ) ; } else if ( content instanceof ServiceGroupCreated ) { return getTemplateNamed ( senderId , "content.service." + groupKey + ".created" ) ; } else if ( content instanceof ServiceGroupUserInvited ) { return getTemplateNamed ( senderId , "content.service." + groupKey + ".invited" ) . replace ( "{name_added}" , getSubjectName ( ( ( ServiceGroupUserInvited ) content ) . getAddedUid ( ) ) ) ; } else if ( content instanceof ServiceGroupUserKicked ) { return getTemplateNamed ( senderId , "content.service." + groupKey + ".kicked" ) . replace ( "{name_kicked}" , getSubjectName ( ( ( ServiceGroupUserKicked ) content ) . getKickedUid ( ) ) ) ; } else if ( content instanceof ServiceGroupUserLeave ) { return getTemplateNamed ( senderId , "content.service." + groupKey + ".left" ) ; } else if ( content instanceof ServiceGroupTitleChanged ) { return getTemplateNamed ( senderId , "content.service." + groupKey + ".title_changed.full" ) . replace ( "{title}" , ( ( ServiceGroupTitleChanged ) content ) . getNewTitle ( ) ) ; } else if ( content instanceof ServiceGroupTopicChanged ) { return getTemplateNamed ( senderId , "content.service." + groupKey + ".topic_changed.full" ) . replace ( "{topic}" , ( ( ServiceGroupTopicChanged ) content ) . getNewTopic ( ) ) ; } else if ( content instanceof ServiceGroupAboutChanged ) { return getTemplateNamed ( senderId , "content.service." + groupKey + ".about_changed.full" ) . replace ( "{about}" , ( ( ServiceGroupAboutChanged ) content ) . getNewAbout ( ) ) ; } else if ( content instanceof ServiceGroupAvatarChanged ) { if ( ( ( ServiceGroupAvatarChanged ) content ) . getNewAvatar ( ) != null ) { return getTemplateNamed ( senderId , "content.service." + groupKey + ".avatar_changed" ) ; } else { return getTemplateNamed ( senderId , "content.service." + groupKey + ".avatar_removed" ) ; } } else if ( content instanceof ServiceGroupUserJoined ) { return getTemplateNamed ( senderId , "content.service." + groupKey + ".joined" ) ; } else if ( content instanceof ServiceCallEnded ) { return get ( "content.service.calls.ended" ) ; } else if ( content instanceof ServiceCallMissed ) { return get ( "content.service.calls.missed" ) ; } return content . getCompatText ( ) ; } | Formatting Service Content |
27,661 | @ ObjectiveCName ( "formatMessagesExport:" ) public String formatMessagesExport ( Message [ ] messages ) { String text = "" ; Arrays . sort ( messages , new Comparator < Message > ( ) { int compare ( long lhs , long rhs ) { return lhs < rhs ? - 1 : ( lhs == rhs ? 0 : 1 ) ; } public int compare ( Message lhs , Message rhs ) { return compare ( lhs . getEngineSort ( ) , rhs . getEngineSort ( ) ) ; } } ) ; if ( messages . length == 1 ) { for ( Message model : messages ) { if ( ! ( model . getContent ( ) instanceof TextContent ) ) { continue ; } text += ( ( TextContent ) model . getContent ( ) ) . getText ( ) ; } } else { for ( Message model : messages ) { if ( ! ( model . getContent ( ) instanceof TextContent ) ) { continue ; } if ( text . length ( ) > 0 ) { text += "\n" ; } text += getUser ( model . getSenderId ( ) ) . getName ( ) + ": " ; text += ( ( TextContent ) model . getContent ( ) ) . getText ( ) ; } } return text ; } | Formatting messages for exporting |
27,662 | public boolean moveToFirst ( ) { try { return resultSet . first ( ) ; } catch ( SQLException e ) { logger . error ( e . getMessage ( ) , e ) ; } return false ; } | We can t use this method in sqlite jdbc driver |
27,663 | public Promise < Void > replaceOwnStream ( CountedReference < WebRTCMediaStream > stream ) { return ask ( new PeerNodeActor . ReplaceOwnStream ( stream . acquire ( ) ) ) ; } | Call this method to set own stream |
27,664 | public void onCandidate ( long sessionId , int index , String id , String sdp ) { send ( new RTCCandidate ( deviceId , sessionId , index , id , sdp ) ) ; } | Call this method when new candidate is received |
27,665 | public Promise < Void > replaceStream ( CountedReference < WebRTCMediaStream > mediaStream ) { return ask ( new PeerConnectionActor . ReplaceStream ( mediaStream . acquire ( ) ) ) ; } | Replace Current outgoing stream |
27,666 | public void onCandidate ( long sessionId , int index , String id , String sdp ) { send ( new PeerConnectionActor . OnCandidate ( sessionId , index , id , sdp ) ) ; } | Call this method when new candidate arrived from other peer |
27,667 | public void reset ( ) { super . reset ( ) ; H1 = 0x67452301 ; H2 = 0xefcdab89 ; H3 = 0x98badcfe ; H4 = 0x10325476 ; xOff = 0 ; for ( int i = 0 ; i != X . length ; i ++ ) { X [ i ] = 0 ; } } | reset the chaining variables to the IV values . |
27,668 | @ SuppressWarnings ( "unchecked" ) public static < T > PromisesArray < T > of ( Collection < T > collection ) { final ArrayList < Promise < T > > res = new ArrayList < > ( ) ; for ( T t : collection ) { res . add ( Promise . success ( t ) ) ; } final Promise [ ] promises = res . toArray ( new Promise [ res . size ( ) ] ) ; return new PromisesArray < > ( ( PromiseFunc < Promise < T > [ ] > ) executor -> { executor . result ( promises ) ; } ) ; } | Create PromisesArray from collection |
27,669 | public static < T > PromisesArray < T > of ( T ... items ) { ArrayList < Promise < T > > res = new ArrayList < > ( ) ; for ( T t : items ) { res . add ( Promise . success ( t ) ) ; } final Promise [ ] promises = res . toArray ( new Promise [ res . size ( ) ] ) ; return new PromisesArray < > ( ( PromiseFunc < Promise < T > [ ] > ) executor -> { executor . result ( promises ) ; } ) ; } | Create PromisesArray from values |
27,670 | public static < T > PromisesArray < T > ofPromises ( Promise < T > ... items ) { ArrayList < Promise < T > > res = new ArrayList < > ( ) ; Collections . addAll ( res , items ) ; final Promise [ ] promises = res . toArray ( new Promise [ res . size ( ) ] ) ; return new PromisesArray < > ( ( PromiseFunc < Promise < T > [ ] > ) executor -> { executor . result ( promises ) ; } ) ; } | Create PromisesArray from multiple Promise |
27,671 | public < R > PromisesArray < R > map ( final Function < T , Promise < R > > fun ) { return mapSourcePromises ( srcPromise -> new Promise < R > ( resolver -> { srcPromise . then ( t -> { Promise < R > mapped = fun . apply ( t ) ; mapped . then ( t2 -> resolver . result ( t2 ) ) ; mapped . failure ( e -> resolver . error ( e ) ) ; } ) ; srcPromise . failure ( e -> resolver . error ( e ) ) ; } ) ) ; } | Map promises results to new promises |
27,672 | public < R > Promise < R > zipPromise ( final ListFunction < T , Promise < R > > fuc ) { return new Promise < > ( resolver -> { promises . then ( promises1 -> { final ArrayList < T > res = new ArrayList < T > ( ) ; for ( int i = 0 ; i < promises1 . length ; i ++ ) { res . add ( null ) ; } final Boolean [ ] ended = new Boolean [ promises1 . length ] ; for ( int i = 0 ; i < promises1 . length ; i ++ ) { final int finalI = i ; promises1 [ i ] . then ( t -> { res . set ( finalI , t ) ; ended [ finalI ] = true ; for ( int i1 = 0 ; i1 < promises1 . length ; i1 ++ ) { if ( ended [ i1 ] == null || ! ended [ i1 ] ) { return ; } } fuc . apply ( res ) . pipeTo ( resolver ) ; } ) ; promises1 [ i ] . failure ( e -> resolver . error ( e ) ) ; } if ( promises1 . length == 0 ) { fuc . apply ( res ) . pipeTo ( resolver ) ; } } ) ; promises . failure ( e -> resolver . error ( e ) ) ; } ) ; } | Zip array to single promise |
27,673 | @ ObjectiveCName ( "subscribeWithListener:notify:" ) public void subscribe ( ValueChangedListener < T > listener , boolean notify ) { if ( listeners . contains ( listener ) ) { return ; } listeners . add ( listener ) ; if ( notify ) { listener . onChanged ( get ( ) , this ) ; } } | Subscribe to value updates |
27,674 | protected void notifyInMainThread ( final T value ) { for ( ValueChangedListener < T > listener : listeners ) { listener . onChanged ( value , Value . this ) ; } } | Performing notification to subscribers if we know that we are on mainthread Useful for chainging updates from chain of values |
27,675 | private static void applyOpenSSLFix ( ) throws SecurityException { if ( ( Build . VERSION . SDK_INT < VERSION_CODE_JELLY_BEAN ) || ( Build . VERSION . SDK_INT > VERSION_CODE_JELLY_BEAN_MR2 ) ) { return ; } try { Class . forName ( "org.apache.harmony.xnet.provider.jsse.NativeCrypto" ) . getMethod ( "RAND_seed" , byte [ ] . class ) . invoke ( null , ( Object ) generateSeed ( ) ) ; int bytesRead = ( Integer ) Class . forName ( "org.apache.harmony.xnet.provider.jsse.NativeCrypto" ) . getMethod ( "RAND_load_file" , String . class , long . class ) . invoke ( null , "/dev/urandom" , 1024 ) ; if ( bytesRead != 1024 ) { throw new IOException ( "Unexpected number of bytes read from Linux PRNG: " + bytesRead ) ; } } catch ( Exception e ) { throw new SecurityException ( "Failed to seed OpenSSL PRNG" , e ) ; } } | Applies the fix for OpenSSL PRNG having low entropy . Does nothing if the fix is not needed . |
27,676 | private static byte [ ] generateSeed ( ) { try { ByteArrayOutputStream seedBuffer = new ByteArrayOutputStream ( ) ; DataOutputStream seedBufferOut = new DataOutputStream ( seedBuffer ) ; seedBufferOut . writeLong ( System . currentTimeMillis ( ) ) ; seedBufferOut . writeLong ( System . nanoTime ( ) ) ; seedBufferOut . writeInt ( Process . myPid ( ) ) ; seedBufferOut . writeInt ( Process . myUid ( ) ) ; seedBufferOut . write ( BUILD_FINGERPRINT_AND_DEVICE_SERIAL ) ; seedBufferOut . close ( ) ; return seedBuffer . toByteArray ( ) ; } catch ( IOException e ) { throw new SecurityException ( "Failed to generate seed" , e ) ; } } | Generates a device - and invocation - specific seed to be mixed into the Linux PRNG . |
27,677 | private static String getDeviceSerialNumber ( ) { try { return ( String ) Build . class . getField ( "SERIAL" ) . get ( null ) ; } catch ( Exception ignored ) { return null ; } } | Gets the hardware serial number of this device . |
27,678 | public void performPersistCursorRequest ( String name , long key , Request request ) { persistentRequests . send ( new PersistentRequestsActor . PerformCursorRequest ( name , key , request ) ) ; } | Perform cursor persist request . Request is performed only if key is bigger than previous request with same name |
27,679 | public static void fill ( byte [ ] a , byte val ) { for ( int i = 0 , len = a . length ; i < len ; i ++ ) a [ i ] = val ; } | Assigns the specified byte value to each element of the specified array of bytes . |
27,680 | public void scheduleFirst ( Envelope envelope ) { if ( envelope . getMailbox ( ) != this ) { throw new RuntimeException ( "envelope.mailbox != this mailbox" ) ; } queueCollection . post ( queueId , envelope , true ) ; } | Send envelope first |
27,681 | private static int [ ] make_crc_table ( ) { int [ ] crc_table = new int [ 256 ] ; for ( int n = 0 ; n < 256 ; n ++ ) { int c = n ; for ( int k = 8 ; -- k >= 0 ; ) { if ( ( c & 1 ) != 0 ) c = 0xedb88320 ^ ( c >>> 1 ) ; else c = c >>> 1 ; } crc_table [ n ] = c ; } return crc_table ; } | Make the table for a fast CRC . |
27,682 | public void update ( int bval ) { int c = ~ crc ; c = crc_table [ ( c ^ bval ) & 0xff ] ^ ( c >>> 8 ) ; crc = ~ c ; } | Updates the checksum with the int bval . |
27,683 | public void update ( byte [ ] buf , int off , int len ) { int c = ~ crc ; while ( -- len >= 0 ) c = crc_table [ ( c ^ buf [ off ++ ] ) & 0xff ] ^ ( c >>> 8 ) ; crc = ~ c ; } | Adds the byte array to the data checksum . |
27,684 | public void end ( ) { if ( this . sectionName != null ) { Log . d ( TAG , "" + this . sectionName + " loaded in " + ( ActorTime . currentTime ( ) - sectionStart ) + " ms" ) ; this . sectionName = null ; } } | Mark section end |
27,685 | public static void startProfileActivity ( Context context , int uid ) { if ( context == null ) { return ; } Bundle b = new Bundle ( ) ; b . putInt ( Intents . EXTRA_UID , uid ) ; startActivity ( context , b , ProfileActivity . class ) ; } | Launch User Profile Activity |
27,686 | private View findFirstVisibleChildClosestToStart ( boolean completelyVisible , boolean acceptPartiallyVisible ) { if ( mShouldReverseLayout ) { return findOneVisibleChild ( getChildCount ( ) - 1 , - 1 , completelyVisible , acceptPartiallyVisible ) ; } else { return findOneVisibleChild ( 0 , getChildCount ( ) , completelyVisible , acceptPartiallyVisible ) ; } } | Convenience method to find the visible child closes to start . Caller should check if it has enough children . |
27,687 | private View findFirstVisibleChildClosestToEnd ( boolean completelyVisible , boolean acceptPartiallyVisible ) { if ( mShouldReverseLayout ) { return findOneVisibleChild ( 0 , getChildCount ( ) , completelyVisible , acceptPartiallyVisible ) ; } else { return findOneVisibleChild ( getChildCount ( ) - 1 , - 1 , completelyVisible , acceptPartiallyVisible ) ; } } | Convenience method to find the visible child closes to end . Caller should check if it has enough children . |
27,688 | private VideoCapturer getVideoCapturer ( ) { String [ ] cameraFacing = { "front" , "back" } ; int [ ] cameraIndex = { 0 , 1 } ; int [ ] cameraOrientation = { 0 , 90 , 180 , 270 } ; for ( String facing : cameraFacing ) { for ( int index : cameraIndex ) { for ( int orientation : cameraOrientation ) { String name = "Camera " + index + ", Facing " + facing + ", Orientation " + orientation ; VideoCapturer capturer = VideoCapturer . create ( name ) ; if ( capturer != null ) { return capturer ; } } } } throw new RuntimeException ( "Failed to open capturer" ) ; } | capturer that works or crash if none do . |
27,689 | public void onInitialDataDownloaded ( ) { Log . d ( TAG , "Initial Data Loaded" ) ; context ( ) . getContactsModule ( ) . startImport ( ) ; if ( appStateVM . isBookImported ( ) ) { onAppLoaded ( ) ; } } | Called after dialogs contacts and settings are downloaded from server |
27,690 | public void detach ( ) { super . detach ( ) ; modules . getFilesModule ( ) . unbindFile ( location . getFileId ( ) , callback , false ) ; } | Detach FileVM from Messenger . Don t use object after detaching . |
27,691 | public MDDocument processDocument ( String text ) { TextCursor cursor = new TextCursor ( text ) ; ArrayList < MDSection > sections = new ArrayList < MDSection > ( ) ; while ( handleCodeBlock ( cursor , sections ) ) ; return new MDDocument ( sections . toArray ( new MDSection [ sections . size ( ) ] ) ) ; } | Parsing markdown document |
27,692 | private void handleTextBlock ( TextCursor cursor , int blockEnd , ArrayList < MDSection > paragraphs ) { MDText [ ] spans = handleSpans ( cursor , blockEnd ) ; paragraphs . add ( new MDSection ( spans ) ) ; cursor . currentOffset = blockEnd ; } | Processing text blocks between code blocks |
27,693 | private MDText [ ] handleSpans ( TextCursor cursor , int blockEnd ) { ArrayList < MDText > elements = new ArrayList < MDText > ( ) ; while ( handleSpan ( cursor , blockEnd , elements ) ) ; return elements . toArray ( new MDText [ elements . size ( ) ] ) ; } | Processing formatting spans |
27,694 | private void handleRawText ( TextCursor cursor , int limit , ArrayList < MDText > elements ) { while ( true ) { BasicUrl url = findUrl ( cursor , limit ) ; if ( url != null ) { String link = cursor . text . substring ( url . getStart ( ) , url . getEnd ( ) ) ; addText ( cursor , url . getStart ( ) , elements ) ; elements . add ( new MDUrl ( link , link ) ) ; cursor . currentOffset = url . getEnd ( ) ; continue ; } addText ( cursor , limit , elements ) ; return ; } } | Handling raw text block |
27,695 | private void addText ( TextCursor cursor , int limit , ArrayList < MDText > elements ) { if ( cursor . currentOffset < limit ) { elements . add ( new MDRawText ( cursor . text . substring ( cursor . currentOffset , limit ) ) ) ; cursor . currentOffset = limit ; } } | Adding raw simple text |
27,696 | private int findCodeBlockStart ( TextCursor cursor ) { int offset = cursor . currentOffset ; int index ; while ( ( index = cursor . text . indexOf ( CODE_BLOCK , offset ) ) >= 0 ) { if ( isGoodAnchor ( cursor . text , index - 1 ) ) { return index ; } offset = index + 3 ; } return - 1 ; } | Searching for valid code block begin |
27,697 | private int findCodeBlockEnd ( TextCursor cursor , int blockStart ) { int offset = blockStart + 3 ; int index ; while ( ( index = cursor . text . indexOf ( CODE_BLOCK , offset ) ) >= 0 ) { if ( isGoodAnchor ( cursor . text , index + 3 ) ) { return index + 3 ; } offset = index + 1 ; } return - 1 ; } | Searching for valid code block end |
27,698 | private int findSpanStart ( TextCursor cursor , int limit ) { for ( int i = cursor . currentOffset ; i < limit ; i ++ ) { char c = cursor . text . charAt ( i ) ; if ( c == '*' || c == '_' ) { if ( isGoodAnchor ( cursor . text , i - 1 ) && isNotSymbol ( cursor . text , i + 1 , c ) ) { return i ; } } } return - 1 ; } | Searching for valid formatting span start |
27,699 | private int findSpanEnd ( TextCursor cursor , int spanStart , int limit , char span ) { for ( int i = spanStart + 1 ; i < limit ; i ++ ) { char c = cursor . text . charAt ( i ) ; if ( c == span ) { if ( isGoodAnchor ( cursor . text , i + 1 ) && isNotSymbol ( cursor . text , i - 1 , span ) ) { return i + 1 ; } } } return - 1 ; } | Searching for valid formatting span end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.