idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
5,500
public static int nvgraphExtractSubgraphByVertex ( nvgraphHandle handle , nvgraphGraphDescr descrG , nvgraphGraphDescr subdescrG , Pointer subvertices , long numvertices ) { return checkResult ( nvgraphExtractSubgraphByVertexNative ( handle , descrG , subdescrG , subvertices , numvertices ) ) ; }
create a new graph by extracting a subgraph given a list of vertices
5,501
public static int nvgraphExtractSubgraphByEdge ( nvgraphHandle handle , nvgraphGraphDescr descrG , nvgraphGraphDescr subdescrG , Pointer subedges , long numedges ) { return checkResult ( nvgraphExtractSubgraphByEdgeNative ( handle , descrG , subdescrG , subedges , numedges ) ) ; }
create a new graph by extracting a subgraph given a list of edges
5,502
public static int nvgraphSrSpmv ( nvgraphHandle handle , nvgraphGraphDescr descrG , long weight_index , Pointer alpha , long x_index , Pointer beta , long y_index , int SR ) { return checkResult ( nvgraphSrSpmvNative ( handle , descrG , weight_index , alpha , x_index , beta , y_index , SR ) ) ; }
nvGRAPH Semi - ring sparse matrix vector multiplication
5,503
public static int nvgraphWidestPath ( nvgraphHandle handle , nvgraphGraphDescr descrG , long weight_index , Pointer source_vert , long widest_path_index ) { return checkResult ( nvgraphWidestPathNative ( handle , descrG , weight_index , source_vert , widest_path_index ) ) ; }
nvGRAPH WidestPath Find widest path potential from source_index to every other vertices .
5,504
public static int nvgraphPagerank ( nvgraphHandle handle , nvgraphGraphDescr descrG , long weight_index , Pointer alpha , long bookmark_index , int has_guess , long pagerank_index , float tolerance , int max_iter ) { return checkResult ( nvgraphPagerankNative ( handle , descrG , weight_index , alpha , bookmark_index , has_guess , pagerank_index , tolerance , max_iter ) ) ; }
nvGRAPH PageRank Find PageRank for each vertex of a graph with a given transition probabilities a bookmark vector of dangling vertices and the damping factor .
5,505
public void setRegionCoverageSize ( int size ) { if ( size < 0 ) { return ; } int lg = ( int ) Math . ceil ( Math . log ( size ) / Math . log ( 2 ) ) ; int newRegionCoverageSize = 1 << lg ; int newRegionCoverageMask = newRegionCoverageSize - 1 ; RegionCoverage newCoverage = new RegionCoverage ( newRegionCoverageSize ) ; if ( coverage != null ) { for ( int i = 0 ; i < ( end - start ) ; i ++ ) { newCoverage . getA ( ) [ ( int ) ( ( start + i ) & newRegionCoverageMask ) ] = coverage . getA ( ) [ ( int ) ( ( start + i ) & regionCoverageMask ) ] ; } } regionCoverageSize = newRegionCoverageSize ; regionCoverageMask = newRegionCoverageMask ; coverage = newCoverage ; }
Set size to the nearest upper 2^n number for quick modulus operation
5,506
public void attach ( JComponent owner ) { detach ( ) ; toolTipDialog = new TransparentToolTipDialog ( owner , new AnchorLink ( Anchor . CENTER_RIGHT , Anchor . CENTER_LEFT ) ) ; }
Attaches the tooltip sticker to the specified component .
5,507
protected String getToolTipText ( ) { String tip = null ; if ( toolTipDialog != null ) { tip = toolTipDialog . getText ( ) ; } return tip ; }
Gets the tooltip text to be displayed .
5,508
protected T construct ( ) { if ( _targetConstructor . isPresent ( ) ) { return _targetConstructor . get ( ) . apply ( this ) ; } try { final Constructor < ? extends T > constructor = _targetClass . get ( ) . getDeclaredConstructor ( this . getClass ( ) ) ; AccessController . doPrivileged ( ( PrivilegedAction < Object > ) ( ) -> { constructor . setAccessible ( true ) ; return null ; } ) ; return constructor . newInstance ( this ) ; } catch ( final NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException e ) { throw new UnsupportedOperationException ( String . format ( UNABLE_TO_CONSTRUCT_TARGET_CLASS , _targetClass ) , e ) ; } catch ( final InvocationTargetException e ) { final Throwable cause = e . getCause ( ) ; if ( cause instanceof RuntimeException ) { throw ( RuntimeException ) cause ; } throw new UnsupportedOperationException ( String . format ( UNABLE_TO_CONSTRUCT_TARGET_CLASS , _targetClass ) , cause ) ; } }
Protected method to construct the target class reflectively from the specified type by passing its constructor an instance of this builder .
5,509
private void updateValue ( ) { if ( table != null ) { int oldCount = this . count ; this . count = table . getSelectedRowCount ( ) ; maybeNotifyListeners ( oldCount , count ) ; } }
Updates the value of this property based on the table s selection model and notify the listeners .
5,510
public static void katakanaToRomaji ( Appendable builder , CharSequence s ) throws IOException { ToStringUtil . getRomanization ( builder , s ) ; }
Romanize katakana with modified hepburn
5,511
private DetailAST getExprAst ( final DetailAST pAst ) { DetailAST result = null ; for ( DetailAST a = pAst . getFirstChild ( ) ; a != null ; a = a . getNextSibling ( ) ) { if ( a . getType ( ) != TokenTypes . LPAREN && a . getType ( ) != TokenTypes . RPAREN ) { result = a ; break ; } } return result ; }
Find the meaningful child of an EXPR AST . This is usually the only child present but it may be surrounded by parentheses .
5,512
public QueryResult < T > first ( ) { if ( response != null && response . size ( ) > 0 ) { return response . get ( 0 ) ; } return null ; }
This method just returns the first QueryResult of response or null if response is null or empty .
5,513
private void attach ( JComponent componentToBeDecorated ) { detach ( ) ; decoratedComponent = componentToBeDecorated ; if ( decoratedComponent != null ) { decoratedComponent . addComponentListener ( decoratedComponentTracker ) ; decoratedComponent . addAncestorListener ( decoratedComponentTracker ) ; decoratedComponent . addHierarchyBoundsListener ( decoratedComponentTracker ) ; decoratedComponent . addHierarchyListener ( decoratedComponentTracker ) ; decoratedComponent . addPropertyChangeListener ( "enabled" , decoratedComponentTracker ) ; decoratedComponent . addPropertyChangeListener ( "ancestor" , decoratedComponentTracker ) ; attachToLayeredPane ( ) ; } }
Attaches the decoration to the specified component .
5,514
private void detach ( ) { if ( decoratedComponent != null ) { decoratedComponent . removeComponentListener ( decoratedComponentTracker ) ; decoratedComponent . removeAncestorListener ( decoratedComponentTracker ) ; decoratedComponent . removeHierarchyBoundsListener ( decoratedComponentTracker ) ; decoratedComponent . removeHierarchyListener ( decoratedComponentTracker ) ; decoratedComponent . removePropertyChangeListener ( "enabled" , decoratedComponentTracker ) ; decoratedComponent . removePropertyChangeListener ( "ancestor" , decoratedComponentTracker ) ; decoratedComponent = null ; detachFromLayeredPane ( ) ; } }
Detaches the decoration from the decorated component .
5,515
private void attachToLayeredPane ( ) { Container ancestor = SwingUtilities . getAncestorOfClass ( JLayeredPane . class , decoratedComponent ) ; if ( ancestor instanceof JLayeredPane ) { attachedLayeredPane = ( JLayeredPane ) ancestor ; Integer layer = getDecoratedComponentLayerInLayeredPane ( attachedLayeredPane ) ; attachedLayeredPane . remove ( decorationPainter ) ; attachedLayeredPane . add ( decorationPainter , layer ) ; } else { detachFromLayeredPane ( ) ; } }
Inserts the decoration to the layered pane right above the decorated component .
5,516
private Integer getDecoratedComponentLayerInLayeredPane ( JLayeredPane layeredPane ) { Container ancestorInLayer = decoratedComponent ; while ( ! layeredPane . equals ( ancestorInLayer . getParent ( ) ) ) { ancestorInLayer = ancestorInLayer . getParent ( ) ; } return ( layeredPane . getLayer ( ancestorInLayer ) + DECORATION_LAYER_OFFSET ) ; }
Retrieves the layer index of the decorated component in the layered pane of the window .
5,517
private void updateDecorationPainterVisibility ( ) { boolean shouldBeVisible = ( decoratedComponent != null ) && ( paintWhenDisabled || decoratedComponent . isEnabled ( ) ) && decoratedComponent . isShowing ( ) && visible ; if ( shouldBeVisible != decorationPainter . isVisible ( ) ) { decorationPainter . setVisible ( shouldBeVisible ) ; } }
Updates the visibility of the decoration painter according to the visible state set by the programmer and the state of the decorated component .
5,518
private void followDecoratedComponent ( JLayeredPane layeredPane ) { Point relativeLocationToOwner = anchorLink . getRelativeSlaveLocation ( decoratedComponent . getWidth ( ) , decoratedComponent . getHeight ( ) , getWidth ( ) , getHeight ( ) ) ; updateDecorationPainterUnclippedBounds ( layeredPane , relativeLocationToOwner ) ; updateDecorationPainterClippedBounds ( layeredPane , relativeLocationToOwner ) ; if ( layeredPane != null ) { decorationPainter . revalidate ( ) ; decorationPainter . repaint ( ) ; } }
Updates the decoration painter in the specified layered pane .
5,519
private void updateDecorationPainterUnclippedBounds ( JLayeredPane layeredPane , Point relativeLocationToOwner ) { Rectangle decorationBoundsInLayeredPane ; if ( layeredPane == null ) { decorationBoundsInLayeredPane = new Rectangle ( ) ; } else { Point decoratedComponentLocationInLayeredPane = SwingUtilities . convertPoint ( decoratedComponent . getParent ( ) , decoratedComponent . getLocation ( ) , layeredPane ) ; decorationBoundsInLayeredPane = new Rectangle ( decoratedComponentLocationInLayeredPane . x + relativeLocationToOwner . x , decoratedComponentLocationInLayeredPane . y + relativeLocationToOwner . y , getWidth ( ) , getHeight ( ) ) ; } decorationPainter . setBounds ( decorationBoundsInLayeredPane ) ; }
Calculates and updates the unclipped bounds of the decoration painter in layered pane coordinates .
5,520
private void updateDecorationPainterClippedBounds ( JLayeredPane layeredPane , Point relativeLocationToOwner ) { if ( layeredPane == null ) { decorationPainter . setClipBounds ( null ) ; } else { JComponent clippingComponent = getEffectiveClippingAncestor ( ) ; if ( clippingComponent == null ) { LOGGER . error ( "No decoration clipping component can be found for decorated component: " + decoratedComponent ) ; decorationPainter . setClipBounds ( null ) ; } else if ( clippingComponent . isShowing ( ) ) { Rectangle ownerBoundsInParent = decoratedComponent . getBounds ( ) ; Rectangle decorationBoundsInParent = new Rectangle ( ownerBoundsInParent . x + relativeLocationToOwner . x , ownerBoundsInParent . y + relativeLocationToOwner . y , getWidth ( ) , getHeight ( ) ) ; Rectangle decorationBoundsInAncestor = SwingUtilities . convertRectangle ( decoratedComponent . getParent ( ) , decorationBoundsInParent , clippingComponent ) ; Rectangle decorationVisibleBoundsInAncestor ; Rectangle ancestorVisibleRect = clippingComponent . getVisibleRect ( ) ; decorationVisibleBoundsInAncestor = ancestorVisibleRect . intersection ( decorationBoundsInAncestor ) ; if ( ( decorationVisibleBoundsInAncestor . width == 0 ) || ( decorationVisibleBoundsInAncestor . height == 0 ) ) { decorationPainter . setClipBounds ( null ) ; } else { Rectangle decorationVisibleBoundsInLayeredPane = SwingUtilities . convertRectangle ( clippingComponent , decorationVisibleBoundsInAncestor , layeredPane ) ; Rectangle clipBounds = SwingUtilities . convertRectangle ( decorationPainter . getParent ( ) , decorationVisibleBoundsInLayeredPane , decorationPainter ) ; decorationPainter . setClipBounds ( clipBounds ) ; } } else { decorationPainter . setClipBounds ( null ) ; } } }
Calculates and updates the clipped bounds of the decoration painter in layered pane coordinates .
5,521
private void setDefaultFonts ( BrowserConfig config ) { config . setDefaultFont ( Font . SERIF , "Times New Roman" ) ; config . setDefaultFont ( Font . SANS_SERIF , "Arial" ) ; config . setDefaultFont ( Font . MONOSPACED , "Courier New" ) ; }
Sets some common fonts as the defaults for generic font families .
5,522
public void addResultCollector ( ResultCollector < ? , DPO > resultCollector ) { if ( resultCollector != null ) { addTrigger ( resultCollector ) ; addDataProvider ( resultCollector ) ; } }
Adds the specified result collector to the triggers and data providers .
5,523
public void removeResultCollector ( ResultCollector < ? , DPO > resultCollector ) { if ( resultCollector != null ) { removeTrigger ( resultCollector ) ; removeDataProvider ( resultCollector ) ; } }
Removes the specified result collector from the triggers and data providers .
5,524
public Transformer [ ] getDataProviderOutputTransformers ( ) { Transformer [ ] transformers ; if ( dataProviderOutputTransformers == null ) { transformers = null ; } else { transformers = dataProviderOutputTransformers . toArray ( new Transformer [ dataProviderOutputTransformers . size ( ) ] ) ; } return transformers ; }
Gets the transformers transforming the output of each data provider before they are mapped to the rules .
5,525
@ SuppressWarnings ( "unchecked" ) private void processEachDataProviderWithEachRule ( ) { for ( DataProvider < DPO > dataProvider : dataProviders ) { Object transformedOutput = dataProvider . getData ( ) ; if ( dataProviderOutputTransformers != null ) { for ( Transformer transformer : dataProviderOutputTransformers ) { transformedOutput = transformer . transform ( transformedOutput ) ; } } if ( ruleInputTransformers != null ) { for ( Transformer transformer : ruleInputTransformers ) { transformedOutput = transformer . transform ( transformedOutput ) ; } } RI ruleInput = ( RI ) transformedOutput ; processRules ( ruleInput ) ; } }
Processes the output of each data provider one by one with each rule .
5,526
@ SuppressWarnings ( "unchecked" ) private void processAllDataProvidersWithEachRule ( ) { List < Object > transformedDataProvidersOutput = new ArrayList < Object > ( dataProviders . size ( ) ) ; for ( DataProvider < DPO > dataProvider : dataProviders ) { Object transformedOutput = dataProvider . getData ( ) ; if ( dataProviderOutputTransformers != null ) { for ( Transformer transformer : dataProviderOutputTransformers ) { transformedOutput = transformer . transform ( transformedOutput ) ; } } transformedDataProvidersOutput . add ( transformedOutput ) ; } Object transformedRulesInput = transformedDataProvidersOutput ; if ( ruleInputTransformers != null ) { for ( Transformer transformer : ruleInputTransformers ) { transformedRulesInput = transformer . transform ( transformedRulesInput ) ; } } RI ruleInput = ( RI ) transformedRulesInput ; processRules ( ruleInput ) ; }
Processes the output of all data providers all at once with each rule .
5,527
private void processRules ( RI ruleInput ) { switch ( ruleToResultHandlerMapping ) { case SPLIT : processEachRuleWithEachResultHandler ( ruleInput ) ; break ; case JOIN : processAllRulesWithEachResultHandler ( ruleInput ) ; break ; default : LOGGER . error ( "Unsupported " + MappingStrategy . class . getSimpleName ( ) + ": " + ruleToResultHandlerMapping ) ; } }
Processes the specified rule input .
5,528
@ SuppressWarnings ( "unchecked" ) private void processEachRuleWithEachResultHandler ( RI ruleInput ) { for ( Rule < RI , RO > rule : rules ) { Object ruleOutput = rule . validate ( ruleInput ) ; if ( ruleOutputTransformers != null ) { for ( Transformer transformer : ruleOutputTransformers ) { ruleOutput = transformer . transform ( ruleOutput ) ; } } if ( resultHandlerInputTransformers != null ) { for ( Transformer transformer : resultHandlerInputTransformers ) { ruleOutput = transformer . transform ( ruleOutput ) ; } } RHI resultHandlerInput = ( RHI ) ruleOutput ; processResultHandlers ( resultHandlerInput ) ; } }
Processes the specified rule input with each rule and processes the results of each rule one by one with each result handler .
5,529
@ SuppressWarnings ( "unchecked" ) private void processAllRulesWithEachResultHandler ( RI ruleInput ) { List < Object > combinedRulesOutput = new ArrayList < Object > ( rules . size ( ) ) ; for ( Rule < RI , RO > rule : rules ) { Object data = rule . validate ( ruleInput ) ; if ( ruleOutputTransformers != null ) { for ( Transformer transformer : ruleOutputTransformers ) { data = transformer . transform ( data ) ; } } combinedRulesOutput . add ( data ) ; } Object ruleOutput = combinedRulesOutput ; if ( resultHandlerInputTransformers != null ) { for ( Transformer transformer : resultHandlerInputTransformers ) { ruleOutput = transformer . transform ( ruleOutput ) ; } } RHI resultHandlerInput = ( RHI ) ruleOutput ; processResultHandlers ( resultHandlerInput ) ; }
Processes the specified rule input with each rule and processes the result of all rules all at once with each result handler .
5,530
private void processResultHandlers ( RHI resultHandlerInput ) { for ( ResultHandler < RHI > resultHandler : resultHandlers ) { resultHandler . handleResult ( resultHandlerInput ) ; } }
Processes the specified result handler input with each result handler .
5,531
private void dispose ( Collection < Transformer > elements ) { if ( elements != null ) { for ( Transformer < ? , ? > element : elements ) { if ( element instanceof Disposable ) { ( ( Disposable ) element ) . dispose ( ) ; } } elements . clear ( ) ; } }
Disposes the elements of the specified collection .
5,532
private AnchorLink getAbsoluteAnchorLinkWithCell ( int dragOffsetX ) { AnchorLink absoluteAnchorLink ; TableModel tableModel = table . getModel ( ) ; if ( ( 0 <= modelRowIndex ) && ( modelRowIndex < tableModel . getRowCount ( ) ) && ( 0 <= modelColumnIndex ) && ( modelColumnIndex < tableModel . getColumnCount ( ) ) ) { int viewRowIndex = table . convertRowIndexToView ( modelRowIndex ) ; int viewColumnIndex = table . convertColumnIndexToView ( modelColumnIndex ) ; Rectangle cellBounds = table . getCellRect ( viewRowIndex , viewColumnIndex , true ) ; Anchor relativeCellAnchor = anchorLinkWithCell . getMasterAnchor ( ) ; Anchor absoluteCellAnchor = new Anchor ( 0.0f , cellBounds . x + dragOffsetX + ( int ) ( cellBounds . width * relativeCellAnchor . getRelativeX ( ) ) + relativeCellAnchor . getOffsetX ( ) , 0.0f , cellBounds . y + ( int ) ( cellBounds . height * relativeCellAnchor . getRelativeY ( ) ) + relativeCellAnchor . getOffsetY ( ) ) ; absoluteAnchorLink = new AnchorLink ( absoluteCellAnchor , anchorLinkWithCell . getSlaveAnchor ( ) ) ; } else { LOGGER . debug ( "Cell at model row and/or column indices is not visible: (" + modelRowIndex + "," + modelColumnIndex + ") for table dimensions (" + tableModel . getRowCount ( ) + "," + tableModel . getColumnCount ( ) + ")" ) ; absoluteAnchorLink = null ; } return absoluteAnchorLink ; }
Retrieves the absolute anchor link to attach the decoration to the cell .
5,533
public static List < FacetQueryResult . Field > convert ( QueryResponse solrResponse , Map < String , String > alias ) { if ( solrResponse == null || solrResponse . getResponse ( ) == null || solrResponse . getResponse ( ) . get ( "facets" ) == null ) { return null ; } if ( alias == null ) { alias = new HashMap < > ( ) ; } SimpleOrderedMap < Object > solrFacets = ( SimpleOrderedMap < Object > ) solrResponse . getResponse ( ) . get ( "facets" ) ; List < FacetQueryResult . Field > fields = new ArrayList < > ( ) ; int count = ( int ) solrFacets . get ( "count" ) ; for ( int i = 0 ; i < solrFacets . size ( ) ; i ++ ) { String name = solrFacets . getName ( i ) ; if ( ! "count" . equals ( name ) ) { if ( solrFacets . get ( name ) instanceof SimpleOrderedMap ) { String [ ] split = name . split ( " " ) ; FacetQueryResult . Field facetField = new FacetQueryResult . Field ( getName ( split [ 0 ] , alias ) , getBucketCount ( ( SimpleOrderedMap < Object > ) solrFacets . get ( name ) , count ) , new ArrayList < > ( ) ) ; if ( split . length > 3 ) { facetField . setStart ( FacetQueryParser . parseNumber ( split [ 1 ] ) ) ; facetField . setEnd ( FacetQueryParser . parseNumber ( split [ 2 ] ) ) ; facetField . setStep ( FacetQueryParser . parseNumber ( split [ 3 ] ) ) ; } parseBuckets ( ( SimpleOrderedMap < Object > ) solrFacets . get ( name ) , facetField , alias ) ; fields . add ( facetField ) ; } else { fields . add ( parseAggregation ( name , solrFacets . get ( name ) , alias ) ) ; } } } return fields ; }
Convert a generic solrResponse into our FacetQueryResult .
5,534
private static int getBucketCount ( SimpleOrderedMap < Object > solrFacets , int defaultCount ) { List < SimpleOrderedMap < Object > > solrBuckets = ( List < SimpleOrderedMap < Object > > ) solrFacets . get ( "buckets" ) ; if ( solrBuckets == null ) { for ( int i = 0 ; i < solrFacets . size ( ) ; i ++ ) { if ( solrFacets . getName ( i ) . equals ( "count" ) ) { return ( int ) solrFacets . getVal ( i ) ; } } } return defaultCount ; }
In order to process type = query facets with a nested type = range .
5,535
@ SuppressWarnings ( "unused" ) public void printAll ( ) { project . getLogger ( ) . lifecycle ( "Full contents of dependency configurations:" ) ; project . getLogger ( ) . lifecycle ( "-------------------------------------------" ) ; for ( final Map . Entry < String , DependencyConfig > entry : depConfigs . entrySet ( ) ) { project . getLogger ( ) . lifecycle ( "- " + entry . getKey ( ) + ":\t" + entry . getValue ( ) ) ; } }
Prints all dependency configurations with full contents for debugging purposes .
5,536
private void updateValue ( Point location ) { CellPosition oldValue = value ; if ( location == null ) { value = null ; } else { int row = table . rowAtPoint ( location ) ; int column = table . columnAtPoint ( location ) ; value = new CellPosition ( row , column ) ; } maybeNotifyListeners ( oldValue , value ) ; }
Updates the value of this property based on the location of the mouse pointer .
5,537
public void preparePartitions ( Map config , int totalTasks , int taskIndex , SpoutOutputCollector collector ) throws Exception { this . collector = collector ; if ( stateStore == null ) { String zkEndpointAddress = eventHubConfig . getZkConnectionString ( ) ; if ( zkEndpointAddress == null || zkEndpointAddress . length ( ) == 0 ) { @ SuppressWarnings ( "unchecked" ) List < String > zkServers = ( List < String > ) config . get ( Config . STORM_ZOOKEEPER_SERVERS ) ; Integer zkPort = ( ( Number ) config . get ( Config . STORM_ZOOKEEPER_PORT ) ) . intValue ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( String zk : zkServers ) { if ( sb . length ( ) > 0 ) { sb . append ( ',' ) ; } sb . append ( zk + ":" + zkPort ) ; } zkEndpointAddress = sb . toString ( ) ; } stateStore = new ZookeeperStateStore ( zkEndpointAddress , ( Integer ) config . get ( Config . STORM_ZOOKEEPER_RETRY_TIMES ) , ( Integer ) config . get ( Config . STORM_ZOOKEEPER_RETRY_INTERVAL ) ) ; } stateStore . open ( ) ; partitionCoordinator = new StaticPartitionCoordinator ( eventHubConfig , taskIndex , totalTasks , stateStore , pmFactory , recvFactory ) ; for ( IPartitionManager partitionManager : partitionCoordinator . getMyPartitionManagers ( ) ) { partitionManager . open ( ) ; } }
This is a extracted method that is easy to test
5,538
public void propertyChange ( PropertyChangeEvent propertyChangeEvent ) { if ( ( triggerProperties == null ) || triggerProperties . isEmpty ( ) || triggerProperties . contains ( propertyChangeEvent . getPropertyName ( ) ) ) { fireTriggerEvent ( new TriggerEvent ( propertyChangeEvent . getSource ( ) ) ) ; } }
Triggers the validation when the property change event is received .
5,539
public boolean existsCore ( String coreName ) { try { CoreStatus status = CoreAdminRequest . getCoreStatus ( coreName , solrClient ) ; status . getInstanceDirectory ( ) ; } catch ( Exception e ) { return false ; } return true ; }
Check if a given core exists .
5,540
public boolean existsCollection ( String collectionName ) throws SolrException { try { List < String > collections = CollectionAdminRequest . listCollections ( solrClient ) ; for ( String collection : collections ) { if ( collection . equals ( collectionName ) ) { return true ; } } return false ; } catch ( Exception e ) { throw new SolrException ( SolrException . ErrorCode . CONFLICT , e ) ; } }
Check if a given collection exists .
5,541
public void removeCollection ( String collectionName ) throws SolrException { try { CollectionAdminRequest request = CollectionAdminRequest . deleteCollection ( collectionName ) ; request . process ( solrClient ) ; } catch ( SolrServerException | IOException e ) { throw new SolrException ( SolrException . ErrorCode . SERVER_ERROR , e . getMessage ( ) , e ) ; } }
Remove a collection .
5,542
public void removeCore ( String coreName ) throws SolrException { try { CoreAdminRequest . unloadCore ( coreName , true , true , solrClient ) ; } catch ( SolrServerException | IOException e ) { throw new SolrException ( SolrException . ErrorCode . SERVER_ERROR , e . getMessage ( ) , e ) ; } }
Remove a core .
5,543
public synchronized static void install ( ) { if ( ! isInstalled ( ) ) { InputStream is = BMPCLocalLauncher . class . getResourceAsStream ( BMP_LOCAL_ZIP_RES ) ; try { unzip ( is , BMPC_USER_DIR ) ; new File ( BMP_LOCAL_EXEC_UNIX ) . setExecutable ( true ) ; new File ( BMP_LOCAL_EXEC_WIN ) . setExecutable ( true ) ; installedVersion ( ) ; } catch ( Exception e ) { throw new BMPCUnexpectedErrorException ( "Installation failed" , e ) ; } } }
Install Local BrowserMob Proxy .
5,544
public synchronized static String installedVersion ( ) { BufferedReader versionReader = null ; try { versionReader = new BufferedReader ( new FileReader ( BMP_LOCAL_VERSION_FILE ) ) ; String version = versionReader . readLine ( ) ; if ( null == version ) throw new Exception ( ) ; return version ; } catch ( Exception e ) { throw new BMPCLocalNotInstalledException ( "Version file not found: " + BMP_LOCAL_VERSION_FILE ) ; } finally { try { if ( null != versionReader ) versionReader . close ( ) ; } catch ( IOException e ) { } } }
Installed version of Local BrowserMob Proxy
5,545
private synchronized static void delete ( File file ) { if ( file . isDirectory ( ) ) { File [ ] files = file . listFiles ( ) ; for ( int i = 0 ; i < files . length ; ++ i ) { delete ( files [ i ] ) ; } file . delete ( ) ; } else { file . delete ( ) ; } }
Delete file recursively if needed
5,546
public List < LuceneToken > parse ( String fieldName , String text ) throws IOException { return readTokens ( analyzer . tokenStream ( fieldName , text ) ) ; }
Parses one line of text
5,547
public void handleResult ( RHI result ) { for ( ResultHandler < RHI > resultHandler : resultHandlers ) { resultHandler . handleResult ( result ) ; } }
Processes the specified result using all delegate result handlers .
5,548
public static Set < File > getPublishedDependencyLibs ( final Task pTask , final DependencyConfig pDepConfig ) { Set < File > result = new HashSet < > ( ) ; Configuration cfg = new ClasspathBuilder ( pTask . getProject ( ) ) . buildMainRuntimeConfiguration ( pDepConfig ) ; for ( ResolvedDependency dep : cfg . getResolvedConfiguration ( ) . getFirstLevelModuleDependencies ( ) ) { if ( ! isCheckstyle ( dep ) ) { for ( ResolvedArtifact artifact : dep . getAllModuleArtifacts ( ) ) { result . add ( artifact . getFile ( ) ) ; } } } return result ; }
Scan the dependencies of the specified configurations and return a list of File objects for each dependency . Resolves the configurations if they are still unresolved .
5,549
protected void processTrigger ( final Trigger trigger ) { final List < DataProvider < RI > > mappedDataProviders = triggersToDataProviders . get ( trigger ) ; if ( ( mappedDataProviders == null ) || mappedDataProviders . isEmpty ( ) ) { LOGGER . warn ( "No matching data provider in mappable validator for trigger: " + trigger ) ; } else { for ( final DataProvider < RI > dataProvider : mappedDataProviders ) { processDataProvider ( dataProvider ) ; } } }
Processes the specified trigger by finding all the mapped data providers and so on .
5,550
private void processDataProvider ( final DataProvider < RI > dataProvider ) { final List < Rule < RI , RO > > mappedRules = dataProvidersToRules . get ( dataProvider ) ; if ( ( mappedRules == null ) || mappedRules . isEmpty ( ) ) { LOGGER . warn ( "No matching rule in mappable validator for data provider: " + dataProvider ) ; } else { final RI data = dataProvider . getData ( ) ; for ( final Rule < RI , RO > rule : mappedRules ) { processRule ( rule , data ) ; } } }
Process the specified data provider by finding all the mapped rules and so on .
5,551
private void processRule ( final Rule < RI , RO > rule , final RI data ) { final List < ResultHandler < RO > > mappedResultHandlers = rulesToResultHandlers . get ( rule ) ; if ( ( mappedResultHandlers == null ) || mappedResultHandlers . isEmpty ( ) ) { LOGGER . warn ( "No matching result handler in mappable validator for rule: " + rule ) ; } else { final RO result = rule . validate ( data ) ; for ( final ResultHandler < RO > resultHandler : mappedResultHandlers ) { processResultHandler ( resultHandler , result ) ; } } }
Processes the specified rule by finding all the mapped results handlers checking the rule and processing the rule result using all found result handlers .
5,552
public ValidatorContext < D , O > handleWith ( final ResultHandler < O > ... resultHandlers ) { if ( resultHandlers != null ) { Collections . addAll ( registeredResultHandlers , resultHandlers ) ; } return this ; }
Adds more result handlers to the validator .
5,553
static String buildCombinedType ( String eventType , Optional < String > objectType ) { return Joiner . on ( "/" ) . skipNulls ( ) . join ( eventType , objectType . orNull ( ) ) ; }
Combines event and object type into a single type string .
5,554
static String buildVirtualPageTitle ( Map < String , String > metadata ) { checkNotNull ( metadata ) ; List < String > escapedMetadata = new ArrayList < > ( ) ; for ( Map . Entry < String , String > entry : metadata . entrySet ( ) ) { escapedMetadata . add ( METADATA_ESCAPER . escape ( entry . getKey ( ) ) + "=" + METADATA_ESCAPER . escape ( entry . getValue ( ) ) ) ; } return Joiner . on ( "," ) . join ( escapedMetadata ) ; }
Creates a virtual page title from a set of metadata key - value pairs .
5,555
static ImmutableList < NameValuePair > buildParameters ( String analyticsId , String clientId , String virtualPageName , String virtualPageTitle , String eventType , String eventName , boolean isUserSignedIn , boolean isUserInternal , Optional < Boolean > isUserTrialEligible , Optional < String > projectNumberHash , Optional < String > billingIdHash , Optional < String > clientHostname , Random random ) { checkNotNull ( analyticsId ) ; checkNotNull ( clientId ) ; checkNotNull ( virtualPageTitle ) ; checkNotNull ( virtualPageName ) ; checkNotNull ( eventType ) ; checkNotNull ( eventName ) ; checkNotNull ( projectNumberHash ) ; checkNotNull ( billingIdHash ) ; checkNotNull ( clientHostname ) ; checkNotNull ( random ) ; ImmutableList . Builder < NameValuePair > listBuilder = new ImmutableList . Builder < > ( ) ; listBuilder . add ( new BasicNameValuePair ( PARAM_PROTOCOL , "1" ) ) ; listBuilder . add ( new BasicNameValuePair ( PARAM_PROPERTY_ID , analyticsId ) ) ; listBuilder . add ( new BasicNameValuePair ( PARAM_TYPE , VALUE_TYPE_PAGEVIEW ) ) ; listBuilder . add ( new BasicNameValuePair ( PARAM_IS_NON_INTERACTIVE , VALUE_FALSE ) ) ; listBuilder . add ( new BasicNameValuePair ( PARAM_CACHEBUSTER , Long . toString ( random . nextLong ( ) ) ) ) ; listBuilder . add ( new BasicNameValuePair ( PARAM_EVENT_TYPE , eventType ) ) ; listBuilder . add ( new BasicNameValuePair ( PARAM_EVENT_NAME , eventName ) ) ; if ( clientHostname . isPresent ( ) && ! clientHostname . get ( ) . isEmpty ( ) ) { listBuilder . add ( new BasicNameValuePair ( PARAM_HOSTNAME , clientHostname . get ( ) ) ) ; } listBuilder . add ( new BasicNameValuePair ( PARAM_CLIENT_ID , clientId ) ) ; if ( projectNumberHash . isPresent ( ) && ! projectNumberHash . get ( ) . isEmpty ( ) ) { listBuilder . add ( new BasicNameValuePair ( PARAM_PROJECT_NUM_HASH , projectNumberHash . get ( ) ) ) ; } if ( billingIdHash . isPresent ( ) && ! billingIdHash . get ( ) . isEmpty ( ) ) { listBuilder . add ( new BasicNameValuePair ( PARAM_BILLING_ID_HASH , billingIdHash . get ( ) ) ) ; } listBuilder . add ( new BasicNameValuePair ( PARAM_USER_SIGNED_IN , toValue ( isUserSignedIn ) ) ) ; listBuilder . add ( new BasicNameValuePair ( PARAM_USER_INTERNAL , toValue ( isUserInternal ) ) ) ; if ( isUserTrialEligible . isPresent ( ) ) { listBuilder . add ( new BasicNameValuePair ( PARAM_USER_TRIAL_ELIGIBLE , toValue ( isUserTrialEligible . get ( ) ) ) ) ; } listBuilder . add ( new BasicNameValuePair ( PARAM_IS_VIRTUAL , VALUE_TRUE ) ) ; listBuilder . add ( new BasicNameValuePair ( PARAM_PAGE , virtualPageName ) ) ; if ( ! virtualPageTitle . isEmpty ( ) ) { listBuilder . add ( new BasicNameValuePair ( PARAM_PAGE_TITLE , virtualPageTitle ) ) ; } return listBuilder . build ( ) ; }
Creates the parameters required to record the Google Analytics event .
5,556
public RuleContext < D > read ( final DataProvider < D > ... dataProviders ) { if ( dataProviders != null ) { Collections . addAll ( registeredDataProviders , dataProviders ) ; } return this ; }
Adds more data providers to the validator .
5,557
private void updateFromProperties ( ) { List < R > newValues = new ArrayList < R > ( ) ; for ( ReadableProperty < R > master : properties ) { newValues . add ( master . getValue ( ) ) ; } setValue ( newValues ) ; }
Updates the current collection of values from the sub - properties and notifies the listeners .
5,558
private void dispose ( Collection < ? > elements ) { for ( Object element : elements ) { if ( element instanceof Disposable ) { ( ( Disposable ) element ) . dispose ( ) ; } } dataProviders . clear ( ) ; }
Clears all elements from the specified collection .
5,559
private void init ( ReadableProperty < MO > master , Transformer < MO , SI > transformer , WritableProperty < SI > slave ) { this . master = master ; this . transformer = transformer ; this . slave = slave ; master . addValueChangeListener ( masterAdapter ) ; updateSlaves ( master . getValue ( ) ) ; }
Initializes the bond .
5,560
private void updateSlaves ( MO masterOutputValue ) { SI slaveInputValue = transformer . transform ( masterOutputValue ) ; slave . setValue ( slaveInputValue ) ; }
Sets the value of the slaves according the value of the master .
5,561
private ITridentPartitionManager getOrCreatePartitionManager ( Partition partition ) { ITridentPartitionManager pm ; if ( ! pmMap . containsKey ( partition . getId ( ) ) ) { IEventHubReceiver receiver = recvFactory . create ( spoutConfig , partition . getId ( ) ) ; pm = pmFactory . create ( receiver ) ; pmMap . put ( partition . getId ( ) , pm ) ; } else { pm = pmMap . get ( partition . getId ( ) ) ; } return pm ; }
Check if partition manager for a given partiton is created if not create it .
5,562
public DataProviderContext on ( final Trigger ... triggers ) { final List < Trigger > registeredTriggers = new ArrayList < Trigger > ( ) ; if ( triggers != null ) { Collections . addAll ( registeredTriggers , triggers ) ; } return new DataProviderContext ( registeredTriggers ) ; }
Adds the first triggers to the validator .
5,563
public static JMDictSense create ( ) { if ( index >= instances . size ( ) ) { instances . add ( new JMDictSense ( ) ) ; } return instances . get ( index ++ ) ; }
Returns a JMDictSense object a new one of an existing one
5,564
public static void clear ( ) { for ( int i = 0 ; i < index ; ++ i ) { instances . get ( i ) . clear ( ) ; } index = 0 ; }
Reset all created JMDictSense object so that they can be reused
5,565
public Point getRelativeSlaveLocation ( final Component masterComponent , final Component slaveComponent ) { return getRelativeSlaveLocation ( masterComponent . getWidth ( ) , masterComponent . getHeight ( ) , slaveComponent . getWidth ( ) , slaveComponent . getHeight ( ) ) ; }
Computes the location of the specified component that is slaved to the specified master component using this anchor link .
5,566
private void unhookFromTrigger ( final T trigger ) { final TriggerListener triggerAdapter = triggersToTriggerAdapters . get ( trigger ) ; trigger . removeTriggerListener ( triggerAdapter ) ; if ( ! triggersToTriggerAdapters . containsKey ( trigger ) ) { triggersToTriggerAdapters . remove ( trigger ) ; } }
De - registers the trigger listener .
5,567
private void unmapTriggerFromAllDataProviders ( final T trigger ) { if ( trigger != null ) { unhookFromTrigger ( trigger ) ; triggersToDataProviders . remove ( trigger ) ; } }
Disconnects the specified trigger from all data providers .
5,568
private void unmapDataProviderFromAllTriggers ( final DP dataProvider ) { if ( dataProvider != null ) { for ( final List < DP > mappedDataProviders : triggersToDataProviders . values ( ) ) { mappedDataProviders . remove ( dataProvider ) ; } } }
Disconnects the specified data providers from all triggers .
5,569
private void unmapRuleFromAllDataProviders ( final R rule ) { if ( rule != null ) { for ( final List < R > mappedRules : dataProvidersToRules . values ( ) ) { mappedRules . remove ( rule ) ; } } }
Disconnects the specified rule from all data providers .
5,570
private void unmapResultHandlerFromAllRules ( final RH resultHandler ) { if ( resultHandler != null ) { for ( final List < RH > mappedResultHandlers : rulesToResultHandlers . values ( ) ) { mappedResultHandlers . remove ( resultHandler ) ; } } }
Disconnects the specified result handler from all rules .
5,571
private void disposeTriggersAndDataProviders ( ) { for ( final Map . Entry < T , List < DP > > entry : triggersToDataProviders . entrySet ( ) ) { unhookFromTrigger ( entry . getKey ( ) ) ; final T trigger = entry . getKey ( ) ; if ( trigger instanceof Disposable ) { ( ( Disposable ) trigger ) . dispose ( ) ; } final List < DP > dataProviders = entry . getValue ( ) ; if ( dataProviders != null ) { for ( final DP dataProvider : dataProviders ) { if ( dataProvider instanceof Disposable ) { ( ( Disposable ) dataProvider ) . dispose ( ) ; } } } } triggersToDataProviders . clear ( ) ; }
Disposes all triggers and data providers that are mapped to each other .
5,572
private void disposeRulesAndResultHandlers ( ) { for ( final Map . Entry < R , List < RH > > entry : rulesToResultHandlers . entrySet ( ) ) { final R rule = entry . getKey ( ) ; if ( rule instanceof Disposable ) { ( ( Disposable ) rule ) . dispose ( ) ; } final List < RH > resultHandlers = entry . getValue ( ) ; if ( resultHandlers != null ) { for ( final RH resultHandler : resultHandlers ) { if ( resultHandler instanceof Disposable ) { ( ( Disposable ) resultHandler ) . dispose ( ) ; } } } } rulesToResultHandlers . clear ( ) ; }
Disposes all rules and result handlers that are mapped to each other .
5,573
private void setValue ( boolean rollover ) { if ( ! ValueUtils . areEqual ( this . rollover , rollover ) ) { boolean oldValue = this . rollover ; this . rollover = rollover ; maybeNotifyListeners ( oldValue , rollover ) ; } }
Applies the specified value and notifies the value change listeners if needed .
5,574
private GeneralValidator < DPO , RI , RO , RHI > build ( ) { GeneralValidator < DPO , RI , RO , RHI > validator = new GeneralValidator < DPO , RI , RO , RHI > ( ) ; for ( Trigger trigger : addedTriggers ) { validator . addTrigger ( trigger ) ; } for ( DataProvider < DPO > dataProvider : addedDataProviders ) { validator . addDataProvider ( dataProvider ) ; } validator . setDataProviderToRuleMappingStrategy ( dataProviderToRuleMapping ) ; validator . setRuleInputTransformers ( addedRuleInputTransformers ) ; for ( Rule < RI , RO > rule : addedRules ) { validator . addRule ( rule ) ; } validator . setRuleToResultHandlerMappingStrategy ( ruleToResultHandlerMapping ) ; validator . setResultHandlerInputTransformers ( addedResultHandlerInputTransformers ) ; for ( ResultHandler < RHI > resultHandler : addedResultHandlers ) { validator . addResultHandler ( resultHandler ) ; } return validator ; }
Builds the validator .
5,575
public Proxy asSeleniumProxy ( ) { Proxy seleniumProxyConfig = new Proxy ( ) ; seleniumProxyConfig . setProxyType ( Proxy . ProxyType . MANUAL ) ; seleniumProxyConfig . setHttpProxy ( asHostAndPort ( ) ) ; return seleniumProxyConfig ; }
Returns the Proxy this client wraps in form of a Selenium Proxy configuration object .
5,576
public JsonObject newHar ( String initialPageRef , boolean captureHeaders , boolean captureContent , boolean captureBinaryContent ) { try { HttpPut request = new HttpPut ( requestURIBuilder ( ) . setPath ( proxyURIPath ( ) + "/har" ) . build ( ) ) ; applyFormParamsToHttpRequest ( request , new BasicNameValuePair ( "initialPageRef" , initialPageRef ) , new BasicNameValuePair ( "captureHeaders" , Boolean . toString ( captureHeaders ) ) , new BasicNameValuePair ( "captureContent" , Boolean . toString ( captureContent ) ) , new BasicNameValuePair ( "captureBinaryContent" , Boolean . toString ( captureBinaryContent ) ) ) ; CloseableHttpResponse response = HTTPclient . execute ( request ) ; JsonObject previousHar = httpResponseToJsonObject ( response ) ; response . close ( ) ; return previousHar ; } catch ( Exception e ) { throw new BMPCUnableToCreateHarException ( e ) ; } }
Creates a new HAR attached to the proxy .
5,577
public void newPage ( String pageRef ) { try { HttpPut request = new HttpPut ( requestURIBuilder ( ) . setPath ( proxyURIPath ( ) + "/har/pageRef" ) . build ( ) ) ; applyFormParamsToHttpRequest ( request , new BasicNameValuePair ( "pageRef" , pageRef ) ) ; CloseableHttpResponse response = HTTPclient . execute ( request ) ; int statusCode = response . getStatusLine ( ) . getStatusCode ( ) ; if ( statusCode != 200 ) { throw new BMPCUnableToCreatePageException ( "Invalid HTTP Response when attempting to create" + "new Page in HAR: " + statusCode ) ; } response . close ( ) ; } catch ( Exception e ) { throw new BMPCUnableToCreateHarException ( e ) ; } }
Starts a new page on the existing HAR . All the traffic recorded in the HAR from this point on will be considered part of this new Page .
5,578
public JsonObject har ( ) { try { HttpGet request = new HttpGet ( requestURIBuilder ( ) . setPath ( proxyURIPath ( ) + "/har" ) . build ( ) ) ; CloseableHttpResponse response = HTTPclient . execute ( request ) ; JsonObject har = httpResponseToJsonObject ( response ) ; response . close ( ) ; return har ; } catch ( Exception e ) { throw new BMPCUnableToCreateHarException ( e ) ; } }
Produces the HAR so far based on the traffic generated so far .
5,579
public static void harToFile ( JsonObject har , String destinationDir , String destinationFile ) { File harDestinationDir = new File ( destinationDir ) ; if ( ! harDestinationDir . exists ( ) ) harDestinationDir . mkdirs ( ) ; PrintWriter harDestinationFileWriter = null ; try { harDestinationFileWriter = new PrintWriter ( destinationDir + File . separator + destinationFile ) ; if ( null != har ) { harDestinationFileWriter . print ( har . toString ( ) ) ; } else { harDestinationFileWriter . print ( "" ) ; } } catch ( FileNotFoundException e ) { throw new BMPCUnableToSaveHarToFileException ( e ) ; } finally { if ( null != harDestinationFileWriter ) { harDestinationFileWriter . flush ( ) ; harDestinationFileWriter . close ( ) ; } } }
Utility to store HAR to file .
5,580
protected void processResult ( RO result ) { for ( ResultHandler < RO > resultHandler : resultHandlers ) { resultHandler . handleResult ( result ) ; } }
Handles the specified result using all result handlers .
5,581
public void setupCrossCheckTasks ( ) { final TaskContainer tasks = project . getTasks ( ) ; final Task xtest = tasks . create ( XTEST_TASK_NAME ) ; xtest . setGroup ( XTEST_GROUP_NAME ) ; xtest . setDescription ( "Run the unit tests against all supported Checkstyle runtimes" ) ; tasks . getByName ( JavaBasePlugin . BUILD_TASK_NAME ) . dependsOn ( xtest ) ; for ( final DependencyConfig depConfig : buildUtil . getDepConfigs ( ) . getAll ( ) . values ( ) ) { final JavaVersion javaLevel = depConfig . getJavaLevel ( ) ; final String csBaseVersion = depConfig . getCheckstyleBaseVersion ( ) ; for ( final String csRuntimeVersion : depConfig . getCompatibleCheckstyleVersions ( ) ) { if ( csBaseVersion . equals ( csRuntimeVersion ) ) { continue ; } final TestTask testTask = tasks . create ( TaskNames . xtest . getName ( depConfig , csRuntimeVersion ) , TestTask . class ) ; testTask . configureFor ( depConfig , csRuntimeVersion ) ; testTask . setGroup ( XTEST_GROUP_NAME ) ; testTask . setDescription ( "Run the unit tests compiled for Checkstyle " + csBaseVersion + " against a Checkstyle " + csRuntimeVersion + " runtime (Java level: " + javaLevel + ")" ) ; testTask . getReports ( ) . getHtml ( ) . setEnabled ( false ) ; xtest . dependsOn ( testTask ) ; } } }
Set up cross - check feature . We provide an xcheck task which depends on a number of Test tasks that run the unit tests compiled against every Checkstyle version against all the other Checkstyle libraries . In this way we find out which versions are compatible .
5,582
public void adjustTaskGroupAssignments ( ) { final TaskContainer tasks = project . getTasks ( ) ; tasks . getByName ( BasePlugin . ASSEMBLE_TASK_NAME ) . setGroup ( ARTIFACTS_GROUP_NAME ) ; tasks . getByName ( JavaPlugin . JAR_TASK_NAME ) . setGroup ( ARTIFACTS_GROUP_NAME ) ; final SourceSet sqSourceSet = buildUtil . getSourceSet ( BuildUtil . SONARQUBE_SOURCE_SET_NAME ) ; tasks . getByName ( JavaPlugin . COMPILE_JAVA_TASK_NAME ) . setGroup ( BasePlugin . BUILD_GROUP ) ; tasks . getByName ( sqSourceSet . getCompileJavaTaskName ( ) ) . setGroup ( BasePlugin . BUILD_GROUP ) ; tasks . getByName ( JavaPlugin . COMPILE_TEST_JAVA_TASK_NAME ) . setGroup ( BasePlugin . BUILD_GROUP ) ; for ( final SpotBugsTask sbTask : tasks . withType ( SpotBugsTask . class ) ) { sbTask . setGroup ( LifecycleBasePlugin . VERIFICATION_GROUP ) ; } for ( final Checkstyle csTask : tasks . withType ( Checkstyle . class ) ) { csTask . setGroup ( LifecycleBasePlugin . VERIFICATION_GROUP ) ; } for ( final Copy task : tasks . withType ( Copy . class ) ) { if ( task . getName ( ) . startsWith ( "process" ) && task . getName ( ) . endsWith ( "Resources" ) ) { task . setGroup ( LifecycleBasePlugin . BUILD_GROUP ) ; } } }
Assign some standard tasks and tasks created by third - party plugins to their task groups according to the order of things for Checkstyle Addons .
5,583
public ResultHandlerContext < D , O > check ( final Rule < D , O > ... rules ) { if ( rules != null ) { Collections . addAll ( registeredRules , rules ) ; } return this ; }
Adds another rule to the validator .
5,584
public static ImageIcon loadImageIcon ( final String iconName , final Class < ? > clazz ) { ImageIcon icon = null ; if ( iconName != null ) { final URL iconResource = clazz . getResource ( iconName ) ; if ( iconResource == null ) { LOGGER . error ( "Icon could not be loaded: '" + iconName ) ; icon = null ; } else { icon = new ImageIcon ( iconResource ) ; } } return icon ; }
Loads an image icon from a resource file .
5,585
public static Map < String , String > mfAttrStd ( final Project pProject ) { Map < String , String > result = new HashMap < > ( ) ; result . put ( "Manifest-Version" , "1.0" ) ; result . put ( "Website" , new BuildUtil ( pProject ) . getExtraPropertyValue ( ExtProp . Website ) ) ; result . put ( "Created-By" , GradleVersion . current ( ) . toString ( ) ) ; result . put ( "Built-By" , System . getProperty ( "user.name" ) ) ; result . put ( "Build-Jdk" , Jvm . current ( ) . toString ( ) ) ; return result ; }
Build a little map with standard manifest attributes .
5,586
private void updateValue ( ) { if ( table != null ) { int oldCount = this . count ; this . count = table . getRowCount ( ) ; maybeNotifyListeners ( oldCount , count ) ; } }
Updates the value of this property and notify the listeners .
5,587
private static boolean queryParamsOperatorAlwaysMatchesOperator ( QueryParam . Type type , List < String > queryParamList , ComparisonOperator operator ) { for ( String queryItem : queryParamList ) { Matcher matcher = getPattern ( type ) . matcher ( queryItem ) ; String op = "" ; if ( matcher . find ( ) ) { op = matcher . group ( 1 ) ; } if ( operator != getComparisonOperator ( op , type ) ) { return false ; } } return true ; }
Auxiliary method to check if the operator of each of the values in the queryParamList matches the operator passed .
5,588
private static List < Object > removeOperatorsFromQueryParamList ( QueryParam . Type type , List < String > queryParamList ) { List < Object > newQueryParamList = new ArrayList < > ( ) ; for ( String queryItem : queryParamList ) { Matcher matcher = getPattern ( type ) . matcher ( queryItem ) ; String queryValueString = queryItem ; if ( matcher . find ( ) ) { queryValueString = matcher . group ( 2 ) ; } switch ( type ) { case STRING : case TEXT : case TEXT_ARRAY : newQueryParamList . add ( queryValueString ) ; break ; case LONG : case LONG_ARRAY : case INTEGER : case INTEGER_ARRAY : newQueryParamList . add ( Long . parseLong ( queryValueString ) ) ; break ; case DOUBLE : case DECIMAL : case DECIMAL_ARRAY : newQueryParamList . add ( Double . parseDouble ( queryValueString ) ) ; break ; case BOOLEAN : case BOOLEAN_ARRAY : newQueryParamList . add ( Boolean . parseBoolean ( queryValueString ) ) ; break ; default : break ; } } return newQueryParamList ; }
Removes any operators present in the queryParamList and gets a list of the values parsed to the corresponding data type .
5,589
private static Bson createDateFilter ( String mongoDbField , List < String > dateValues , ComparisonOperator comparator , QueryParam . Type type ) { Bson filter = null ; Object date = null ; if ( QueryParam . Type . DATE . equals ( type ) ) { date = convertStringToDate ( dateValues . get ( 0 ) ) ; } else if ( QueryParam . Type . TIMESTAMP . equals ( type ) ) { date = convertStringToDate ( dateValues . get ( 0 ) ) . getTime ( ) ; } if ( date != null ) { switch ( comparator ) { case BETWEEN : if ( dateValues . size ( ) == 2 ) { Date to = convertStringToDate ( dateValues . get ( 1 ) ) ; if ( QueryParam . Type . DATE . equals ( type ) ) { filter = new Document ( mongoDbField , new Document ( ) . append ( "$gte" , date ) . append ( "$lt" , to ) ) ; } else if ( QueryParam . Type . TIMESTAMP . equals ( type ) ) { filter = new Document ( mongoDbField , new Document ( ) . append ( "$gte" , date ) . append ( "$lt" , to . getTime ( ) ) ) ; } } break ; case EQUALS : filter = Filters . eq ( mongoDbField , date ) ; break ; case GREATER_THAN : filter = Filters . gt ( mongoDbField , date ) ; break ; case GREATER_THAN_EQUAL : filter = Filters . gte ( mongoDbField , date ) ; break ; case LESS_THAN : filter = Filters . lt ( mongoDbField , date ) ; break ; case LESS_THAN_EQUAL : filter = Filters . lte ( mongoDbField , date ) ; break ; default : break ; } } return filter ; }
Generates a date filter .
5,590
public static LogicalOperator checkOperator ( String value ) throws IllegalArgumentException { boolean containsOr = value . contains ( OR ) ; boolean containsAnd = value . contains ( AND ) ; if ( containsAnd && containsOr ) { throw new IllegalArgumentException ( "Cannot merge AND and OR operators in the same query filter." ) ; } else if ( containsAnd && ! containsOr ) { return LogicalOperator . AND ; } else if ( containsOr && ! containsAnd ) { return LogicalOperator . OR ; } else { return null ; } }
Checks that the filter value list contains only one type of operations .
5,591
public EasyJaSubDictionaryEntry getEntry ( String word ) { if ( word == null || word . length ( ) == 0 ) { throw new RuntimeException ( "Invalid word" ) ; } EasyJaSubTrie . Value < EasyJaSubDictionaryEntry > value = trie . get ( new CharacterIterator ( word ) ) ; if ( value == null ) { return null ; } return value . getValue ( ) ; }
Returns an entry corresponding to specified word or to a prefix of it
5,592
@ SuppressWarnings ( "unchecked" ) public < T > T getExtraPropertyValue ( final ExtProp pExtraPropName ) { ExtraPropertiesExtension extraProps = project . getExtensions ( ) . getByType ( ExtraPropertiesExtension . class ) ; if ( extraProps . has ( pExtraPropName . getPropertyName ( ) ) ) { return ( T ) extraProps . get ( pExtraPropName . getPropertyName ( ) ) ; } throw new GradleException ( "Reference to non-existent project extra property '" + pExtraPropName . getPropertyName ( ) + "'" ) ; }
Read the value of an extra property of the project .
5,593
public Task getTask ( final TaskNames pTaskName , final DependencyConfig pDepConfig ) { return project . getTasks ( ) . getByName ( pTaskName . getName ( pDepConfig ) ) ; }
Convenience method for getting a specific task directly .
5,594
public void addBuildTimestampDeferred ( final Task pTask , final Attributes pAttributes ) { pTask . doFirst ( new Closure < Void > ( pTask ) { @ SuppressWarnings ( "MethodDoesntCallSuperMethod" ) public Void call ( ) { addBuildTimestamp ( pAttributes ) ; return null ; } } ) ; }
Add build timestamp to some manifest attributes in the execution phase so that it does not count for the up - to - date check .
5,595
public void inheritManifest ( final Jar pTask , final DependencyConfig pDepConfig ) { pTask . doFirst ( new Closure < Void > ( pTask ) { @ SuppressWarnings ( "MethodDoesntCallSuperMethod" ) public Void call ( ) { final Jar jarTask = ( Jar ) getTask ( TaskNames . jar , pDepConfig ) ; pTask . setManifest ( jarTask . getManifest ( ) ) ; addBuildTimestamp ( pTask . getManifest ( ) . getAttributes ( ) ) ; return null ; } } ) ; }
Make the given Jar task inherit its manifest from the main thin Jar task . Also set the build timestamp .
5,596
public Point getAnchorPoint ( int width , int height ) { return new Point ( ( int ) ( relativeX * width + offsetX ) , ( int ) ( relativeY * height + offsetY ) ) ; }
Retrieves a point on an object of the specified size .
5,597
public void setInhibited ( boolean inhibited ) { boolean wasInhibited = this . inhibited ; this . inhibited = inhibited ; if ( wasInhibited && ! inhibited ) { if ( inhibitCount > 0 ) { maybeNotifyListeners ( lastNonInhibitedValue , lastInhibitedValue ) ; } inhibitCount = 0 ; } }
States whether this property should be inhibited .
5,598
private void notifyListenersIfUninhibited ( R oldValue , R newValue ) { if ( inhibited ) { inhibitCount ++ ; lastInhibitedValue = newValue ; } else { lastInhibitedValue = newValue ; lastNonInhibitedValue = newValue ; doNotifyListeners ( oldValue , newValue ) ; } }
Notifies the listeners that the property value has changed if the property is not inhibited .
5,599
private void doNotifyListeners ( R oldValue , R newValue ) { List < ValueChangeListener < R > > listenersCopy = new ArrayList < ValueChangeListener < R > > ( listeners ) ; notifyingListeners = true ; for ( ValueChangeListener < R > listener : listenersCopy ) { listener . valueChanged ( this , oldValue , newValue ) ; } notifyingListeners = false ; }
Notifies the listeners that the property value has changed unconditionally .