idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
33,400
private List < AbstractJcrNode > findOutputNodes ( AbstractJcrNode rootOutputNode ) throws RepositoryException { if ( rootOutputNode . isNew ( ) ) { return Arrays . asList ( rootOutputNode ) ; } // if the node was not new, we need to find the new sequenced nodes List < AbstractJcrNode > nodes = new ArrayList < AbstractJcrNode > ( ) ; NodeIterator childrenIt = rootOutputNode . getNodesInternal ( ) ; while ( childrenIt . hasNext ( ) ) { Node child = childrenIt . nextNode ( ) ; if ( child . isNew ( ) ) { nodes . add ( ( AbstractJcrNode ) child ) ; } } return nodes ; }
Finds the top nodes which have been created during the sequencing process based on the original output node . It is important that this is called before the session is saved because it uses the new flag .
156
39
33,401
private void removeExistingOutputNodes ( AbstractJcrNode parentOfOutput , String outputNodeName , String selectedPath , String logMsg ) throws RepositoryException { // Determine if there is an existing output node ... if ( TRACE ) { LOGGER . trace ( "Looking under '{0}' for existing output to be removed for {1}" , parentOfOutput . getPath ( ) , logMsg ) ; } NodeIterator outputIter = parentOfOutput . getNodesInternal ( outputNodeName ) ; while ( outputIter . hasNext ( ) ) { Node outputNode = outputIter . nextNode ( ) ; // See if this is indeed the output, which should have the 'mode:derived' mixin ... if ( outputNode . isNodeType ( DERIVED_NODE_TYPE_NAME ) && outputNode . hasProperty ( DERIVED_FROM_PROPERTY_NAME ) ) { // See if it was an output for the same input node ... String derivedFrom = outputNode . getProperty ( DERIVED_FROM_PROPERTY_NAME ) . getString ( ) ; if ( selectedPath . equals ( derivedFrom ) ) { // Delete it ... if ( DEBUG ) { LOGGER . debug ( "Removing existing output node '{0}' for {1}" , outputNode . getPath ( ) , logMsg ) ; } outputNode . remove ( ) ; } } } }
Remove any existing nodes that were generated by previous sequencing operations of the node at the selected path .
306
19
33,402
private boolean contentExists ( BinaryKey key , boolean alive ) throws BinaryStoreException { try { String query = "SELECT payload from modeshape.binary where cid='" + key . toString ( ) + "'" ; query = alive ? query + " and usage=1;" : query + " and usage = 0;" ; ResultSet rs = session . execute ( query ) ; return rs . iterator ( ) . hasNext ( ) ; } catch ( RuntimeException e ) { throw new BinaryStoreException ( e ) ; } }
Test content for existence .
112
5
33,403
private ByteBuffer buffer ( InputStream stream ) throws IOException { stream . reset ( ) ; ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; IoUtil . write ( stream , bout ) ; return ByteBuffer . wrap ( bout . toByteArray ( ) ) ; }
Converts input stream into ByteBuffer .
60
8
33,404
public static Map < SelectorName , SelectorName > getSelectorAliasesByName ( Visitable visitable ) { // Find all of the selectors that have aliases ... final Map < SelectorName , SelectorName > result = new HashMap < SelectorName , SelectorName > ( ) ; Visitors . visitAll ( visitable , new Visitors . AbstractVisitor ( ) { @ Override public void visit ( AllNodes allNodes ) { if ( allNodes . hasAlias ( ) ) { result . put ( allNodes . name ( ) , allNodes . aliasOrName ( ) ) ; } } @ Override public void visit ( NamedSelector selector ) { if ( selector . hasAlias ( ) ) { result . put ( selector . name ( ) , selector . aliasOrName ( ) ) ; } } } ) ; return result ; }
Get a map of the selector aliases keyed by their names .
185
13
33,405
public String getComment ( int index ) { if ( comments == null || index < 0 || index >= comments . size ( ) ) { throw new IllegalArgumentException ( "Not a valid comment index: " + index ) ; } return comments . elementAt ( index ) ; }
Returns the index th comment retrieved from the file .
58
10
33,406
protected boolean hasPrivileges ( Privilege [ ] privileges ) { for ( Privilege p : privileges ) { if ( ! contains ( this . privileges , p ) ) { return false ; } } return true ; }
Tests given privileges .
45
5
33,407
protected boolean addIfNotPresent ( Privilege [ ] privileges ) { ArrayList < Privilege > list = new ArrayList < Privilege > ( ) ; Collections . addAll ( list , privileges ) ; boolean res = combineRecursively ( list , privileges ) ; this . privileges . addAll ( list ) ; return res ; }
Adds specified privileges to this entry .
69
7
33,408
protected boolean combineRecursively ( List < Privilege > list , Privilege [ ] privileges ) { boolean res = false ; for ( Privilege p : privileges ) { if ( p . isAggregate ( ) ) { res = combineRecursively ( list , p . getAggregatePrivileges ( ) ) ; } else if ( ! contains ( list , p ) ) { list . add ( p ) ; res = true ; } } return res ; }
Adds specified privileges to the given list .
97
8
33,409
protected NodeSequence createNodeSequenceForSource ( QueryCommand originalQuery , QueryContext context , PlanNode sourceNode , Columns columns , QuerySources sources ) { // The indexes should already be in the correct order, from lowest cost to highest cost ... for ( PlanNode indexNode : sourceNode . getChildren ( ) ) { if ( indexNode . getType ( ) != Type . INDEX ) continue ; IndexPlan index = indexNode . getProperty ( Property . INDEX_SPECIFICATION , IndexPlan . class ) ; NodeSequence sequence = createNodeSequenceForSource ( originalQuery , context , sourceNode , index , columns , sources ) ; if ( sequence != null ) { // Mark the index as being used ... indexNode . setProperty ( Property . INDEX_USED , Boolean . TRUE ) ; return sequence ; } // Otherwise, keep looking for an index ... LOGGER . debug ( "Skipping disabled index '{0}' from provider '{1}' in workspace(s) {2} for query: {3}" , index . getName ( ) , index . getProviderName ( ) , context . getWorkspaceNames ( ) , originalQuery ) ; } // Grab all of the nodes ... return sources . allNodes ( 1.0f , - 1 ) ; }
Create a node sequence for the given source .
275
9
33,410
protected NodeSequence createNodeSequenceForSource ( QueryCommand originalQuery , QueryContext context , PlanNode sourceNode , IndexPlan index , Columns columns , QuerySources sources ) { if ( index . getProviderName ( ) == null ) { String name = index . getName ( ) ; String pathStr = ( String ) index . getParameters ( ) . get ( IndexPlanners . PATH_PARAMETER ) ; if ( pathStr != null ) { if ( IndexPlanners . NODE_BY_PATH_INDEX_NAME . equals ( name ) ) { PathFactory paths = context . getExecutionContext ( ) . getValueFactories ( ) . getPathFactory ( ) ; Path path = paths . create ( pathStr ) ; return sources . singleNode ( path , 1.0f ) ; } if ( IndexPlanners . CHILDREN_BY_PATH_INDEX_NAME . equals ( name ) ) { PathFactory paths = context . getExecutionContext ( ) . getValueFactories ( ) . getPathFactory ( ) ; Path path = paths . create ( pathStr ) ; return sources . childNodes ( path , 1.0f ) ; } if ( IndexPlanners . DESCENDANTS_BY_PATH_INDEX_NAME . equals ( name ) ) { PathFactory paths = context . getExecutionContext ( ) . getValueFactories ( ) . getPathFactory ( ) ; Path path = paths . create ( pathStr ) ; return sources . descendantNodes ( path , 1.0f ) ; } } String idStr = ( String ) index . getParameters ( ) . get ( IndexPlanners . ID_PARAMETER ) ; if ( idStr != null ) { if ( IndexPlanners . NODE_BY_ID_INDEX_NAME . equals ( name ) ) { StringFactory string = context . getExecutionContext ( ) . getValueFactories ( ) . getStringFactory ( ) ; String id = string . create ( idStr ) ; final String workspaceName = context . getWorkspaceNames ( ) . iterator ( ) . next ( ) ; return sources . singleNode ( workspaceName , id , 1.0f ) ; } } } return null ; }
Create a node sequence for the given index
476
8
33,411
private String getHash ( ) { try { Node contentNode = getContextNode ( ) ; Property data = contentNode . getProperty ( Property . JCR_DATA ) ; Binary bin = ( Binary ) data . getBinary ( ) ; return String . format ( "{%s}%s" , HASH_ALGORITHM , bin . getHexHash ( ) ) ; } catch ( RepositoryException e ) { return "" ; } }
Get the hexadecimal form of the SHA - 1 hash of the contents .
96
17
33,412
public void setWorkspaceNames ( String [ ] values ) { col2 . combo . setValueMap ( values ) ; if ( values . length > 0 ) { col2 . combo . setValue ( values [ 0 ] ) ; } }
Assigns workspace names to the combo box into column 2 .
50
13
33,413
private Set < String > versionLabelsFor ( Version version ) throws RepositoryException { if ( ! version . getParent ( ) . equals ( this ) ) { throw new VersionException ( JcrI18n . invalidVersion . text ( version . getPath ( ) , getPath ( ) ) ) ; } String versionId = version . getIdentifier ( ) ; PropertyIterator iter = versionLabels ( ) . getProperties ( ) ; if ( iter . getSize ( ) == 0 ) return Collections . emptySet ( ) ; Set < String > labels = new HashSet < String > ( ) ; while ( iter . hasNext ( ) ) { javax . jcr . Property prop = iter . nextProperty ( ) ; if ( versionId . equals ( prop . getString ( ) ) ) { labels . add ( prop . getName ( ) ) ; } } return labels ; }
Returns the version labels that point to the given version
188
10
33,414
private int computeCredsHashCode ( Credentials c ) { if ( c instanceof SimpleCredentials ) { return computeSimpleCredsHashCode ( ( SimpleCredentials ) c ) ; } return c . hashCode ( ) ; }
Returns Credentials instance hash code . Handles instances of SimpleCredentials in a special way .
54
21
33,415
public int getSameNameSiblingIndex ( ) { int snsIndex = 1 ; if ( this . parent == null ) { return snsIndex ; } // Go through all the children ... for ( AstNode sibling : this . parent . getChildren ( ) ) { if ( sibling == this ) { break ; } if ( sibling . getName ( ) . equals ( this . name ) ) { ++ snsIndex ; } } return snsIndex ; }
Get the current same - name - sibling index .
96
10
33,416
public String getAbsolutePath ( ) { StringBuilder pathBuilder = new StringBuilder ( "/" ) . append ( this . getName ( ) ) ; AstNode parent = this . getParent ( ) ; while ( parent != null ) { pathBuilder . insert ( 0 , "/" + parent . getName ( ) ) ; parent = parent . getParent ( ) ; } return pathBuilder . toString ( ) ; }
Get the current path of this node
88
7
33,417
public AstNode setProperty ( String name , Object value ) { CheckArg . isNotNull ( name , "name" ) ; CheckArg . isNotNull ( value , "value" ) ; properties . put ( name , value ) ; return this ; }
Set the property with the given name to the supplied value . Any existing property with the same name will be replaced .
54
23
33,418
public AstNode setProperty ( String name , Object ... values ) { CheckArg . isNotNull ( name , "name" ) ; CheckArg . isNotNull ( values , "value" ) ; if ( values . length != 0 ) { properties . put ( name , Arrays . asList ( values ) ) ; } return this ; }
Set the property with the given name to the supplied values . If there is at least one value the new property will replace any existing property with the same name . This method does nothing if zero values are supplied .
72
42
33,419
protected String removeBracketsAndQuotes ( String text , Position position ) { return removeBracketsAndQuotes ( text , true , position ) ; }
Remove all leading and trailing single - quotes double - quotes or square brackets from the supplied text . If multiple properly - paired quotes or brackets are found they will all be removed .
30
35
33,420
protected String removeBracketsAndQuotes ( String text , boolean recursive , Position position ) { if ( text . length ( ) > 0 ) { char firstChar = text . charAt ( 0 ) ; switch ( firstChar ) { case ' ' : case ' ' : if ( text . charAt ( text . length ( ) - 1 ) != firstChar ) { String msg = GraphI18n . expectingValidName . text ( text , position . getLine ( ) , position . getColumn ( ) ) ; throw new ParsingException ( position , msg ) ; } String removed = text . substring ( 1 , text . length ( ) - 1 ) ; return recursive ? removeBracketsAndQuotes ( removed , recursive , position ) : removed ; case ' ' : if ( text . charAt ( text . length ( ) - 1 ) != ' ' ) { String msg = GraphI18n . expectingValidName . text ( text , position . getLine ( ) , position . getColumn ( ) ) ; throw new ParsingException ( position , msg ) ; } removed = text . substring ( 1 , text . length ( ) - 1 ) ; return recursive ? removeBracketsAndQuotes ( removed , recursive , position ) : removed ; } } return text ; }
Remove any leading and trailing single - quotes double - quotes or square brackets from the supplied text .
264
19
33,421
private String [ ] propertyDefs ( Node node ) throws RepositoryException { ArrayList < String > list = new ArrayList <> ( ) ; NodeType primaryType = node . getPrimaryNodeType ( ) ; PropertyDefinition [ ] defs = primaryType . getPropertyDefinitions ( ) ; for ( PropertyDefinition def : defs ) { if ( ! def . isProtected ( ) ) { list . add ( def . getName ( ) ) ; } } NodeType [ ] mixinType = node . getMixinNodeTypes ( ) ; for ( NodeType type : mixinType ) { defs = type . getPropertyDefinitions ( ) ; for ( PropertyDefinition def : defs ) { if ( ! def . isProtected ( ) ) { list . add ( def . getName ( ) ) ; } } } String [ ] res = new String [ list . size ( ) ] ; list . toArray ( res ) ; return res ; }
Gets the list of properties available to the given node .
203
12
33,422
private AccessControlList findAccessList ( AccessControlManager acm , String path ) throws RepositoryException { AccessControlPolicy [ ] policy = acm . getPolicies ( path ) ; if ( policy != null && policy . length > 0 ) { return ( AccessControlList ) policy [ 0 ] ; } policy = acm . getEffectivePolicies ( path ) ; if ( policy != null && policy . length > 0 ) { return ( AccessControlList ) policy [ 0 ] ; } return null ; }
Searches access list for the given node .
108
10
33,423
private Collection < JcrProperty > getProperties ( String repository , String workspace , String path , Node node ) throws RepositoryException { ArrayList < PropertyDefinition > names = new ArrayList <> ( ) ; NodeType primaryType = node . getPrimaryNodeType ( ) ; PropertyDefinition [ ] defs = primaryType . getPropertyDefinitions ( ) ; names . addAll ( Arrays . asList ( defs ) ) ; NodeType [ ] mixinType = node . getMixinNodeTypes ( ) ; for ( NodeType type : mixinType ) { defs = type . getPropertyDefinitions ( ) ; names . addAll ( Arrays . asList ( defs ) ) ; } ArrayList < JcrProperty > list = new ArrayList <> ( ) ; for ( PropertyDefinition def : names ) { String name = def . getName ( ) ; String type = PropertyType . nameFromValue ( def . getRequiredType ( ) ) ; Property p = null ; try { p = node . getProperty ( def . getName ( ) ) ; } catch ( PathNotFoundException e ) { } String display = values ( def , p ) ; String value = def . isMultiple ( ) ? multiValue ( p ) : singleValue ( p , def , repository , workspace , path ) ; list . add ( new JcrProperty ( name , type , value , display ) ) ; } return list ; }
Reads properties of the given node .
301
8
33,424
private String values ( PropertyDefinition pd , Property p ) throws RepositoryException { if ( p == null ) { return "N/A" ; } if ( pd . getRequiredType ( ) == PropertyType . BINARY ) { return "BINARY" ; } if ( ! p . isMultiple ( ) ) { return p . getString ( ) ; } return multiValue ( p ) ; }
Displays property value as string
87
6
33,425
private AccessControlEntry pick ( AccessControlList acl , String principal ) throws RepositoryException { for ( AccessControlEntry entry : acl . getAccessControlEntries ( ) ) { if ( entry . getPrincipal ( ) . getName ( ) . equals ( principal ) ) { return entry ; } } return null ; }
Picks access entry for the given principal .
69
9
33,426
private Privilege [ ] excludePrivilege ( Privilege [ ] privileges , JcrPermission permission ) { ArrayList < Privilege > list = new ArrayList <> ( ) ; for ( Privilege privilege : privileges ) { if ( ! privilege . getName ( ) . equalsIgnoreCase ( permission . getName ( ) ) ) { list . add ( privilege ) ; } } Privilege [ ] res = new Privilege [ list . size ( ) ] ; list . toArray ( res ) ; return res ; }
Excludes given privilege .
109
5
33,427
private Privilege [ ] includePrivilege ( AccessControlManager acm , Privilege [ ] privileges , JcrPermission permission ) throws RepositoryException { ArrayList < Privilege > list = new ArrayList <> ( ) ; for ( Privilege privilege : privileges ) { if ( ! privilege . getName ( ) . equalsIgnoreCase ( permission . getName ( ) ) ) { list . add ( privilege ) ; } } list . add ( acm . privilegeFromName ( permission . getJcrName ( ) ) ) ; Privilege [ ] res = new Privilege [ list . size ( ) ] ; list . toArray ( res ) ; return res ; }
Includes given privilege .
141
4
33,428
public static FileSystemBinaryStore create ( File directory , File trash ) { String key = directory . getAbsolutePath ( ) ; FileSystemBinaryStore store = INSTANCES . get ( key ) ; if ( store == null ) { store = trash != null ? new FileSystemBinaryStore ( directory , trash ) : new FileSystemBinaryStore ( directory ) ; FileSystemBinaryStore existing = INSTANCES . putIfAbsent ( key , store ) ; if ( existing != null ) { store = existing ; } } return store ; }
Creates a new FS binary store instance
117
8
33,429
protected void loadRemaining ( ) { if ( ! loadedAll ) { // Put all of the batches from the sequence into the buffer assert targetNumRowsInMemory >= 0L ; assert batchSize != null ; Batch batch = original . nextBatch ( ) ; boolean loadIntoMemory = inMemoryBatches != null && actualNumRowsInMemory < targetNumRowsInMemory ; while ( batch != null ) { long rows = loadBatch ( batch , loadIntoMemory , null ) ; if ( batchSize . get ( ) == 0L ) batchSize . set ( rows ) ; if ( loadIntoMemory ) { assert inMemoryBatches != null ; if ( actualNumRowsInMemory >= targetNumRowsInMemory ) loadIntoMemory = false ; } batch = original . nextBatch ( ) ; } long numInMemory = inMemoryBatches != null ? actualNumRowsInMemory : 0L ; totalSize = offHeapBatchesSupplier . size ( ) + numInMemory ; loadedAll = true ; restartBatches ( ) ; } }
Load all of the remaining rows from the supplied sequence into the buffer .
232
14
33,430
public BinaryKey moveValue ( BinaryKey key , String source , String destination ) throws BinaryStoreException { final BinaryStore sourceStore ; if ( source == null ) { sourceStore = findBinaryStoreContainingKey ( key ) ; } else { sourceStore = selectBinaryStore ( source ) ; } // could not find source store, or if ( sourceStore == null || ! sourceStore . hasBinary ( key ) ) { throw new BinaryStoreException ( JcrI18n . unableToFindBinaryValue . text ( key , sourceStore ) ) ; } BinaryStore destinationStore = selectBinaryStore ( destination ) ; // key is already in the destination store if ( sourceStore . equals ( destinationStore ) ) { return key ; } final BinaryValue binaryValue = storeValue ( sourceStore . getInputStream ( key ) , destination , false ) ; sourceStore . markAsUnused ( java . util . Collections . singleton ( key ) ) ; return binaryValue . getKey ( ) ; }
Move a value from one named store to another store
211
10
33,431
public void moveValue ( BinaryKey key , String destination ) throws BinaryStoreException { moveValue ( key , null , destination ) ; }
Move a BinaryKey to a named store
28
8
33,432
public BinaryStore findBinaryStoreContainingKey ( BinaryKey key ) { Iterator < Map . Entry < String , BinaryStore > > binaryStoreIterator = getNamedStoreIterator ( ) ; while ( binaryStoreIterator . hasNext ( ) ) { BinaryStore bs = binaryStoreIterator . next ( ) . getValue ( ) ; if ( bs . hasBinary ( key ) ) { return bs ; } } return null ; }
Get the named binary store that contains the key
94
9
33,433
private BinaryStore selectBinaryStore ( String hint ) { BinaryStore namedBinaryStore = null ; if ( hint != null ) { logger . trace ( "Selecting named binary store for hint: " + hint ) ; namedBinaryStore = namedStores . get ( hint ) ; } if ( namedBinaryStore == null ) { namedBinaryStore = getDefaultBinaryStore ( ) ; } logger . trace ( "Selected binary store: " + namedBinaryStore . toString ( ) ) ; return namedBinaryStore ; }
Select a named binary store for the given hint
115
9
33,434
public void start ( ) { if ( state == State . RUNNING ) return ; final Lock lock = this . lock . writeLock ( ) ; try { lock . lock ( ) ; this . state = State . STARTING ; // Create an executor service that we'll use to start the repositories ... ThreadFactory threadFactory = new NamedThreadFactory ( "modeshape-start-repo" ) ; repositoryStarterService = Executors . newCachedThreadPool ( threadFactory ) ; state = State . RUNNING ; } catch ( RuntimeException e ) { state = State . NOT_RUNNING ; throw e ; } finally { lock . unlock ( ) ; } }
Start this engine to make it available for use . This method does nothing if the engine is already running .
143
21
33,435
public Future < Boolean > shutdown ( boolean forceShutdownOfAllRepositories ) { if ( ! forceShutdownOfAllRepositories ) { // Check to see if there are any still running ... final Lock lock = this . lock . readLock ( ) ; try { lock . lock ( ) ; for ( JcrRepository repository : repositories . values ( ) ) { switch ( repository . getState ( ) ) { case NOT_RUNNING : case STOPPING : break ; case RESTORING : case RUNNING : case STARTING : // This repository is still running, so fail return ImmediateFuture . create ( Boolean . FALSE ) ; } } // If we got to here, there are no more running repositories ... } finally { lock . unlock ( ) ; } } // Create a simple executor that will do the backgrounding for us ... final ExecutorService executor = Executors . newSingleThreadExecutor ( ) ; try { // Submit a runnable to shutdown the repositories ... return executor . submit ( this :: doShutdown ) ; } finally { // Now shutdown the executor and return the future ... executor . shutdown ( ) ; } }
Shutdown this engine optionally stopping all still - running repositories .
244
12
33,436
protected boolean doShutdown ( ) { if ( state == State . NOT_RUNNING ) { LOGGER . debug ( "Engine already shut down." ) ; return true ; } LOGGER . debug ( "Shutting down engine..." ) ; final Lock lock = this . lock . writeLock ( ) ; try { lock . lock ( ) ; state = State . STOPPING ; if ( ! repositories . isEmpty ( ) ) { // Now go through all of the repositories and request they all be shutdown ... Queue < Future < Boolean >> repoFutures = new LinkedList < Future < Boolean > > ( ) ; Queue < String > repoNames = new LinkedList < String > ( ) ; for ( JcrRepository repository : repositories . values ( ) ) { if ( repository != null ) { repoNames . add ( repository . getName ( ) ) ; repoFutures . add ( repository . shutdown ( ) ) ; } } // Now block while each is shutdown ... while ( repoFutures . peek ( ) != null ) { String repoName = repoNames . poll ( ) ; try { // Get the results from the future (this will return only when the shutdown has completed) ... repoFutures . poll ( ) . get ( ) ; // We've successfully shut down, so remove it from the map ... repositories . remove ( repoName ) ; } catch ( ExecutionException | InterruptedException e ) { Logger . getLogger ( getClass ( ) ) . error ( e , JcrI18n . failedToShutdownDeployedRepository , repoName ) ; } } } if ( repositories . isEmpty ( ) ) { // All repositories were properly shutdown, so now stop the service for starting and shutting down the repos ... repositoryStarterService . shutdown ( ) ; repositoryStarterService = null ; // Do not clear the set of repositories, so that restarting will work just fine ... this . state = State . NOT_RUNNING ; } else { // Could not shut down all repositories, so keep running .. this . state = State . RUNNING ; } } catch ( RuntimeException e ) { this . state = State . RUNNING ; throw e ; } finally { lock . unlock ( ) ; } return this . state != State . RUNNING ; }
Do the work of shutting down this engine and its repositories .
483
12
33,437
public Map < String , State > getRepositories ( ) { checkRunning ( ) ; Map < String , State > results = new HashMap < String , State > ( ) ; final Lock lock = this . lock . readLock ( ) ; try { lock . lock ( ) ; for ( JcrRepository repository : repositories . values ( ) ) { results . put ( repository . getName ( ) , repository . getState ( ) ) ; } } finally { lock . unlock ( ) ; } return Collections . unmodifiableMap ( results ) ; }
Get an instantaneous snapshot of the JCR repositories and their state . Note that the results are accurate only when this methods returns .
115
25
33,438
protected Collection < JcrRepository > repositories ( ) { if ( this . state == State . RUNNING ) { final Lock lock = this . lock . readLock ( ) ; try { lock . lock ( ) ; return new ArrayList < JcrRepository > ( repositories . values ( ) ) ; } finally { lock . unlock ( ) ; } } return Collections . emptyList ( ) ; }
Returns a copy of the repositories . Note that when returned not all repositories may be active .
83
18
33,439
protected JcrRepository deploy ( final RepositoryConfiguration repositoryConfiguration , final String repositoryKey ) throws ConfigurationException , RepositoryException { CheckArg . isNotNull ( repositoryConfiguration , "repositoryConfiguration" ) ; checkRunning ( ) ; final String repoName = repositoryKey != null ? repositoryKey : repositoryConfiguration . getName ( ) ; Problems problems = repositoryConfiguration . validate ( ) ; if ( problems . hasErrors ( ) ) { throw new ConfigurationException ( problems , JcrI18n . repositoryConfigurationIsNotValid . text ( repoName , problems . toString ( ) ) ) ; } // Now try to deploy the repository ... JcrRepository repository = null ; final Lock lock = this . lock . writeLock ( ) ; try { lock . lock ( ) ; if ( this . repositories . containsKey ( repoName ) ) { throw new RepositoryException ( JcrI18n . repositoryIsAlreadyDeployed . text ( repoName ) ) ; } // Instantiate (but do not start!) the repository, store it in our map, and return it ... repository = new JcrRepository ( repositoryConfiguration ) ; this . repositories . put ( repoName , repository ) ; } finally { lock . unlock ( ) ; } return repository ; }
Deploy a new repository with the given configuration . This method will fail if this engine already contains a repository with the specified name .
263
25
33,440
public Status validateRequest ( final NormalisedPath requestPath , HttpServerExchange exchange , OpenApiOperation openApiOperation ) { requireNonNull ( requestPath , "A request path is required" ) ; requireNonNull ( exchange , "An exchange is required" ) ; requireNonNull ( openApiOperation , "An OpenAPI operation is required" ) ; Status status = validatePathParameters ( requestPath , openApiOperation ) ; if ( status != null ) return status ; status = validateQueryParameters ( exchange , openApiOperation ) ; if ( status != null ) return status ; status = validateHeader ( exchange , openApiOperation ) ; if ( status != null ) return status ; Object body = exchange . getAttachment ( BodyHandler . REQUEST_BODY ) ; // skip the body validation if body parser is not in the request chain. if ( body == null && ValidatorHandler . config . skipBodyValidation ) return null ; status = validateRequestBody ( body , openApiOperation ) ; return status ; }
Validate the request against the given API operation
220
9
33,441
public Status validateResponse ( final HttpServerExchange exchange , final SwaggerOperation swaggerOperation ) { requireNonNull ( exchange , "An exchange is required" ) ; requireNonNull ( swaggerOperation , "A swagger operation is required" ) ; io . swagger . models . Response swaggerResponse = swaggerOperation . getOperation ( ) . getResponses ( ) . get ( Integer . toString ( exchange . getStatusCode ( ) ) ) ; if ( swaggerResponse == null ) { swaggerResponse = swaggerOperation . getOperation ( ) . getResponses ( ) . get ( "default" ) ; // try the default response } if ( swaggerResponse == null ) { return new Status ( "ERR11015" , exchange . getStatusCode ( ) , swaggerOperation . getPathString ( ) . original ( ) ) ; } if ( swaggerResponse . getSchema ( ) == null ) { return null ; } String body = exchange . getOutputStream ( ) . toString ( ) ; if ( body == null || body . length ( ) == 0 ) { return new Status ( "ERR11016" , swaggerOperation . getMethod ( ) , swaggerOperation . getPathString ( ) . original ( ) ) ; } return schemaValidator . validate ( body , swaggerResponse . getSchema ( ) ) ; }
Validate the given response against the API operation .
292
10
33,442
public Status validate ( final Object value , final Property schema ) { return doValidate ( value , schema , null ) ; }
Validate the given value against the given property schema .
26
11
33,443
public Status validate ( final Object value , final Model schema , SchemaValidatorsConfig config ) { return doValidate ( value , schema , config ) ; }
Validate the given value against the given model schema .
33
11
33,444
public Status validateResponseContent ( Object responseContent , OpenApiOperation openApiOperation , String statusCode , String mediaTypeName ) { //try to convert json string to structured object if ( responseContent instanceof String ) { responseContent = convertStrToObjTree ( ( String ) responseContent ) ; } JsonNode schema = getContentSchema ( openApiOperation , statusCode , mediaTypeName ) ; //if cannot find schema based on status code, try to get from "default" if ( schema == null || schema . isMissingNode ( ) ) { // if corresponding response exist but also does not contain any schema, pass validation if ( openApiOperation . getOperation ( ) . getResponses ( ) . containsKey ( String . valueOf ( statusCode ) ) ) { return null ; } schema = getContentSchema ( openApiOperation , DEFAULT_STATUS_CODE , mediaTypeName ) ; // if default also does not contain any schema, pass validation if ( schema == null || schema . isMissingNode ( ) ) return null ; } if ( ( responseContent != null && schema == null ) || ( responseContent == null && schema != null ) ) { return new Status ( VALIDATOR_RESPONSE_CONTENT_UNEXPECTED , openApiOperation . getMethod ( ) , openApiOperation . getPathString ( ) . original ( ) ) ; } config . setTypeLoose ( false ) ; return schemaValidator . validate ( responseContent , schema , config ) ; }
validate a given response content object
326
7
33,445
private Object convertStrToObjTree ( String s ) { Object contentObj = null ; if ( s != null ) { s = s . trim ( ) ; try { if ( s . startsWith ( "{" ) ) { contentObj = Config . getInstance ( ) . getMapper ( ) . readValue ( s , new TypeReference < HashMap < String , Object > > ( ) { } ) ; } else if ( s . startsWith ( "[" ) ) { contentObj = Config . getInstance ( ) . getMapper ( ) . readValue ( s , new TypeReference < List < Object > > ( ) { } ) ; } else { logger . error ( "cannot deserialize json str: {}" , s ) ; return null ; } } catch ( IOException e ) { logger . error ( e . getMessage ( ) ) ; } } return contentObj ; }
try to convert a string with json style to a structured object .
189
13
33,446
private OpenApiOperation getOpenApiOperation ( String uri , String httpMethod ) throws URISyntaxException { String uriWithoutQuery = new URI ( uri ) . getPath ( ) ; NormalisedPath requestPath = new ApiNormalisedPath ( uriWithoutQuery ) ; Optional < NormalisedPath > maybeApiPath = OpenApiHelper . findMatchingApiPath ( requestPath ) ; if ( ! maybeApiPath . isPresent ( ) ) { return null ; } final NormalisedPath openApiPathString = maybeApiPath . get ( ) ; final Path path = OpenApiHelper . openApi3 . getPath ( openApiPathString . original ( ) ) ; final Operation operation = path . getOperation ( httpMethod ) ; return new OpenApiOperation ( openApiPathString , path , httpMethod , operation ) ; }
locate operation based on uri and httpMethod
190
10
33,447
public FilterStreamParameters follow ( long follow ) { if ( this . follow . length ( ) > 0 ) { this . follow . append ( ' ' ) ; } this . follow . append ( follow ) ; return this ; }
Add a user to follow in the stream . Does not replace any existing follows in the filter .
47
19
33,448
public AbstractStreamParameters track ( String track ) { if ( this . track . length ( ) > 0 ) { this . track . append ( ' ' ) ; } this . track . append ( track ) ; return this ; }
Add tracking keywords to the filter . Does not replace any existing tracking keywords in the filter .
47
18
33,449
public AbstractStreamParameters addLocation ( float west , float south , float east , float north ) { if ( locations . length ( ) > 0 ) { locations . append ( ' ' ) ; } locations . append ( west ) . append ( ' ' ) . append ( south ) . append ( ' ' ) ; locations . append ( east ) . append ( ' ' ) . append ( north ) . append ( ' ' ) ; return this ; }
Add a location to the filter Does not replace any existing locations in the filter .
92
16
33,450
private Entities toEntities ( final JsonNode node , String text ) throws IOException { if ( null == node || node . isNull ( ) || node . isMissingNode ( ) ) { return null ; } final ObjectMapper mapper = this . createMapper ( ) ; Entities entities = mapper . readerFor ( Entities . class ) . readValue ( node ) ; extractTickerSymbolEntitiesFromText ( text , entities ) ; return entities ; }
passing in text to fetch ticker symbol pseudo - entities
102
12
33,451
public UserStateResult getUserState ( String username ) throws APIConnectionException , APIRequestException { StringUtils . checkUsername ( username ) ; ResponseWrapper response = _httpClient . sendGet ( _baseUrl + userPath + "/" + username + "/userstat" ) ; return UserStateResult . fromResponse ( response , UserStateResult . class ) ; }
Get user state
82
3
33,452
public UserStateListResult [ ] getUsersState ( String ... users ) throws APIConnectionException , APIRequestException { JsonArray jsonArray = new JsonArray ( ) ; for ( String username : users ) { StringUtils . checkUsername ( username ) ; jsonArray . add ( new JsonPrimitive ( username ) ) ; } ResponseWrapper response = _httpClient . sendPost ( _baseUrl + userPath + "/userstat" , jsonArray . toString ( ) ) ; return _gson . fromJson ( response . responseContent , UserStateListResult [ ] . class ) ; }
Get users state
133
3
33,453
public UserInfoResult [ ] getBlackList ( String username ) throws APIConnectionException , APIRequestException { StringUtils . checkUsername ( username ) ; ResponseWrapper response = _httpClient . sendGet ( _baseUrl + userPath + "/" + username + "/blacklist" ) ; return _gson . fromJson ( response . responseContent , UserInfoResult [ ] . class ) ; }
Get a user s all black list
90
7
33,454
public UserGroupsResult getGroupList ( String username ) throws APIConnectionException , APIRequestException { StringUtils . checkUsername ( username ) ; ResponseWrapper response = _httpClient . sendGet ( _baseUrl + userPath + "/" + username + "/groups" ) ; return UserGroupsResult . fromResponse ( response ) ; }
Get all groups of a user
77
6
33,455
public ResponseWrapper addBlackList ( String username , String ... users ) throws APIConnectionException , APIRequestException { return _userClient . addBlackList ( username , users ) ; }
Add Users to black list
42
5
33,456
public ResponseWrapper setNoDisturb ( String username , NoDisturbPayload payload ) throws APIConnectionException , APIRequestException { return _userClient . setNoDisturb ( username , payload ) ; }
Set don t disturb service while receiving messages . You can Add or remove single conversation or group conversation
47
19
33,457
public void addOrRemoveMembers ( long gid , String [ ] addList , String [ ] removeList ) throws APIConnectionException , APIRequestException { Members add = Members . newBuilder ( ) . addMember ( addList ) . build ( ) ; Members remove = Members . newBuilder ( ) . addMember ( removeList ) . build ( ) ; _groupClient . addOrRemoveMembers ( gid , add , remove ) ; }
Add or remove members from a group
95
7
33,458
public SendMessageResult sendSingleTextByAdmin ( String targetId , String fromId , MessageBody body ) throws APIConnectionException , APIRequestException { return sendMessage ( _sendVersion , "single" , targetId , "admin" , fromId , MessageType . TEXT , body ) ; }
Send single text message by admin
65
6
33,459
public ResponseWrapper addCrossBlacklist ( String username , CrossBlacklist [ ] blacklists ) throws APIConnectionException , APIRequestException { return _crossAppClient . addCrossBlacklist ( username , blacklists ) ; }
Add blacklist whose users belong to another app to a given user .
50
13
33,460
public CreateChatRoomResult createChatRoom ( ChatRoomPayload payload ) throws APIConnectionException , APIRequestException { Preconditions . checkArgument ( null != payload , "ChatRoomPayload should not be null" ) ; ResponseWrapper responseWrapper = _httpClient . sendPost ( _baseUrl + mChatRoomPath , payload . toString ( ) ) ; return CreateChatRoomResult . fromResponse ( responseWrapper , CreateChatRoomResult . class ) ; }
Create chat room
104
3
33,461
public ChatRoomListResult getBatchChatRoomInfo ( long ... roomIds ) throws APIConnectionException , APIRequestException { Preconditions . checkArgument ( roomIds != null && roomIds . length > 0 , "Room ids should not be null" ) ; JsonArray array = new JsonArray ( ) ; for ( long id : roomIds ) { array . add ( new JsonPrimitive ( id ) ) ; } ResponseWrapper responseWrapper = _httpClient . sendPost ( _baseUrl + mChatRoomPath + "/batch" , array . toString ( ) ) ; return ChatRoomListResult . fromResponse ( responseWrapper ) ; }
Get chat room information by room ids
150
8
33,462
public ChatRoomListResult getUserChatRoomInfo ( String username ) throws APIConnectionException , APIRequestException { StringUtils . checkUsername ( username ) ; ResponseWrapper responseWrapper = _httpClient . sendGet ( _baseUrl + mUserPath + "/" + username + "/chatroom" ) ; return ChatRoomListResult . fromResponse ( responseWrapper ) ; }
Get user s whole chat room information
85
7
33,463
public ResponseWrapper deleteChatRoom ( long roomId ) throws APIConnectionException , APIRequestException { Preconditions . checkArgument ( roomId > 0 , "room id is invalid" ) ; return _httpClient . sendDelete ( _baseUrl + mChatRoomPath + "/" + roomId ) ; }
Delete chat room by id
70
5
33,464
public DownloadResult downloadFile ( String mediaId ) throws APIConnectionException , APIRequestException { Preconditions . checkArgument ( null != mediaId , "mediaId is necessary" ) ; ResponseWrapper response = _httpClient . sendGet ( _baseUrl + resourcePath + "?mediaId=" + mediaId ) ; return DownloadResult . fromResponse ( response , DownloadResult . class ) ; }
Download file with mediaId will return DownloadResult which include url .
88
13
33,465
public MessageListResult v2GetMessageListByCursor ( String cursor ) throws APIConnectionException , APIRequestException { if ( null != cursor ) { String requestUrl = mBaseReportPath + mV2MessagePath + "?cursor=" + cursor ; ResponseWrapper response = _httpClient . sendGet ( requestUrl ) ; return MessageListResult . fromResponse ( response , MessageListResult . class ) ; } else { throw new IllegalArgumentException ( "the cursor parameter should not be null" ) ; } }
Get message list with cursor the cursor will effective in 120 seconds . And will return same count of messages as first request .
114
24
33,466
public MemberListResult getCrossGroupMembers ( long gid ) throws APIConnectionException , APIRequestException { Preconditions . checkArgument ( 0 != gid , "gid must not be empty" ) ; ResponseWrapper response = _httpClient . sendGet ( _baseUrl + crossGroupPath + "/" + gid + "/members/" ) ; return MemberListResult . fromResponse ( response ) ; }
Get members info from cross group
91
6
33,467
public ResponseWrapper deleteCrossBlacklist ( String username , CrossBlacklist [ ] blacklists ) throws APIConnectionException , APIRequestException { StringUtils . checkUsername ( username ) ; CrossBlacklistPayload payload = new CrossBlacklistPayload . Builder ( ) . setCrossBlacklists ( blacklists ) . build ( ) ; return _httpClient . sendDelete ( _baseUrl + crossUserPath + "/" + username + "/blacklist" , payload . toString ( ) ) ; }
Delete blacklist whose users belong to another app from a given user .
109
13
33,468
public ResponseWrapper deleteSensitiveWord ( String word ) throws APIConnectionException , APIRequestException { Preconditions . checkArgument ( word . length ( ) <= 10 , "one word's max length is 10" ) ; JsonObject jsonObject = new JsonObject ( ) ; jsonObject . addProperty ( "word" , word ) ; return _httpClient . sendDelete ( _baseUrl + sensitiveWordPath , jsonObject . toString ( ) ) ; }
Delete sensitive word
103
3
33,469
public ResponseWrapper updateSensitiveWordStatus ( int status ) throws APIConnectionException , APIRequestException { Preconditions . checkArgument ( status == 0 || status == 1 , "status should be 0 or 1" ) ; return _httpClient . sendPut ( _baseUrl + sensitiveWordPath + "/status?status=" + status , null ) ; }
Update sensitive word status
79
4
33,470
public SensitiveWordStatusResult getSensitiveWordStatus ( ) throws APIConnectionException , APIRequestException { ResponseWrapper responseWrapper = _httpClient . sendGet ( _baseUrl + sensitiveWordPath + "/status" ) ; return _gson . fromJson ( responseWrapper . responseContent , SensitiveWordStatusResult . class ) ; }
Get sensitive word status
78
4
33,471
public void setAction ( final Action fromAction , final Action toAction , final int rotation , long delay ) { setAction ( fromAction , false , ROTATE_CLOCKWISE ) ; postDelayed ( new Runnable ( ) { @ Override public void run ( ) { if ( ! isAttachedToWindow ( ) ) { return ; } setAction ( toAction , true , rotation ) ; } } , delay ) ; }
Sets a new action transition .
94
7
33,472
private float calculateScale ( int x , int y ) { final float centerX = getWidth ( ) / 2f ; final float centerY = getHeight ( ) / 2f ; final float maxDistance = ( float ) Math . sqrt ( centerX * centerX + centerY * centerY ) ; final float deltaX = centerX - x ; final float deltaY = centerY - y ; final float distance = ( float ) Math . sqrt ( deltaX * deltaX + deltaY * deltaY ) ; final float scale = 0.5f + ( distance / maxDistance ) * 0.5f ; return scale ; }
calculates the required scale of the ink - view to fill the whole view
134
16
33,473
public static boolean validOptions ( String [ ] [ ] options , DocErrorReporter reporter ) { return SARL_DOCLET . configuration . validOptions ( options , reporter ) ; }
Validate the given options .
38
6
33,474
public List < UUID > spawn ( int nbAgents , Class < ? extends Agent > agent , Object ... params ) { return this . spawnService . spawn ( nbAgents , null , this . janusContext , null , agent , params ) ; }
Spawn agents of the given type and pass the parameters to its initialization function .
56
15
33,475
public UUID spawn ( UUID agentID , Class < ? extends Agent > agent , Object ... params ) { final List < UUID > ids = this . spawnService . spawn ( 1 , null , this . janusContext , agentID , agent , params ) ; if ( ids . isEmpty ( ) ) { return null ; } return ids . get ( 0 ) ; }
Spawn an agent of the given type and pass the parameters to its initialization function .
82
16
33,476
public < S extends Service > S getService ( Class < S > type ) { for ( final Service serv : this . serviceManager . servicesByState ( ) . values ( ) ) { if ( serv . isRunning ( ) && type . isInstance ( serv ) ) { return type . cast ( serv ) ; } } return null ; }
Replies a kernel service that is alive .
71
9
33,477
public void setCodeminingEnabled ( Boolean enable ) { final IPreferenceStore store = getWritablePreferenceStore ( null ) ; if ( enable == null ) { store . setToDefault ( CODEMINING_PROPERTY ) ; } else { store . setValue ( CODEMINING_PROPERTY , enable . booleanValue ( ) ) ; } }
Enable or disable the codemining feature into the SARL editor .
80
14
33,478
public static void addFormalParameter ( ExecutableMemberDoc member , Parameter param , boolean isVarArg , Content htmlTree , SarlConfiguration configuration , SubWriterHolderWriter writer ) { final ProxyInstaller proxyInstaller = configuration . getProxyInstaller ( ) ; final ExecutableMemberDoc omember = proxyInstaller . unwrap ( member ) ; final Parameter oparam = proxyInstaller . unwrap ( param ) ; final String defaultValue = Utils . getParameterDefaultValue ( omember , oparam , configuration ) ; final boolean addDefaultValueBrackets = Utils . isNullOrEmpty ( defaultValue ) && Utils . isDefaultValuedParameter ( oparam , configuration ) ; if ( addDefaultValueBrackets ) { htmlTree . addContent ( "[" ) ; //$NON-NLS-1$ } if ( oparam . name ( ) . length ( ) > 0 ) { htmlTree . addContent ( oparam . name ( ) ) ; } htmlTree . addContent ( writer . getSpace ( ) ) ; htmlTree . addContent ( Utils . getKeywords ( ) . getColonKeyword ( ) ) ; htmlTree . addContent ( " " ) ; //$NON-NLS-1$ if ( oparam . type ( ) != null ) { final Content link = writer . getLink ( new LinkInfoImpl ( configuration , LinkInfoImpl . Kind . EXECUTABLE_MEMBER_PARAM , oparam . type ( ) ) . varargs ( isVarArg ) ) ; htmlTree . addContent ( link ) ; } if ( addDefaultValueBrackets ) { htmlTree . addContent ( "]" ) ; //$NON-NLS-1$ } else if ( ! Utils . isNullOrEmpty ( defaultValue ) ) { htmlTree . addContent ( " " ) ; //$NON-NLS-1$ htmlTree . addContent ( Utils . getKeywords ( ) . getEqualsSignKeyword ( ) ) ; htmlTree . addContent ( writer . getSpace ( ) ) ; htmlTree . addContent ( defaultValue ) ; } }
Add a parameter to the given executable member .
457
9
33,479
public String getKeyString ( ) { if ( ! Strings . isEmpty ( getAnnotatedWith ( ) ) ) { return MessageFormat . format ( "@{1} {0}" , getBind ( ) , getAnnotatedWith ( ) ) ; //$NON-NLS-1$ } if ( ! Strings . isEmpty ( getAnnotatedWithName ( ) ) ) { return MessageFormat . format ( "@Named({1}) {0}" , getBind ( ) , getAnnotatedWithName ( ) ) ; //$NON-NLS-1$ } return MessageFormat . format ( "{0}" , getBind ( ) ) ; //$NON-NLS-1$ }
Replies the string representation of the binding key .
155
10
33,480
protected void refreshSREListUI ( ) { // Refreshes the SRE listing after a SRE install notification, might not // happen on the UI thread. final Display display = Display . getDefault ( ) ; if ( display . getThread ( ) . equals ( Thread . currentThread ( ) ) ) { if ( ! this . sresList . isBusy ( ) ) { this . sresList . refresh ( ) ; } } else { display . syncExec ( new Runnable ( ) { @ SuppressWarnings ( "synthetic-access" ) @ Override public void run ( ) { if ( ! SREsPreferencePage . this . sresList . isBusy ( ) ) { SREsPreferencePage . this . sresList . refresh ( ) ; } } } ) ; } }
Refresh the UI list of SRE .
178
9
33,481
public void setErrorMessage ( Throwable exception ) { if ( exception != null ) { String message = exception . getLocalizedMessage ( ) ; if ( Strings . isNullOrEmpty ( message ) ) { message = exception . getMessage ( ) ; } if ( Strings . isNullOrEmpty ( message ) ) { message = MessageFormat . format ( Messages . SREsPreferencePage_9 , exception . getClass ( ) . getName ( ) ) ; } setErrorMessage ( message ) ; } }
Set the error message from the given exception .
109
9
33,482
protected void setSREs ( ISREInstall [ ] sres ) { this . sreArray . clear ( ) ; for ( final ISREInstall sre : sres ) { this . sreArray . add ( sre ) ; } this . sresList . setInput ( this . sreArray ) ; refreshSREListUI ( ) ; updateUI ( ) ; }
Sets the SREs to be displayed in this block .
82
13
33,483
public String createUniqueName ( String name ) { if ( ! isDuplicateName ( name ) ) { return name ; } if ( name . matches ( ".*\\(\\d*\\)" ) ) { //$NON-NLS-1$ final int start = name . lastIndexOf ( ' ' ) ; final int end = name . lastIndexOf ( ' ' ) ; final String stringInt = name . substring ( start + 1 , end ) ; final int numericValue = Integer . parseInt ( stringInt ) ; final String newName = name . substring ( 0 , start + 1 ) + ( numericValue + 1 ) + ")" ; //$NON-NLS-1$ return createUniqueName ( newName ) ; } return createUniqueName ( name + " (1)" ) ; //$NON-NLS-1$ }
Compares the given name against current names and adds the appropriate numerical suffix to ensure that it is unique .
185
21
33,484
protected void addSRE ( ) { final AddSREInstallWizard wizard = new AddSREInstallWizard ( createUniqueIdentifier ( ) , this . sreArray . toArray ( new ISREInstall [ this . sreArray . size ( ) ] ) ) ; final WizardDialog dialog = new WizardDialog ( getShell ( ) , wizard ) ; if ( dialog . open ( ) == Window . OK ) { final ISREInstall result = wizard . getCreatedSRE ( ) ; if ( result != null ) { this . sreArray . add ( result ) ; //refresh from model refreshSREListUI ( ) ; this . sresList . setSelection ( new StructuredSelection ( result ) ) ; //ensure labels are updated if ( ! this . sresList . isBusy ( ) ) { this . sresList . refresh ( true ) ; } updateUI ( ) ; // Autoselect the default SRE if ( getDefaultSRE ( ) == null ) { setDefaultSRE ( result ) ; } } } }
Add a SRE .
226
5
33,485
protected void editSRE ( ) { final IStructuredSelection selection = ( IStructuredSelection ) this . sresList . getSelection ( ) ; final ISREInstall sre = ( ISREInstall ) selection . getFirstElement ( ) ; if ( sre == null ) { return ; } final EditSREInstallWizard wizard = new EditSREInstallWizard ( sre , this . sreArray . toArray ( new ISREInstall [ this . sreArray . size ( ) ] ) ) ; final WizardDialog dialog = new WizardDialog ( getShell ( ) , wizard ) ; if ( dialog . open ( ) == Window . OK ) { this . sresList . setSelection ( new StructuredSelection ( sre ) ) ; this . sresList . refresh ( true ) ; updateUI ( ) ; } }
Edit the selected SRE .
182
6
33,486
@ SuppressWarnings ( "unchecked" ) protected void copySRE ( ) { final IStructuredSelection selection = ( IStructuredSelection ) this . sresList . getSelection ( ) ; final Iterator < ISREInstall > it = selection . iterator ( ) ; final List < ISREInstall > newEntries = new ArrayList <> ( ) ; while ( it . hasNext ( ) ) { final ISREInstall selectedSRE = it . next ( ) ; final ISREInstall copy = selectedSRE . copy ( createUniqueIdentifier ( ) ) ; copy . setName ( createUniqueName ( selectedSRE . getName ( ) ) ) ; final EditSREInstallWizard wizard = new EditSREInstallWizard ( copy , this . sreArray . toArray ( new ISREInstall [ this . sreArray . size ( ) ] ) ) ; final WizardDialog dialog = new WizardDialog ( getShell ( ) , wizard ) ; final int dlgResult = dialog . open ( ) ; if ( dlgResult == Window . OK ) { newEntries . add ( copy ) ; } else { assert dlgResult == Window . CANCEL ; // Canceling one wizard should cancel all subsequent wizards break ; } } if ( ! newEntries . isEmpty ( ) ) { this . sreArray . addAll ( newEntries ) ; refreshSREListUI ( ) ; this . sresList . setSelection ( new StructuredSelection ( newEntries . toArray ( ) ) ) ; } else { this . sresList . setSelection ( selection ) ; } this . sresList . refresh ( true ) ; updateUI ( ) ; }
Copy the selected SRE .
368
6
33,487
@ SuppressWarnings ( "unchecked" ) protected void removeSREs ( ) { final IStructuredSelection selection = ( IStructuredSelection ) this . sresList . getSelection ( ) ; final ISREInstall [ ] vms = new ISREInstall [ selection . size ( ) ] ; final Iterator < ISREInstall > iter = selection . iterator ( ) ; int i = 0 ; while ( iter . hasNext ( ) ) { vms [ i ] = iter . next ( ) ; i ++ ; } removeSREs ( vms ) ; }
Remove the selected SREs .
126
7
33,488
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) public void removeSREs ( ISREInstall ... sres ) { final ISREInstall defaultSRE = getDefaultSRE ( ) ; final String defaultId = defaultSRE == null ? null : defaultSRE . getId ( ) ; int defaultIndex = - 1 ; if ( defaultId != null ) { for ( int i = 0 ; defaultIndex == - 1 && i < this . sreTable . getItemCount ( ) ; ++ i ) { if ( defaultId . equals ( ( ( ISREInstall ) this . sreTable . getItem ( i ) . getData ( ) ) . getId ( ) ) ) { defaultIndex = i ; } } } final String normedDefaultId = Strings . nullToEmpty ( defaultId ) ; boolean defaultIsRemoved = false ; for ( final ISREInstall sre : sres ) { if ( this . sreArray . remove ( sre ) && sre . getId ( ) . equals ( normedDefaultId ) ) { defaultIsRemoved = true ; } } refreshSREListUI ( ) ; // Update the default SRE if ( defaultIsRemoved ) { if ( this . sreTable . getItemCount ( ) == 0 ) { setSelection ( null ) ; } else { if ( defaultIndex < 0 ) { defaultIndex = 0 ; } else if ( defaultIndex >= this . sreTable . getItemCount ( ) ) { defaultIndex = this . sreTable . getItemCount ( ) - 1 ; } setSelection ( new StructuredSelection ( this . sreTable . getItem ( defaultIndex ) . getData ( ) ) ) ; } } this . sresList . refresh ( true ) ; if ( defaultIsRemoved ) { fireDefaultSREChanged ( ) ; } updateUI ( ) ; }
Removes the given SREs from the table .
402
11
33,489
@ SuppressWarnings ( "unchecked" ) private void enableButtons ( ) { final IStructuredSelection selection = ( IStructuredSelection ) this . sresList . getSelection ( ) ; final int selectionCount = selection . size ( ) ; this . editButton . setEnabled ( selectionCount == 1 ) ; this . copyButton . setEnabled ( selectionCount > 0 ) ; if ( selectionCount > 0 && selectionCount <= this . sresList . getTable ( ) . getItemCount ( ) ) { final Iterator < ISREInstall > iterator = selection . iterator ( ) ; while ( iterator . hasNext ( ) ) { final ISREInstall install = iterator . next ( ) ; if ( SARLRuntime . isPlatformSRE ( install ) ) { this . removeButton . setEnabled ( false ) ; return ; } } this . removeButton . setEnabled ( true ) ; } else { this . removeButton . setEnabled ( false ) ; } }
Enables the buttons based on selected items counts in the viewer .
209
13
33,490
private void sortByName ( ) { this . sresList . setComparator ( new ViewerComparator ( ) { @ Override public int compare ( Viewer viewer , Object e1 , Object e2 ) { if ( ( e1 instanceof ISREInstall ) && ( e2 instanceof ISREInstall ) ) { final ISREInstall left = ( ISREInstall ) e1 ; final ISREInstall right = ( ISREInstall ) e2 ; return left . getName ( ) . compareToIgnoreCase ( right . getName ( ) ) ; } return super . compare ( viewer , e1 , e2 ) ; } @ Override public boolean isSorterProperty ( Object element , String property ) { return true ; } } ) ; this . sortColumn = Column . NAME ; }
Sorts by SRE name .
169
7
33,491
private void sortByLocation ( ) { this . sresList . setComparator ( new ViewerComparator ( ) { @ Override public int compare ( Viewer viewer , Object e1 , Object e2 ) { if ( ( e1 instanceof ISREInstall ) && ( e2 instanceof ISREInstall ) ) { final ISREInstall left = ( ISREInstall ) e1 ; final ISREInstall right = ( ISREInstall ) e2 ; return left . getLocation ( ) . compareToIgnoreCase ( right . getLocation ( ) ) ; } return super . compare ( viewer , e1 , e2 ) ; } @ Override public boolean isSorterProperty ( Object element , String property ) { return true ; } } ) ; this . sortColumn = Column . LOCATION ; }
Sorts by VM location .
170
6
33,492
@ SuppressWarnings ( "static-method" ) protected Collection < AbstractSubCodeBuilderFragment > initializeSubGenerators ( Injector injector ) { final Collection < AbstractSubCodeBuilderFragment > fragments = new ArrayList <> ( ) ; fragments . add ( injector . getInstance ( BuilderFactoryFragment . class ) ) ; fragments . add ( injector . getInstance ( DocumentationBuilderFragment . class ) ) ; fragments . add ( injector . getInstance ( AbstractBuilderBuilderFragment . class ) ) ; fragments . add ( injector . getInstance ( AbstractAppenderBuilderFragment . class ) ) ; fragments . add ( injector . getInstance ( ScriptBuilderFragment . class ) ) ; return fragments ; }
Initialize the sub generators .
157
6
33,493
protected BindingFactory createRuntimeBindings ( ) { final BindingFactory factory = new BindingFactory ( getClass ( ) . getName ( ) ) ; for ( final AbstractSubCodeBuilderFragment subFragment : this . subFragments ) { subFragment . generateRuntimeBindings ( factory ) ; } return factory ; }
Create the runtime bindings for the builders .
67
8
33,494
protected BindingFactory createEclipseBindings ( ) { final BindingFactory factory = new BindingFactory ( getClass ( ) . getName ( ) ) ; for ( final AbstractSubCodeBuilderFragment subFragment : this . subFragments ) { subFragment . generateEclipseBindings ( factory ) ; } return factory ; }
Create the Eclipse bindings for the builders .
69
8
33,495
protected BindingFactory createIdeaBindings ( ) { final BindingFactory factory = new BindingFactory ( getClass ( ) . getName ( ) ) ; for ( final AbstractSubCodeBuilderFragment subFragment : this . subFragments ) { subFragment . generateIdeaBindings ( factory ) ; } return factory ; }
Create the IDEA bindings for the builders .
69
9
33,496
protected BindingFactory createWebBindings ( ) { final BindingFactory factory = new BindingFactory ( getClass ( ) . getName ( ) ) ; for ( final AbstractSubCodeBuilderFragment subFragment : this . subFragments ) { subFragment . generateWebBindings ( factory ) ; } return factory ; }
Create the Web - interface bindings for the builders .
67
10
33,497
@ Override @ Pure public int compareTo ( Address address ) { if ( address == null ) { return 1 ; } return this . agentId . compareTo ( address . getUUID ( ) ) ; }
Compares this object with the specified object for order . Returns a negative integer zero or a positive integer as this object is less than equal to or greater than the specified object .
44
35
33,498
public static void main ( String [ ] args ) { final int retCode = createMainObject ( ) . runCompiler ( args ) ; System . exit ( retCode ) ; }
Main program of the batch compiler .
38
7
33,499
public void setFromString ( String sectionNumber , int level ) { assert level >= 1 ; final String [ ] numbers = sectionNumber . split ( "[^0-9]+" ) ; //$NON-NLS-1$ final int len = Math . max ( 0 , this . numbers . size ( ) - numbers . length ) ; for ( int i = 0 ; i < len ; ++ i ) { this . numbers . removeLast ( ) ; } for ( int i = 0 ; i < numbers . length && i < level ; ++ i ) { this . numbers . addLast ( Integer . valueOf ( numbers [ i ] ) ) ; } }
Change this version number from the given string representation .
139
10