idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
30,500
public void clear ( int startIndex , int endIndex ) { if ( endIndex <= startIndex ) return ; int startWord = ( startIndex >> 6 ) ; if ( startWord >= wlen ) return ; int endWord = ( ( endIndex - 1 ) >> 6 ) ; long startmask = - 1L << startIndex ; long endmask = - 1L >>> - endIndex ; startmask = ~ startmask ; endmask = ~ ...
Clears a range of bits . Clearing past the end does not change the size of the set .
30,501
public boolean getAndSet ( int index ) { int wordNum = index >> 6 ; int bit = index & 0x3f ; long bitmask = 1L << bit ; boolean val = ( bits [ wordNum ] & bitmask ) != 0 ; bits [ wordNum ] |= bitmask ; return val ; }
Sets a bit and returns the previous value . The index should be less than the BitSet size .
30,502
public boolean flipAndGet ( long index ) { int wordNum = ( int ) ( index >> 6 ) ; int bit = ( int ) index & 0x3f ; long bitmask = 1L << bit ; bits [ wordNum ] ^= bitmask ; return ( bits [ wordNum ] & bitmask ) != 0 ; }
flips a bit and returns the resulting bit value . The index should be less than the BitSet size .
30,503
public void flip ( long startIndex , long endIndex ) { if ( endIndex <= startIndex ) return ; int startWord = ( int ) ( startIndex >> 6 ) ; int endWord = expandingWordNum ( endIndex - 1 ) ; long startmask = - 1L << startIndex ; long endmask = - 1L >>> - endIndex ; if ( startWord == endWord ) { bits [ startWord ] ^= ( s...
Flips a range of bits expanding the set size if necessary
30,504
private void shift ( ) { if ( ( int ) word == 0 ) { wordShift += 32 ; word = word >>> 32 ; } if ( ( word & 0x0000FFFF ) == 0 ) { wordShift += 16 ; word >>>= 16 ; } if ( ( word & 0x000000FF ) == 0 ) { wordShift += 8 ; word >>>= 8 ; } indexArray = bitlist [ ( int ) word & 0xff ] ; }
64 bit shifts
30,505
public void push ( KType e1 , KType e2 ) { ensureBufferSpace ( 2 ) ; buffer [ elementsCount ++ ] = e1 ; buffer [ elementsCount ++ ] = e2 ; }
Adds two KTypes to the stack .
30,506
public void push ( KType [ ] elements , int start , int len ) { assert start >= 0 && len >= 0 ; ensureBufferSpace ( len ) ; System . arraycopy ( elements , start , buffer , elementsCount , len ) ; elementsCount += len ; }
Add a range of array elements to the stack .
30,507
public void discard ( int count ) { assert elementsCount >= count ; elementsCount -= count ; Arrays . fill ( buffer , elementsCount , elementsCount + count , null ) ; }
Discard an arbitrary number of elements from the top of the stack .
30,508
public KType pop ( ) { assert elementsCount > 0 ; final KType v = Intrinsics . < KType > cast ( buffer [ -- elementsCount ] ) ; buffer [ elementsCount ] = null ; return v ; }
Remove the top element from the stack and return it .
30,509
@ SuppressWarnings ( "unchecked" ) public static < T > T add ( T op1 , T op2 ) { if ( op1 . getClass ( ) != op2 . getClass ( ) ) { throw new RuntimeException ( "Arguments of different classes: " + op1 + " " + op2 ) ; } if ( Byte . class . isInstance ( op1 ) ) { return ( T ) ( Byte ) ( byte ) ( ( ( Byte ) op1 ) . byteVa...
An intrinsic that is replaced with plain addition of arguments for primitive template types . Invalid for non - number generic types .
30,510
public int removeAll ( final KTypeLookupContainer < ? super KType > c ) { return this . removeAll ( new KTypePredicate < KType > ( ) { public boolean apply ( KType k ) { return c . contains ( k ) ; } } ) ; }
Default implementation uses a predicate for removal .
30,511
public Object [ ] toArray ( ) { KType [ ] array = Intrinsics . < KType > newArray ( size ( ) ) ; int i = 0 ; for ( KTypeCursor < KType > c : this ) { array [ i ++ ] = c . value ; } return array ; }
Default implementation of copying to an array .
30,512
public static < KType , VType > KTypeVTypeHashMap < KType , VType > from ( KType [ ] keys , VType [ ] values ) { if ( keys . length != values . length ) { throw new IllegalArgumentException ( "Arrays of keys and values must have an identical length." ) ; } KTypeVTypeHashMap < KType , VType > map = new KTypeVTypeHashMap...
Creates a hash map from two index - aligned arrays of key - value pairs .
30,513
private String processComment ( String text , TemplateOptions options ) { if ( options . hasKType ( ) ) { text = text . replaceAll ( "(KType)(?=\\p{Lu})" , options . getKType ( ) . getBoxedType ( ) ) ; text = text . replace ( "KType" , options . getKType ( ) . getType ( ) ) ; } if ( options . hasVType ( ) ) { text = te...
Process references inside comment blocks javadocs etc .
30,514
public int addAll ( Iterable < ? extends KTypeCursor < ? extends KType > > iterable ) { int count = 0 ; for ( KTypeCursor < ? extends KType > cursor : iterable ) { if ( add ( cursor . value ) ) { count ++ ; } } return count ; }
Adds all elements from the given iterable to this set .
30,515
public KType indexGet ( int index ) { assert index >= 0 : "The index must point at an existing key." ; assert index <= mask || ( index == mask + 1 && hasEmptyKey ) ; return Intrinsics . < KType > cast ( keys [ index ] ) ; }
Returns the exact value of the existing key . This method makes sense for sets of objects which define custom key - equality relationship .
30,516
public KType indexReplace ( int index , KType equivalentKey ) { assert index >= 0 : "The index must point at an existing key." ; assert index <= mask || ( index == mask + 1 && hasEmptyKey ) ; assert Intrinsics . equals ( this , keys [ index ] , equivalentKey ) ; KType previousValue = Intrinsics . < KType > cast ( keys ...
Replaces the existing equivalent key with the given one and returns any previous value stored for that key .
30,517
public void indexInsert ( int index , KType key ) { assert index < 0 : "The index must not point at an existing key." ; index = ~ index ; if ( Intrinsics . isEmpty ( key ) ) { assert index == mask + 1 ; assert Intrinsics . isEmpty ( keys [ index ] ) ; hasEmptyKey = true ; } else { assert Intrinsics . isEmpty ( keys [ i...
Inserts a key for an index that is not present in the set . This method may help in avoiding double recalculation of the key s hash .
30,518
private static void topDownMergeSort ( int [ ] src , int [ ] dst , int fromIndex , int toIndex , IndirectComparator comp ) { if ( toIndex - fromIndex <= MIN_LENGTH_FOR_INSERTION_SORT ) { insertionSort ( fromIndex , toIndex - fromIndex , dst , comp ) ; return ; } final int mid = ( fromIndex + toIndex ) >>> 1 ; topDownMe...
Perform a recursive descending merge sort .
30,519
private static int [ ] createOrderArray ( final int start , final int length ) { final int [ ] order = new int [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { order [ i ] = start + i ; } return order ; }
Creates the initial order array .
30,520
public void add ( KType [ ] elements , int start , int length ) { assert length >= 0 : "Length must be >= 0" ; ensureBufferSpace ( length ) ; System . arraycopy ( elements , start , buffer , elementsCount , length ) ; elementsCount += length ; }
Add all elements from a range of given array to the list .
30,521
public int addAll ( KTypeContainer < ? extends KType > container ) { final int size = container . size ( ) ; ensureBufferSpace ( size ) ; for ( KTypeCursor < ? extends KType > cursor : container ) { add ( cursor . value ) ; } return size ; }
Adds all elements from another container .
30,522
public int addAll ( Iterable < ? extends KTypeCursor < ? extends KType > > iterable ) { int size = 0 ; for ( KTypeCursor < ? extends KType > cursor : iterable ) { add ( cursor . value ) ; size ++ ; } return size ; }
Adds all elements from another iterable .
30,523
public int addFirst ( Iterable < ? extends KTypeCursor < ? extends KType > > iterable ) { int size = 0 ; for ( KTypeCursor < ? extends KType > cursor : iterable ) { addFirst ( cursor . value ) ; size ++ ; } return size ; }
Inserts all elements from the given iterable to the front of this deque .
30,524
public int addLast ( KTypeContainer < ? extends KType > container ) { int size = container . size ( ) ; ensureBufferSpace ( size ) ; for ( KTypeCursor < ? extends KType > cursor : container ) { addLast ( cursor . value ) ; } return size ; }
Inserts all elements from the given container to the end of this deque .
30,525
public int addLast ( Iterable < ? extends KTypeCursor < ? extends KType > > iterable ) { int size = 0 ; for ( KTypeCursor < ? extends KType > cursor : iterable ) { addLast ( cursor . value ) ; size ++ ; } return size ; }
Inserts all elements from the given iterable to the end of this deque .
30,526
public static long pop_array ( long [ ] arr , int wordOffset , int numWords ) { long popCount = 0 ; for ( int i = wordOffset , end = wordOffset + numWords ; i < end ; ++ i ) { popCount += Long . bitCount ( arr [ i ] ) ; } return popCount ; }
Returns the number of set bits in an array of longs .
30,527
public static long pop_intersect ( long [ ] arr1 , long [ ] arr2 , int wordOffset , int numWords ) { long popCount = 0 ; for ( int i = wordOffset , end = wordOffset + numWords ; i < end ; ++ i ) { popCount += Long . bitCount ( arr1 [ i ] & arr2 [ i ] ) ; } return popCount ; }
Returns the popcount or cardinality of the two sets after an intersection . Neither array is modified .
30,528
public static int mix32 ( int k ) { k = ( k ^ ( k >>> 16 ) ) * 0x85ebca6b ; k = ( k ^ ( k >>> 13 ) ) * 0xc2b2ae35 ; return k ^ ( k >>> 16 ) ; }
MH3 s plain finalization step .
30,529
private void generate ( TemplateFile input , List < OutputFile > outputs , TemplateOptions templateOptions ) throws IOException { final String targetFileName = targetFileName ( templatesPath . relativize ( input . path ) . toString ( ) , templateOptions ) ; final OutputFile output = new OutputFile ( outputPath . resolv...
Apply templates .
30,530
private String filterVelocity ( TemplateFile f , String template , TemplateOptions options ) { final VelocityContext ctx = new VelocityContext ( ) ; ctx . put ( "TemplateOptions" , options ) ; ctx . put ( "true" , true ) ; ctx . put ( "templateOnly" , false ) ; ctx . put ( "false" , false ) ; StringWriter sw = new Stri...
Apply velocity to the input .
30,531
private List < TemplateFile > collectTemplateFiles ( Path dir ) throws IOException { final List < TemplateFile > paths = new ArrayList < > ( ) ; for ( Path path : scanFilesMatching ( dir , "glob:**.java" ) ) { paths . add ( new TemplateFile ( path ) ) ; } return paths ; }
Collect all template files from this and subdirectories .
30,532
public static ToastCompat makeText ( Context context , CharSequence text , int duration ) { @ SuppressLint ( "ShowToast" ) Toast toast = Toast . makeText ( context , text , duration ) ; setContextCompat ( toast . getView ( ) , new SafeToastContext ( context , toast ) ) ; return new ToastCompat ( context , toast ) ; }
Make a standard toast that just contains a text view .
30,533
void switchTwoColumns ( int columnIndex , int columnToIndex ) { checkForInit ( ) ; int cellData = mColumnWidths [ columnToIndex ] ; mColumnWidths [ columnToIndex ] = mColumnWidths [ columnIndex ] ; mColumnWidths [ columnIndex ] = cellData ; }
Switch 2 items in array with columns data
30,534
void switchTwoRows ( int rowIndex , int rowToIndex ) { checkForInit ( ) ; int cellData = mRowHeights [ rowToIndex ] ; mRowHeights [ rowToIndex ] = mRowHeights [ rowIndex ] ; mRowHeights [ rowIndex ] = cellData ; }
Switch 2 items in array with rows data
30,535
void remove ( int row , int column ) { SparseArrayCompat < TObj > array = mData . get ( row ) ; if ( array != null ) { array . remove ( column ) ; } }
Remove item in row column position int the matrix
30,536
private void refreshViewHolders ( ) { if ( mAdapter != null ) { for ( ViewHolder holder : mViewHolders . getAll ( ) ) { if ( holder != null ) { refreshItemViewHolder ( holder , mState . isRowDragging ( ) , mState . isColumnDragging ( ) ) ; } } if ( mState . isColumnDragging ( ) ) { refreshAllColumnHeadersHolders ( ) ; ...
Refresh all view holders
30,537
private void refreshHeaderColumnViewHolder ( ViewHolder holder ) { int left = getEmptySpace ( ) + mManager . getColumnsWidth ( 0 , Math . max ( 0 , holder . getColumnIndex ( ) ) ) ; if ( ! isRTL ( ) ) { left += mManager . getHeaderRowWidth ( ) ; } int top = mSettings . isHeaderFixed ( ) ? 0 : - mState . getScrollY ( ) ...
Refresh current column header view holder .
30,538
private void recycleViewHolders ( boolean isRecycleAll ) { if ( mAdapter == null ) { return ; } final List < Integer > headerKeysToRemove = new ArrayList < > ( ) ; for ( ViewHolder holder : mViewHolders . getAll ( ) ) { if ( holder != null && ! holder . isDragging ( ) ) { View view = holder . getItemView ( ) ; if ( isR...
Recycle view holders outside screen
30,539
private void removeKeys ( List < Integer > keysToRemove , SparseArrayCompat < ViewHolder > headers ) { for ( Integer key : keysToRemove ) { headers . remove ( key ) ; } }
Remove recycled viewholders from sparseArray
30,540
private void recycleViewHolder ( ViewHolder holder ) { mRecycler . pushRecycledView ( holder ) ; removeView ( holder . getItemView ( ) ) ; mAdapter . onViewHolderRecycled ( holder ) ; }
Recycle view holder and remove view from layout .
30,541
private void addViewHolders ( Rect filledArea ) { int leftColumn = mManager . getColumnByXWithShift ( filledArea . left , mSettings . getCellMargin ( ) ) ; int rightColumn = mManager . getColumnByXWithShift ( filledArea . right , mSettings . getCellMargin ( ) ) ; int topRow = mManager . getRowByYWithShift ( filledArea ...
Create and add view holders with views to the layout .
30,542
private ViewHolder createViewHolder ( int itemType ) { if ( itemType == ViewHolderType . ITEM ) { return mAdapter . onCreateItemViewHolder ( AdaptiveTableLayout . this ) ; } else if ( itemType == ViewHolderType . ROW_HEADER ) { return mAdapter . onCreateRowHeaderViewHolder ( AdaptiveTableLayout . this ) ; } else if ( i...
Create view holder by type
30,543
private void shiftColumnsViews ( final int fromColumn , final int toColumn ) { if ( mAdapter != null ) { mAdapter . changeColumns ( getBindColumn ( fromColumn ) , getBindColumn ( toColumn ) ) ; switchHeaders ( mHeaderColumnViewHolders , fromColumn , toColumn , ViewHolderType . COLUMN_HEADER ) ; mManager . switchTwoColu...
Method change columns . Change view holders indexes kay in map init changing items in adapter .
30,544
private void shiftRowsViews ( final int fromRow , final int toRow ) { if ( mAdapter != null ) { mAdapter . changeRows ( fromRow , toRow , mSettings . isSolidRowHeader ( ) ) ; switchHeaders ( mHeaderRowViewHolders , fromRow , toRow , ViewHolderType . ROW_HEADER ) ; mManager . switchTwoRows ( fromRow , toRow ) ; Collecti...
Method change rows . Change view holders indexes kay in map init changing items in adapter .
30,545
@ SuppressWarnings ( "unused" ) private void setDraggingToColumn ( int column , boolean isDragging ) { Collection < ViewHolder > holders = mViewHolders . getColumnItems ( column ) ; for ( ViewHolder holder : holders ) { holder . setIsDragging ( isDragging ) ; } ViewHolder holder = mHeaderColumnViewHolders . get ( colum...
Method set dragging flag to all view holders in the specific column
30,546
@ SuppressWarnings ( "unused" ) private void setDraggingToRow ( int row , boolean isDragging ) { Collection < ViewHolder > holders = mViewHolders . getRowItems ( row ) ; for ( ViewHolder holder : holders ) { holder . setIsDragging ( isDragging ) ; } ViewHolder holder = mHeaderRowViewHolders . get ( row ) ; if ( holder ...
Method set dragging flag to all view holders in the specific row
30,547
void switchTwoColumns ( int columnIndex , int columnToIndex ) { for ( int i = 0 ; i < getRowCount ( ) - 1 ; i ++ ) { Object cellData = getItems ( ) [ i ] [ columnToIndex ] ; getItems ( ) [ i ] [ columnToIndex ] = getItems ( ) [ i ] [ columnIndex ] ; getItems ( ) [ i ] [ columnIndex ] = cellData ; } }
Switch 2 columns with data
30,548
void switchTwoColumnHeaders ( int columnIndex , int columnToIndex ) { Object cellData = getColumnHeaders ( ) [ columnToIndex ] ; getColumnHeaders ( ) [ columnToIndex ] = getColumnHeaders ( ) [ columnIndex ] ; getColumnHeaders ( ) [ columnIndex ] = cellData ; }
Switch 2 columns headers with data
30,549
void switchTwoRows ( int rowIndex , int rowToIndex ) { for ( int i = 0 ; i < getItems ( ) . length ; i ++ ) { Object cellData = getItems ( ) [ rowToIndex ] [ i ] ; getItems ( ) [ rowToIndex ] [ i ] = getItems ( ) [ rowIndex ] [ i ] ; getItems ( ) [ rowIndex ] [ i ] = cellData ; } }
Switch 2 rows with data
30,550
void switchTwoRowHeaders ( int rowIndex , int rowToIndex ) { Object cellData = getRowHeaders ( ) [ rowToIndex ] ; getRowHeaders ( ) [ rowToIndex ] = getRowHeaders ( ) [ rowIndex ] ; getRowHeaders ( ) [ rowIndex ] = cellData ; }
Switch 2 rows headers with data
30,551
public static DB newEmbeddedDB ( DBConfiguration config ) throws ManagedProcessException { DB db = new DB ( config ) ; db . prepareDirectories ( ) ; db . unpackEmbeddedDb ( ) ; db . install ( ) ; return db ; }
This factory method is the mechanism for constructing a new embedded database for use . This method automatically installs the database and prepares it for use .
30,552
public static DB newEmbeddedDB ( int port ) throws ManagedProcessException { DBConfigurationBuilder config = new DBConfigurationBuilder ( ) ; config . setPort ( port ) ; return newEmbeddedDB ( config . build ( ) ) ; }
This factory method is the mechanism for constructing a new embedded database for use . This method automatically installs the database and prepares it for use with default configuration allowing only for specifying port .
30,553
synchronized protected void install ( ) throws ManagedProcessException { try { ManagedProcess mysqlInstallProcess = installPreparation ( ) ; mysqlInstallProcess . start ( ) ; mysqlInstallProcess . waitForExit ( ) ; } catch ( Exception e ) { throw new ManagedProcessException ( "An error occurred while installing the dat...
Installs the database to the location specified in the configuration .
30,554
public synchronized void start ( ) throws ManagedProcessException { logger . info ( "Starting up the database..." ) ; boolean ready = false ; try { mysqldProcess = startPreparation ( ) ; ready = mysqldProcess . startAndWaitForConsoleMessageMaxMs ( getReadyForConnectionsTag ( ) , dbStartMaxWaitInMS ) ; } catch ( Excepti...
Starts up the database using the data directory and port specified in the configuration .
30,555
public void source ( String resource , String username , String password , String dbName ) throws ManagedProcessException { InputStream from = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( resource ) ; if ( from == null ) throw new IllegalArgumentException ( "Could not find script file on the classpath at: ...
Takes in a string that represents a resource on the classpath and sources it via the mysql command line tool .
30,556
public synchronized void stop ( ) throws ManagedProcessException { if ( mysqldProcess . isAlive ( ) ) { logger . debug ( "Stopping the database..." ) ; mysqldProcess . destroy ( ) ; logger . info ( "Database stopped." ) ; } else { logger . debug ( "Database was already stopped." ) ; } }
Stops the database .
30,557
protected void unpackEmbeddedDb ( ) { if ( configuration . getBinariesClassPathLocation ( ) == null ) { logger . info ( "Not unpacking any embedded database (as BinariesClassPathLocation configuration is null)" ) ; return ; } try { Util . extractFromClasspathToFile ( configuration . getBinariesClassPathLocation ( ) , b...
Based on the current OS unpacks the appropriate version of MariaDB to the file system based on the configuration .
30,558
protected void prepareDirectories ( ) throws ManagedProcessException { baseDir = Util . getDirectory ( configuration . getBaseDir ( ) ) ; libDir = Util . getDirectory ( configuration . getLibDir ( ) ) ; try { String dataDirPath = configuration . getDataDir ( ) ; if ( Util . isTemporaryDirectory ( dataDirPath ) ) { File...
If the data directory specified in the configuration is a temporary directory this deletes any previous version . It also makes sure that the directory exists .
30,559
protected void cleanupOnExit ( ) { String threadName = "Shutdown Hook Deletion Thread for Temporary DB " + dataDir . toString ( ) ; final DB db = this ; Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( threadName ) { public void run ( ) { try { if ( mysqldProcess != null && mysqldProcess . isAlive ( ) ) { logg...
Adds a shutdown hook to ensure that when the JVM exits the database is stopped and any temporary data directories are cleaned up .
30,560
public ManagedProcess dumpXML ( File outputFile , String dbName , String user , String password ) throws IOException , ManagedProcessException { return dump ( outputFile , Arrays . asList ( dbName ) , true , true , true , user , password ) ; }
unexpected deadlock ) .
30,561
public static int extractFromClasspathToFile ( String packagePath , File toDir ) throws IOException { String locationPattern = "classpath*:" + packagePath + "/**" ; ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver ( ) ; Resource [ ] resources = resourcePatternResolver . getResou...
Extract files from a package on the classpath into a directory .
30,562
private OkHttpConnector connector ( GitHubServerConfig config ) { OkHttpClient client = new OkHttpClient ( ) . setProxy ( getProxy ( defaultIfBlank ( config . getApiUrl ( ) , GITHUB_URL ) ) ) ; if ( config . getClientCacheSize ( ) > 0 ) { Cache cache = toCacheDir ( ) . apply ( config ) ; client . setCache ( cache ) ; }...
okHttp connector to be used as backend for GitHub client . Uses proxy of jenkins If cache size > 0 uses cache
30,563
public static < ITEM extends Item > Predicate < ITEM > isBuildable ( ) { return new Predicate < ITEM > ( ) { public boolean apply ( ITEM item ) { return item instanceof Job ? ( ( Job < ? , ? > ) item ) . isBuildable ( ) : item instanceof BuildableItem ; } } ; }
Can be useful to ignore disabled jobs on reregistering hooks
30,564
public static < ITEM extends Item > Predicate < ITEM > isAlive ( ) { return new Predicate < ITEM > ( ) { public boolean apply ( ITEM item ) { return ! from ( GHEventsSubscriber . all ( ) ) . filter ( isApplicableFor ( item ) ) . toList ( ) . isEmpty ( ) ; } } ; }
If any of event subscriber interested in hook for item then return true By default push hook subscriber is interested in job with gh - push - trigger
30,565
public static String asValidHref ( String urlString ) { try { return new URL ( urlString ) . toExternalForm ( ) ; } catch ( MalformedURLException e ) { LOG . debug ( "Malformed url - {}, empty string will be returned" , urlString ) ; return "" ; } }
Method to filter invalid url for XSS . This url can be inserted to href safely
30,566
public HttpResponse doAct ( StaplerRequest req ) throws IOException { if ( req . hasParameter ( "no" ) ) { disable ( true ) ; return HttpResponses . redirectViaContextPath ( "/manage" ) ; } else { return new HttpRedirect ( "." ) ; } }
Depending on whether the user said yes or no send them to the right place .
30,567
public void unregisterFor ( GitHubRepositoryName name , List < GitHubRepositoryName > aliveRepos ) { try { GHRepository repo = checkNotNull ( from ( name . resolve ( allowedToManageHooks ( ) ) ) . firstMatch ( withAdminAccess ( ) ) . orNull ( ) , "There are no credentials with admin access to manage hooks on %s" , name...
Used to cleanup old hooks in case of removed or reconfigured trigger since JENKINS - 28138 this method permanently removes service hooks
30,568
public static BetterThanOrEqualBuildResult betterThanOrEqualTo ( Result result , GHCommitState state , String msg ) { BetterThanOrEqualBuildResult conditional = new BetterThanOrEqualBuildResult ( ) ; conditional . setResult ( result . toString ( ) ) ; conditional . setState ( state . name ( ) ) ; conditional . setMessa...
Convenient way to reuse logic of checking for the build status
30,569
public static BuildData calculateBuildData ( String parentName , String parentFullName , List < BuildData > buildDataList ) { if ( buildDataList == null ) { return null ; } if ( buildDataList . size ( ) == 1 ) { return buildDataList . get ( 0 ) ; } String projectName = parentFullName . replace ( parentName , "" ) ; if ...
Calculate build data from downstream builds that could be a shared library which is loaded first in a pipeline . For that reason this method compares all remote URLs for each build data with the real project name to determine the proper build data . This way the SHA returned in the build data will relate to the project
30,570
public Iterable < GitHub > findGithubConfig ( Predicate < GitHubServerConfig > match ) { Function < GitHubServerConfig , GitHub > loginFunction = loginToGithub ( ) ; if ( Objects . isNull ( loginFunction ) ) { return Collections . emptyList ( ) ; } return from ( getConfigs ( ) ) . filter ( match ) . transform ( loginFu...
Filters all stored configs against given predicate then logs in as the given user and returns the non null connection objects
30,571
public String commitId ( final String id ) { return new StringBuilder ( ) . append ( baseUrl ) . append ( "commit/" ) . append ( id ) . toString ( ) ; }
Returns the URL to a particular commit .
30,572
public String expandAll ( Run < ? , ? > run , TaskListener listener ) throws IOException , InterruptedException { if ( run instanceof AbstractBuild ) { try { return TokenMacro . expandAll ( ( AbstractBuild ) run , listener , content , false , Collections . < TokenMacro > emptyList ( ) ) ; } catch ( MacroEvaluationExcep...
Expands all env vars . In case of AbstractBuild also expands token macro and build vars
30,573
@ SuppressWarnings ( "deprecation" ) public String get ( Run < ? , ? > run , TaskListener listener ) { return DisplayURLProvider . get ( ) . getRunURL ( run ) ; }
Returns absolute URL of the Run
30,574
protected void onEvent ( GHEvent event , String payload ) { GHEventPayload . Ping ping ; try { ping = GitHub . offline ( ) . parseEventPayload ( new StringReader ( payload ) , GHEventPayload . Ping . class ) ; } catch ( IOException e ) { LOGGER . warn ( "Received malformed PingEvent: " + payload , e ) ; return ; } GHRe...
Logs repo on ping event
30,575
public static DirectoryStream . Filter < Path > notInCaches ( Set < String > caches ) { checkNotNull ( caches , "set of active caches can't be null" ) ; return new NotInCachesFilter ( caches ) ; }
To accept for cleaning only not active cache dirs
30,576
public static void clearRedundantCaches ( List < GitHubServerConfig > configs ) { Path baseCacheDir = getBaseCacheDir ( ) ; if ( notExists ( baseCacheDir ) ) { return ; } final Set < String > actualNames = from ( configs ) . filter ( withEnabledCache ( ) ) . transform ( toCacheDir ( ) ) . transform ( cacheToName ( ) ) ...
Removes all not active dirs with old caches . This method is invoked after each save of global plugin config
30,577
private static void deleteEveryIn ( DirectoryStream < Path > caches ) { for ( Path notActualCache : caches ) { LOGGER . debug ( "Deleting redundant cache dir {}" , notActualCache ) ; try { FileUtils . deleteDirectory ( notActualCache . toFile ( ) ) ; } catch ( IOException e ) { LOGGER . error ( "Can't delete cache dir ...
Removes directories with caches
30,578
@ Initializer ( after = InitMilestone . EXTENSIONS_AUGMENTED , before = InitMilestone . JOB_LOADED ) public static void runMigrator ( ) throws Exception { new Migrator ( ) . migrate ( ) ; }
Launches migration after all extensions have been augmented as we need to ensure that the credentials plugin has been initialized . We need ensure that migrator will run after xstream aliases will be added .
30,579
protected Function < Credential , GitHubServerConfig > toGHServerConfig ( ) { return new Function < Credential , GitHubServerConfig > ( ) { public GitHubServerConfig apply ( Credential input ) { LOGGER . info ( "Migrate GitHub Plugin creds for {} {}" , input . getUsername ( ) , input . getApiUrl ( ) ) ; GitHubTokenCred...
Creates new string credentials from token
30,580
public void focus ( ) { requestFocus ( ) ; InputMethodManager inputMethodManager = ( InputMethodManager ) getContext ( ) . getSystemService ( Context . INPUT_METHOD_SERVICE ) ; inputMethodManager . showSoftInput ( this , 0 ) ; }
Request focus on this PinEntryEditText
30,581
public void openSettingsScreen ( ) { Intent intent = new Intent ( ) ; intent . setAction ( Settings . ACTION_APPLICATION_DETAILS_SETTINGS ) ; Uri uri = Uri . parse ( "package:" + context . getContext ( ) . getPackageName ( ) ) ; intent . setData ( uri ) ; context . startActivity ( intent ) ; }
open android settings screen for the specific package name
30,582
protected void requestPermission ( final PermissionModel model ) { new AlertDialog . Builder ( this ) . setTitle ( model . getTitle ( ) ) . setMessage ( model . getExplanationMessage ( ) ) . setPositiveButton ( "Request" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int wh...
internal usage to show dialog with explanation you provided and a button to ask the user to request the permission
30,583
void performFlush ( ) { if ( ! shouldFlush ( ) ) { return ; } logger . verbose ( "Uploading payloads in queue to Segment." ) ; int payloadsUploaded = 0 ; Client . Connection connection = null ; try { connection = client . upload ( ) ; BatchPayloadWriter writer = new BatchPayloadWriter ( connection . os ) . beginObject ...
Upload payloads to our servers and remove them from the queue file .
30,584
public Date timestamp ( ) { String timestamp = getString ( TIMESTAMP_KEY ) ; if ( isNullOrEmpty ( timestamp ) ) { return null ; } return parseISO8601Date ( timestamp ) ; }
Set a timestamp the event occurred .
30,585
static Traits create ( ) { Traits traits = new Traits ( new NullableConcurrentHashMap < String , Object > ( ) ) ; traits . putAnonymousId ( UUID . randomUUID ( ) . toString ( ) ) ; return traits ; }
Create a new Traits instance with an anonymous ID . Analytics client can be called on any thread so this instance is thread safe .
30,586
public ValueMap putValue ( String key , Object value ) { delegate . put ( key , value ) ; return this ; }
Helper method to be able to chain put methods .
30,587
public String event ( ) { String name = name ( ) ; if ( ! isNullOrEmpty ( name ) ) { return name ; } return category ( ) ; }
Either the name or category of the screen payload .
30,588
public Options setIntegration ( String integrationKey , boolean enabled ) { if ( SegmentIntegration . SEGMENT_KEY . equals ( integrationKey ) ) { throw new IllegalArgumentException ( "Segment integration cannot be enabled or disabled." ) ; } integrations . put ( integrationKey , enabled ) ; return this ; }
Sets whether an action will be sent to the target integration .
30,589
public Options setIntegrationOptions ( String integrationKey , Map < String , Object > options ) { integrations . put ( integrationKey , options ) ; return this ; }
Attach some integration specific options for this call .
30,590
public static < T > Set < T > newSet ( T ... values ) { Set < T > set = new HashSet < > ( values . length ) ; Collections . addAll ( set , values ) ; return set ; }
Creates a mutable HashSet instance containing the given elements in unspecified order
30,591
@ SuppressLint ( "HardwareIds" ) public static String getDeviceId ( Context context ) { String androidId = getString ( context . getContentResolver ( ) , ANDROID_ID ) ; if ( ! isNullOrEmpty ( androidId ) && ! "9774d56d682e549c" . equals ( androidId ) && ! "unknown" . equals ( androidId ) && ! "000000000000000" . equals...
Creates a unique device id . Suppresses HardwareIds lint warnings as we don t use this ID for identifying specific users . This is also what is required by the Segment spec .
30,592
public static SharedPreferences getSegmentSharedPreferences ( Context context , String tag ) { return context . getSharedPreferences ( "analytics-android-" + tag , MODE_PRIVATE ) ; }
Returns a shared preferences for storing any library preferences .
30,593
public static String getResourceString ( Context context , String key ) { int id = getIdentifier ( context , "string" , key ) ; if ( id != 0 ) { return context . getResources ( ) . getString ( id ) ; } else { return null ; } }
Get the string resource for the given key . Returns null if not found .
30,594
private static int getIdentifier ( Context context , String type , String key ) { return context . getResources ( ) . getIdentifier ( key , type , context . getPackageName ( ) ) ; }
Get the identifier for the resource with a given type and key .
30,595
public static void createDirectory ( File location ) throws IOException { if ( ! ( location . exists ( ) || location . mkdirs ( ) || location . isDirectory ( ) ) ) { throw new IOException ( "Could not create directory at " + location ) ; } }
Ensures that a directory is created in the given location throws an IOException otherwise .
30,596
public void screen ( String category , String name , Properties properties ) { if ( isNullOrEmpty ( category ) && isNullOrEmpty ( name ) ) { throw new IllegalArgumentException ( "either category or name must be provided." ) ; } if ( properties == null ) { properties = new Properties ( ) ; } dispatcher . dispatchPayload...
The screen methods let your record whenever a user sees a screen of your mobile app and attach a name category or properties to the screen .
30,597
private static void listToWriter ( List < ? > list , JsonWriter writer ) throws IOException { writer . beginArray ( ) ; for ( Object value : list ) { writeValue ( value , writer ) ; } writer . endArray ( ) ; }
Print the json representation of a List to the given writer .
30,598
public void verbose ( String format , Object ... extra ) { if ( shouldLog ( VERBOSE ) ) { Log . v ( tag , String . format ( format , extra ) ) ; } }
Log a verbose message .
30,599
public void info ( String format , Object ... extra ) { if ( shouldLog ( INFO ) ) { Log . i ( tag , String . format ( format , extra ) ) ; } }
Log an info message .