Ejemplo n.º 1
1
		/// <summary>
		/// 当配置更新时,被调用
		/// </summary>
		/// <param name="event"> </param>
		public virtual void propertiesReloaded(PropertiesReloadedEvent @event)
		{

			Properties oldProperties = lastMergedProperties;

			try
			{
				//
				Properties newProperties = mergeProperties();

				//
				// 获取哪些 dynamic property 被影响
				//
				ISet<string> placeholders = placeholderToDynamics.Keys;
				ISet<DynamicProperty> allDynamics = new HashSet<DynamicProperty>();
				foreach (string placeholder in placeholders)
				{
					string newValue = newProperties.getProperty(placeholder);
					string oldValue = oldProperties.getProperty(placeholder);
					if (!string.ReferenceEquals(newValue, null) && !newValue.Equals(oldValue) || string.ReferenceEquals(newValue, null) && !string.ReferenceEquals(oldValue, null))
					{
						if (logger.InfoEnabled)
						{
							logger.info("Property changed detected: " + placeholder + (!string.ReferenceEquals(newValue, null) ? "=" + newValue : " removed"));
						}
						IList<DynamicProperty> affectedDynamics = placeholderToDynamics[placeholder];
						allDynamics.addAll(affectedDynamics);
					}
				}

				//
				// 获取受影响的beans
				//
				IDictionary<string, IList<DynamicProperty>> dynamicsByBeanName = new Dictionary<string, IList<DynamicProperty>>();
				IDictionary<string, object> beanByBeanName = new Dictionary<string, object>();
				foreach (DynamicProperty dynamic in allDynamics)
				{
					string beanName = dynamic.BeanName;
					IList<DynamicProperty> l = dynamicsByBeanName[beanName];

					if (l == null)
					{
						dynamicsByBeanName[beanName] = (l = new List<DynamicProperty>());
						object bean = null;
						try
						{
							bean = applicationContext.getBean(beanName);
							beanByBeanName[beanName] = bean;
						}
						catch (BeansException e)
						{
							// keep dynamicsByBeanName list, warn only once.
							logger.error("Error obtaining bean " + beanName, e);
						}

						//
						// say hello
						//
						try
						{
							if (bean is IReconfigurationAware)
							{
								((IReconfigurationAware) bean).beforeReconfiguration(); // hello!
							}
						}
						catch (Exception e)
						{
							logger.error("Error calling beforeReconfiguration on " + beanName, e);
						}
					}
					l.Add(dynamic);
				}

				//
				// 处理受影响的bean
				//
				IDictionary<string, IList<DynamicProperty>>.KeyCollection beanNames = dynamicsByBeanName.Keys;
				foreach (string beanName in beanNames)
				{
					object bean = beanByBeanName[beanName];
					if (bean == null) // problems obtaining bean, earlier
					{
						continue;
					}
					BeanWrapper beanWrapper = new BeanWrapperImpl(bean);

					// for all affected ...
					IList<DynamicProperty> dynamics = dynamicsByBeanName[beanName];
					foreach (DynamicProperty dynamic in dynamics)
					{
						string propertyName = dynamic.PropertyName;
						string unparsedValue = dynamic.UnparsedValue;

						// obtain an updated value, including dependencies
						string newValue;
						removeDynamic(dynamic);
						currentBeanName = beanName;
						currentPropertyName = propertyName;
						try
						{
							newValue = parseStringValue(unparsedValue, newProperties, new HashSet());
						}
						finally
						{
							currentBeanName = null;
							currentPropertyName = null;
						}
						if (logger.InfoEnabled)
						{
							logger.info("Updating property " + beanName + "." + propertyName + " to " + newValue);
						}

						// assign it to the bean
						try
						{
							beanWrapper.setPropertyValue(propertyName, newValue);
						}
						catch (BeansException e)
						{
							logger.error("Error setting property " + beanName + "." + propertyName + " to " + newValue, e);
						}
					}
				}

				//
				// say goodbye.
				//
				foreach (string beanName in beanNames)
				{
					object bean = beanByBeanName[beanName];
					try
					{

						if (bean is IReconfigurationAware)
						{
							((IReconfigurationAware) bean).afterReconfiguration();
						}
					}
					catch (Exception e)
					{
						logger.error("Error calling afterReconfiguration on " + beanName, e);
					}
				}

			}
			catch (IOException e)
			{
				logger.error("Error trying to reload net.unicon.iamlabs.spring.properties.example.net.unicon.iamlabs" + ".spring" + ".properties: " + e.Message, e);
			}
		}
Ejemplo n.º 2
0
        protected internal virtual ProcessApplicationRegistration registerProcessApplication(CommandContext commandContext, DeploymentEntity deployment, ISet <string> processKeysToRegisterFor)
        {
            ProcessApplicationDeploymentBuilderImpl appDeploymentBuilder = (ProcessApplicationDeploymentBuilderImpl)deploymentBuilder;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.application.ProcessApplicationReference appReference = appDeploymentBuilder.getProcessApplicationReference();
            ProcessApplicationReference appReference = appDeploymentBuilder.ProcessApplicationReference;

            // build set of deployment ids this process app should be registered for:
            ISet <string> deploymentsToRegister = new HashSet <string>(Collections.singleton(deployment.Id));

            if (appDeploymentBuilder.ResumePreviousVersions)
            {
                if (ResumePreviousBy.RESUME_BY_PROCESS_DEFINITION_KEY.Equals(appDeploymentBuilder.ResumePreviousVersionsBy))
                {
                    deploymentsToRegister.addAll(resumePreviousByProcessDefinitionKey(commandContext, deployment, processKeysToRegisterFor));
                }
                else if (ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME.Equals(appDeploymentBuilder.ResumePreviousVersionsBy))
                {
                    deploymentsToRegister.addAll(resumePreviousByDeploymentName(commandContext, deployment));
                }
            }

            // register process application for deployments
            return((new RegisterProcessApplicationCmd(deploymentsToRegister, appReference)).execute(commandContext));
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public java.util.Collection<org.neo4j.server.plugins.Injectable<?>> initializePackages(Iterable<String> packageNames)
        public virtual ICollection <Injectable <object> > InitializePackages(IEnumerable <string> packageNames)
        {
            GraphDatabaseAPI graphDatabaseService = _neoServer.Database.Graph;
            Config           configuration        = _neoServer.Config;

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Collection<org.neo4j.server.plugins.Injectable<?>> injectables = new java.util.HashSet<>();
            ICollection <Injectable <object> > injectables = new HashSet <Injectable <object> >();

            foreach (PluginLifecycle lifecycle in _lifecycles)
            {
                if (HasPackage(lifecycle, packageNames))
                {
                    if (lifecycle is SPIPluginLifecycle)
                    {
                        SPIPluginLifecycle lifeCycleSpi = ( SPIPluginLifecycle )lifecycle;
                        injectables.addAll(lifeCycleSpi.Start(_neoServer));
                    }
                    else
                    {
                        injectables.addAll(lifecycle.Start(graphDatabaseService, new ConfigAdapter(configuration)));
                    }
                }
            }
            return(injectables);
        }
Ejemplo n.º 4
0
 internal static ICollection <EntityId> Merge(ICollection <EntityId> c1, ICollection <EntityId> c2)
 {
     if (c1 == null && c2 == null)
     {
         return(Collections.emptySet());
     }
     else if (c1 != null && c2 != null)
     {
         if (c1.Count == 0)
         {
             return(c2);
         }
         if (c2.Count == 0)
         {
             return(c1);
         }
         ICollection <EntityId> result = new HashSet <EntityId>(c1.Count + c2.Count, 1);
         result.addAll(c1);
         result.addAll(c2);
         return(result);
     }
     else
     {
         return(c1 != null ? c1 : c2);
     }
 }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getAllRelationships()
        public virtual void getAllRelationships()
        {
            ISet <Relationship> existingRelationships = Iterables.addToCollection(GraphDb.AllRelationships, new HashSet <Relationship>());

            ISet <Relationship> createdRelationships = new HashSet <Relationship>();
            Node node = GraphDb.createNode();

            for (int i = 0; i < 100; i++)
            {
                createdRelationships.Add(node.CreateRelationshipTo(GraphDb.createNode(), TEST));
            }
            NewTransaction();

            ISet <Relationship> allRelationships = new HashSet <Relationship>();

            allRelationships.addAll(existingRelationships);
            allRelationships.addAll(createdRelationships);

            int count = 0;

            foreach (Relationship rel in GraphDb.AllRelationships)
            {
                assertTrue("Unexpected rel " + rel + ", expected one of " + allRelationships, allRelationships.Contains(rel));
                count++;
            }
            assertEquals(allRelationships.Count, count);
        }
Ejemplo n.º 6
0
        // private methods
        // the inWord should be lowerCase()
        // return all possible split combo within edit distance of N
        // maxSplitNo must >= 1 to get come result
        protected internal static HashSet <string> GetSplitSetBySpaces(string inWord, int maxSplitNo)
        {
            HashSet <string> splitSet = new HashSet <string>();

            // check iuputs
            if ((string.ReferenceEquals(inWord, null)) || (inWord.Length == 0) || (maxSplitNo < 1))
            {
                return(splitSet);
            }
            HashSet <string> curSplitSet = GetSplitSetBy1Space(inWord);

            splitSet.addAll(curSplitSet);
            int spaceNo = 1;

            // recursively for more than 1 split by space
            while (spaceNo < maxSplitNo)
            {
                HashSet <string> nextSplitSet = new HashSet <string>();
                // generate next level of split based on current split
                foreach (string curSplit in curSplitSet)
                {
                    HashSet <string> tempSplitSet = GetSplitSetBy1Space(curSplit);
                    nextSplitSet.addAll(tempSplitSet);
                }
                // updates
                curSplitSet = new HashSet <string>(nextSplitSet);
                splitSet.addAll(nextSplitSet);
                spaceNo++;
            }
            return(splitSet);
        }
Ejemplo n.º 7
0
        public HashSet <Spring_IdentifierDecl> DeclaredVariables()
        {
            // VERY BAD DESIGN. TODO: refactor
            var funParameters = this.Children()
                                .FirstOrDefault((x => x.NodeType == SpringCompositeNodeType.FUNCTION_PARAMETER_LIST))
                                ?.Descendants().OfType <Spring_IdentifierDecl>()
                                .Collect();


            var localVariables = this.Children()
                                 .FirstOrDefault(x => x.NodeType == SpringCompositeNodeType.LOCAL_VARIABLES)
                                 ?.Descendants().OfType <Spring_IdentifierDecl>()
                                 .Collect();

            var declaredVariables = new HashSet <Spring_IdentifierDecl>();

            if (funParameters != null)
            {
                declaredVariables.addAll(funParameters);
            }

            if (localVariables != null)
            {
                declaredVariables.addAll(localVariables);
            }

            return(declaredVariables);
        }
Ejemplo n.º 8
0
        protected internal virtual ICollection <string> collectProcessInstanceIds()
        {
            HashSet <string> allProcessInstanceIds = new HashSet <string>();

            IList <string> processInstanceIds = builder.ProcessInstanceIds;

            if (processInstanceIds != null)
            {
                allProcessInstanceIds.addAll(processInstanceIds);
            }

            ProcessInstanceQueryImpl processInstanceQuery = (ProcessInstanceQueryImpl)builder.ProcessInstanceQuery;

            if (processInstanceQuery != null)
            {
                allProcessInstanceIds.addAll(processInstanceQuery.listIds());
            }

            HistoricProcessInstanceQueryImpl historicProcessInstanceQuery = (HistoricProcessInstanceQueryImpl)builder.HistoricProcessInstanceQuery;

            if (historicProcessInstanceQuery != null)
            {
                allProcessInstanceIds.addAll(historicProcessInstanceQuery.listIds());
            }

            return(allProcessInstanceIds);
        }
Ejemplo n.º 9
0
        protected internal virtual IList <string> collectExternalTaskIds()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.Set<String> collectedIds = new java.util.HashSet<String>();
            ISet <string> collectedIds = new HashSet <string>();

            IList <string> externalTaskIds = builder.ExternalTaskIds;

            if (externalTaskIds != null)
            {
                ensureNotContainsNull(typeof(BadUserRequestException), "External task id cannot be null", "externalTaskIds", externalTaskIds);
                collectedIds.addAll(externalTaskIds);
            }

            ExternalTaskQueryImpl externalTaskQuery = (ExternalTaskQueryImpl)builder.ExternalTaskQuery;

            if (externalTaskQuery != null)
            {
                collectedIds.addAll(externalTaskQuery.listIds());
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<String> collectedProcessInstanceIds = collectProcessInstanceIds();
            IList <string> collectedProcessInstanceIds = collectProcessInstanceIds();

            if (collectedProcessInstanceIds.Count > 0)
            {
                Context.CommandContext.runWithoutAuthorization(new CallableAnonymousInnerClass(this, collectedIds, collectedProcessInstanceIds));
            }

            return(new List <string>(collectedIds));
        }
Ejemplo n.º 10
0
        protected internal virtual IList <string> collectProcessInstanceIds()
        {
            ISet <string> collectedProcessInstanceIds = new HashSet <string>();

            IList <string> processInstanceIds = builder.ProcessInstanceIds;

            if (processInstanceIds != null && processInstanceIds.Count > 0)
            {
                collectedProcessInstanceIds.addAll(processInstanceIds);
            }

            ProcessInstanceQueryImpl processInstanceQuery = (ProcessInstanceQueryImpl)builder.ProcessInstanceQuery;

            if (processInstanceQuery != null)
            {
                collectedProcessInstanceIds.addAll(processInstanceQuery.listIds());
            }

            HistoricProcessInstanceQueryImpl historicProcessInstanceQuery = (HistoricProcessInstanceQueryImpl)builder.HistoricProcessInstanceQuery;

            if (historicProcessInstanceQuery != null)
            {
                collectedProcessInstanceIds.addAll(historicProcessInstanceQuery.listIds());
            }

            return(new List <string>(collectedProcessInstanceIds));
        }
Ejemplo n.º 11
0
        private ISet <T> Join <T>(ISet <T> set, ISet <T> set2)
        {
            ISet <T> result = new HashSet <T>();

            result.addAll(set);
            result.addAll(set2);
            return(result);
        }
Ejemplo n.º 12
0
        private string[] mergeTypes(string[] paramArrayOfString1, string[] paramArrayOfString2)
        {
            HashSet <object> hashSet = new HashSet <object>(2 * (paramArrayOfString1.Length + paramArrayOfString2.Length));

            hashSet.addAll(Arrays.asList(paramArrayOfString1));
            hashSet.addAll(Arrays.asList(paramArrayOfString2));
            return((string[])hashSet.toArray(new string[hashSet.Count]));
        }
Ejemplo n.º 13
0
        // get all possible regular inflVars for a base
        public static HashSet <string> GetInflVars(string baseStr)
        {
            HashSet <string> inflVarSet = GetInflVarsAdj(baseStr);

            inflVarSet.addAll(GetInflVarsNoun(baseStr));
            inflVarSet.addAll(GetInflVarsVerb(baseStr));
            return(inflVarSet);
        }
Ejemplo n.º 14
0
        public virtual void failure_fromResults_varargs2()
        {
            Result <string>    success1 = Result.success("success 1");
            Result <string>    success2 = Result.success("success 1");
            Result <object>    failure1 = Result.failure(MISSING_DATA, "failure 1");
            Result <object>    failure2 = Result.failure(ERROR, "failure 2");
            Result <object>    test     = Result.failure(success1, failure1, success2, failure2);
            ISet <FailureItem> expected = new HashSet <FailureItem>();

            expected.addAll(failure1.Failure.Items);
            expected.addAll(failure2.Failure.Items);
            assertEquals(test.Failure.Items, expected);
        }
Ejemplo n.º 15
0
 /**
  * Removes duplicates.
  * @param list of terms
  * @return duplicate free list
  */
 private List<String> removeDuplicates( List<String> list) {
     HashSet<String> hs = new HashSet<String>();
    hs.addAll(list);
    list.clear();
    list.addAll(hs);
    return list;
 }
Ejemplo n.º 16
0
        protected internal virtual IList <string> collectHistoricProcessInstanceIds()
        {
            ISet <string> collectedProcessInstanceIds = new HashSet <string>();

            IList <string> processInstanceIds = this.HistoricProcessInstanceIds;

            if (processInstanceIds != null)
            {
                collectedProcessInstanceIds.addAll(processInstanceIds);
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl processInstanceQuery = (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) this.historicProcessInstanceQuery;
            HistoricProcessInstanceQueryImpl processInstanceQuery = (HistoricProcessInstanceQueryImpl)this.historicProcessInstanceQuery;

            if (processInstanceQuery != null)
            {
                foreach (HistoricProcessInstance hpi in processInstanceQuery.list())
                {
                    collectedProcessInstanceIds.Add(hpi.Id);
                }
            }

            return(new List <string>(collectedProcessInstanceIds));
        }
Ejemplo n.º 17
0
        private static HashSet <String> newHashSet(params String[] strings)
        {
            HashSet <String> set = new HashSet <String>();

            set.addAll(Arrays.asList(strings));
            return(set);
        }
Ejemplo n.º 18
0
        public override ISet <SelectionKey> keys()
        {
            ISet <SelectionKey> setKeys = new HashSet <SelectionKey>();

            setKeys.addAll(rawSelectionKeys);
            return(setKeys);
        }
Ejemplo n.º 19
0
        public virtual void failure_fromResults_collection()
        {
            Result <string> success1 = Result.success("success 1");
            Result <string> success2 = Result.success("success 1");
            Result <string> failure1 = Result.failure(MISSING_DATA, "failure 1");
            Result <string> failure2 = Result.failure(ERROR, "failure 2");

            // Exposing collection explicitly shows why signature of failure is as it is
            IList <Result <string> > results  = Arrays.asList(success1, success2, failure1, failure2);
            Result <string>          test     = Result.failure(results);
            ISet <FailureItem>       expected = new HashSet <FailureItem>();

            expected.addAll(failure1.Failure.Items);
            expected.addAll(failure2.Failure.Items);
            assertEquals(test.Failure.Items, expected);
        }
Ejemplo n.º 20
0
            internal virtual void updateTagFMeasure(string[] refs, string[] preds)
            {
                // create a set with all tags
                HashSet <string> tags = new HashSet <string>(Arrays.asList(refs));

                tags.addAll(Arrays.asList(preds));

                // create samples for each tag
                foreach (string tag in tags)
                {
                    IList <Span> reference  = new List <Span>();
                    IList <Span> prediction = new List <Span>();
                    for (int i = 0; i < refs.Length; i++)
                    {
                        if (refs[i].Equals(tag))
                        {
                            reference.Add(new Span(i, i + 1));
                        }
                        if (preds[i].Equals(tag))
                        {
                            prediction.Add(new Span(i, i + 1));
                        }
                    }
                    if (!this.tagFMeasure.ContainsKey(tag))
                    {
                        this.tagFMeasure[tag] = new FMeasure();
                    }
                    // populate the fmeasure
                    this.tagFMeasure[tag].updateScores(reference.ToArray(), prediction.ToArray());
                }
            }
Ejemplo n.º 21
0
        // Trap door needed to keep this as an enum
        internal virtual void ReplacePropertyKeysToInclude(IList <string> propertyKeysToIncludeNow)
        {
            ISet <string> copiedPropertyKeysToIncludeNow = new HashSet <string>(propertyKeysToIncludeNow.Count);

            copiedPropertyKeysToIncludeNow.addAll(propertyKeysToIncludeNow);
            this._propertyKeysToInclude.set(copiedPropertyKeysToIncludeNow);
        }
Ejemplo n.º 22
0
        protected internal override IList <string> collectJobIds(CommandContext commandContext)
        {
            ISet <string> collectedJobIds = new HashSet <string>();

            IList <string> jobIds = this.JobIds;

            if (jobIds != null)
            {
                collectedJobIds.addAll(jobIds);
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.runtime.JobQuery jobQuery = this.jobQuery;
            JobQuery jobQuery = this.jobQuery;

            if (jobQuery != null)
            {
                foreach (Job job in jobQuery.list())
                {
                    collectedJobIds.Add(job.Id);
                }
            }

            return(new List <string>(collectedJobIds));
        }
Ejemplo n.º 23
0
        private bool IsDeadlockReal(ForsetiLockManager.Lock @lock, int tries)
        {
            ISet <ForsetiLockManager.Lock> waitedUpon     = new HashSet <ForsetiLockManager.Lock>();
            ISet <ForsetiClient>           owners         = new HashSet <ForsetiClient>();
            ISet <ForsetiLockManager.Lock> nextWaitedUpon = new HashSet <ForsetiLockManager.Lock>();
            ISet <ForsetiClient>           nextOwners     = new HashSet <ForsetiClient>();

            @lock.CollectOwners(owners);

            do
            {
                waitedUpon.addAll(nextWaitedUpon);
                CollectNextOwners(waitedUpon, owners, nextWaitedUpon, nextOwners);
                if (nextOwners.Contains(this) && tries > 20)
                {
                    // Worrying... let's take a deep breath
                    nextOwners.Clear();
                    LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
                    // ... and check again
                    CollectNextOwners(waitedUpon, owners, nextWaitedUpon, nextOwners);
                    if (nextOwners.Contains(this))
                    {
                        // Yes, this deadlock looks real.
                        return(true);
                    }
                }
                owners.Clear();
                ISet <ForsetiClient> ownersTmp = owners;
                owners     = nextOwners;
                nextOwners = ownersTmp;
            } while (nextWaitedUpon.Count > 0);
            // Nope, we didn't find any real wait cycles.
            return(false);
        }
Ejemplo n.º 24
0
		/**
		 * Return those entities that are used, but not defined.
		 */
		public Collection getUndefined() 
		{
			HashSet result = new HashSet();
			result.addAll(use.getCollection());
			result.removeAll(def.getCollection());
			return result;
		}
Ejemplo n.º 25
0
        /* Modification */

        /**
         * Update by replacing one set of Simplices with another.
         * Both sets of simplices must fill the same "hole" in the
         * Triangulation.
         * @param oldSet set of Simplices to be replaced
         * @param newSet set of replacement Simplices
         */
        public void update(Set oldSet,
                           Set newSet)
        {
            // Collect all simplices neighboring the oldSet
            Set allNeighbors = new HashSet();

            for (Iterator it = oldSet.iterator(); it.hasNext();)
            {
                allNeighbors.addAll((Set)_neighbors.get((Simplex)it.next()));
            }
            // Delete the oldSet
            for (Iterator it = oldSet.iterator(); it.hasNext();)
            {
                Simplex simplex = (Simplex)it.next();
                for (Iterator otherIt = ((Set)_neighbors.get(simplex)).iterator();
                     otherIt.hasNext();)
                {
                    ((Set)_neighbors.get(otherIt.next())).remove(simplex);
                }
                _neighbors.remove(simplex);
                allNeighbors.remove(simplex);
            }
            // Include the newSet simplices as possible neighbors
            allNeighbors.addAll(newSet);
            // Create entries for the simplices in the newSet
            for (Iterator it = newSet.iterator(); it.hasNext();)
            {
                _neighbors.put((Simplex)it.next(), new HashSet());
            }
            // Update all the neighbors info
            for (Iterator it = newSet.iterator(); it.hasNext();)
            {
                Simplex s1 = (Simplex)it.next();
                for (Iterator otherIt = allNeighbors.iterator(); otherIt.hasNext();)
                {
                    Simplex s2 = (Simplex)otherIt.next();
                    if (!s1.isNeighbor(s2))
                    {
                        continue;
                    }
                    ((Set)_neighbors.get(s1)).add(s2);
                    ((Set)_neighbors.get(s2)).add(s1);
                }
            }
        }
Ejemplo n.º 26
0
        public virtual ISet <string> keySet()
        {
            ISet <string> keySet = new HashSet <string>();

            foreach (VariableContext variableContext in delegateContexts)
            {
                keySet.addAll(variableContext.Keys);
            }
            return(keySet);
        }
Ejemplo n.º 27
0
 public override void StopAutoIndexingProperty(string propName)
 {
     _propertyKeysToInclude.getAndUpdate(current =>
     {
         ISet <string> updated = new HashSet <string>();
         updated.addAll(current);
         updated.remove(propName);
         return(updated);
     });
 }
Ejemplo n.º 28
0
        public override IndexOrder[] OrderCapability(params ValueCategory[] valueCategories)
        {
            ISet <IndexOrder> orderCapability = new HashSet <IndexOrder>();

            foreach (IndexCapability capability in _capabilities)
            {
                orderCapability.addAll(Arrays.asList(capability.OrderCapability(valueCategories)));
            }
            return(orderCapability.toArray(new IndexOrder[orderCapability.Count]));
        }
Ejemplo n.º 29
0
        private IndexLimitation[] LimitationsUnion(IEnumerable <IndexCapability> capabilities)
        {
            HashSet <IndexLimitation> union = new HashSet <IndexLimitation>();

            foreach (IndexCapability capability in capabilities)
            {
                union.addAll(Arrays.asList(capability.Limitations()));
            }
            return(union.toArray(new IndexLimitation[union.Count]));
        }
Ejemplo n.º 30
0
 public OR(SemanticContext a, SemanticContext b)
 {
     _operands = new HashSet <object>();
     if (a is OR)
     {
         _operands.addAll(((OR)a)._operands);
     }
     else if (a != null)
     {
         _operands.Add(a);
     }
     if (b is OR)
     {
         _operands.addAll(((OR)b)._operands);
     }
     else if (b != null)
     {
         _operands.Add(b);
     }
 }
Ejemplo n.º 31
0
        /// <summary>
        /// All the externally published sets are derived from the committed and appended sets.
        /// </summary>
        private void UpdateMemberSets()
        {
            _votingMembers = Collections.unmodifiableSet(_state.Latest);

            HashSet <MemberId> newReplicationMembers = new HashSet <MemberId>(_votingMembers);

            newReplicationMembers.addAll(_additionalReplicationMembers);

            _replicationMembers = Collections.unmodifiableSet(newReplicationMembers);
            _listeners.forEach(RaftMembership_Listener.onMembershipChanged);
        }
Ejemplo n.º 32
0
        protected internal virtual ISet <string> collectOutputNames(DmnDecisionResult decisionResult)
        {
            ISet <string> outputNames = new HashSet <string>();

            foreach (IDictionary <string, object> entryMap in decisionResult.ResultList)
            {
                outputNames.addAll(entryMap.Keys);
            }

            return(outputNames);
        }
Ejemplo n.º 33
0
		/// <summary>
		/// 第一次扫描<br/>
		/// 在Spring内部的Bean定义初始化后执行,这样是最高优先级的
		/// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) throws org.springframework.beans.BeansException
		public override void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry)
		{

			// 为了做兼容
			DisconfCenterHostFilesStore.Instance.addJustHostFileSet(fileList);

			IList<string> scanPackList = StringUtil.parseStringToStringList(scanPackage, SCAN_SPLIT_TOKEN);
			// unique
			ISet<string> hs = new HashSet<string>();
			hs.addAll(scanPackList);
			scanPackList.Clear();
			((List<string>)scanPackList).AddRange(hs);

			// 进行扫描
			DisconfMgr.Instance.ApplicationContext = applicationContext;
			DisconfMgr.Instance.firstScan(scanPackList);

			// register java bean
			registerAspect(registry);
		}
Ejemplo n.º 34
0
		/// <summary>
		/// 获取一个类的所有字段
		/// </summary>
		/// <param name="entityClass">
		/// 
		/// @return </param>
		public static ISet<Field> getAllFiled(Type entityClass)
		{

			// 获取本类的所有字段
			ISet<Field> fs = new HashSet<Field>();
			foreach (Field f in entityClass.GetFields())
			{
				fs.Add(f);
			}
			foreach (Field f in entityClass.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
			{
				fs.Add(f);
			}

			// 递归获取父类的所有字段
			Type superClass = entityClass.BaseType;
			if (!superClass.Equals(typeof(object)))
			{
				ISet<Field> superFileds = getAllFiled(superClass);
				fs.addAll(superFileds);
			}

			return fs;
		}
Ejemplo n.º 35
0
        protected virtual void MinimizeRuleSetCore( HashSet<string> ruleDefs,
                                     CompositeGrammarTree p )
        {
            HashSet<string> localRuleDefs = new HashSet<string>();
            HashSet<string> overrides = new HashSet<string>();
            // compute set of non-overridden rules for this delegate
            foreach ( Rule r in p.grammar.Rules )
            {
                if ( !ruleDefs.Contains( r.Name ) )
                {
                    localRuleDefs.Add( r.Name );
                }
                else if ( !r.Name.Equals( Grammar.ArtificialTokensRuleName ) )
                {
                    // record any overridden rule 'cept tokens rule
                    overrides.Add( r.Name );
                }
            }
            //System.Console.Out.WriteLine( "rule defs for " + p.grammar.name + ": " + localRuleDefs );
            //System.Console.Out.WriteLine( "overridden rule for " + p.grammar.name + ": " + overrides );
            p.grammar.overriddenRules = overrides;

            // make set of all rules defined thus far walking delegation tree.
            // the same rule in two delegates resolves in favor of first found
            // in tree therefore second must not be included
            ruleDefs.addAll( localRuleDefs );

            // pass larger set of defined rules to delegates
            if ( p.children != null )
            {
                foreach ( CompositeGrammarTree @delegate in p.children )
                {
                    MinimizeRuleSetCore( ruleDefs, @delegate );
                }
            }
        }
Ejemplo n.º 36
0
        public virtual HashSet<Rule> _minimizeRuleSet( CompositeGrammarTree p )
        {
            var refs = new HashSet<Rule>();
            foreach ( GrammarAST refAST in p.grammar.ruleRefs )
            {
                System.Console.Out.WriteLine( "ref " + refAST.Text + ": " + refAST.NFAStartState +
                                   " enclosing rule: " + refAST.NFAStartState.enclosingRule +
                                   " invoking rule: " + ( (NFAState)refAST.NFAStartState.transition[0].target ).enclosingRule );
                refs.Add( ( (NFAState)refAST.NFAStartState.transition[0].target ).enclosingRule );
            }

            if ( p.children != null )
            {
                foreach ( CompositeGrammarTree @delegate in p.children )
                {
                    var delegateRuleRefs = _minimizeRuleSet( @delegate );
                    refs.addAll( delegateRuleRefs );
                }
            }

            return refs;
        }
Ejemplo n.º 37
0
 public OR( SemanticContext a, SemanticContext b )
 {
     _operands = new HashSet<object>();
     if ( a is OR )
     {
         _operands.addAll( ( (OR)a )._operands );
     }
     else if ( a != null )
     {
         _operands.Add( a );
     }
     if ( b is OR )
     {
         _operands.addAll( ( (OR)b )._operands );
     }
     else if ( b != null )
     {
         _operands.Add( b );
     }
 }
Ejemplo n.º 38
0
		/// <summary>
		/// 获取一个类的所有方法
		/// </summary>
		/// <param name="entityClass">
		/// 
		/// @return </param>
		public static ISet<Method> getAllMethod(Type entityClass)
		{

			// 获取本类的所有的方法
			ISet<Method> ms = new HashSet<Method>();
			foreach (Method m in entityClass.GetMethods())
			{
				ms.Add(m);
			}
			foreach (Method m in entityClass.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
			{
				ms.Add(m);
			}

			// 递归获取父类的所有方法
			Type superClass = entityClass.BaseType;
			if (!superClass.Equals(typeof(object)))
			{
				ISet<Method> superFields = getAllMethod(superClass);
				ms.addAll(superFields);
			}

			return ms;
		}
Ejemplo n.º 39
0
		/// <summary>
		/// Determine which genotype fields are in use in the genotypes in VC </summary>
		/// <param name="vc"> </param>
		/// <returns> an ordered list of genotype fields in use in VC.  If vc has genotypes this will always include GT first </returns>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public static List<String> calcVCFGenotypeKeys(final VariantContext vc, final VCFHeader header)
		public static IList<string> calcVCFGenotypeKeys(VariantContext vc, VCFHeader header)
		{
			Set<string> keys = new HashSet<string>();

			bool sawGoodGT = false;
			bool sawGoodQual = false;
			bool sawGenotypeFilter = false;
			bool sawDP = false;
			bool sawAD = false;
			bool sawPL = false;
			foreach (Genotype g in vc.Genotypes)
			{
				keys.addAll(g.ExtendedAttributes.Keys);
				if (g.Available)
				{
					sawGoodGT = true;
				}
				if (g.hasGQ())
				{
					sawGoodQual = true;
				}
				if (g.hasDP())
				{
					sawDP = true;
				}
				if (g.hasAD())
				{
					sawAD = true;
				}
				if (g.hasPL())
				{
					sawPL = true;
				}
				if (g.Filtered)
				{
					sawGenotypeFilter = true;
				}
			}

			if (sawGoodQual)
			{
				keys.add(VCFConstants.GENOTYPE_QUALITY_KEY);
			}
			if (sawDP)
			{
				keys.add(VCFConstants.DEPTH_KEY);
			}
			if (sawAD)
			{
				keys.add(VCFConstants.GENOTYPE_ALLELE_DEPTHS);
			}
			if (sawPL)
			{
				keys.add(VCFConstants.GENOTYPE_PL_KEY);
			}
			if (sawGenotypeFilter)
			{
				keys.add(VCFConstants.GENOTYPE_FILTER_KEY);
			}

			IList<string> sortedList = ParsingUtils.sortList(new List<string>(keys));

			// make sure the GT is first
			if (sawGoodGT)
			{
				IList<string> newList = new List<string>(sortedList.Count + 1);
				newList.Add(VCFConstants.GENOTYPE_KEY);
				newList.AddRange(sortedList);
				sortedList = newList;
			}

			if (sortedList.Count == 0 && header.hasGenotypingData())
			{
				// this needs to be done in case all samples are no-calls
				return Collections.singletonList(VCFConstants.GENOTYPE_KEY);
			}
			else
			{
				return sortedList;
			}
		}
Ejemplo n.º 40
0
 public Set<Rule> GetImportedRulesSensitiveToOverriddenRulesDueToLOOK()
 {
     Set<String> diffFIRSTs = getOverriddenRulesWithDifferentFIRST();
     Set<Rule> rules = new HashSet();
     for (Iterator it = diffFIRSTs.iterator(); it.hasNext();) {
         String r = (String) it.next();
         for (int i = 0; i < delegates.size(); i++) {
             Grammar g = delegates.get(i);
             Set<Rule> callers = g.ruleSensitivity.get(r);
             // somebody invokes rule whose FIRST changed in subgrammar?
             if ( callers!=null ) {
                 rules.addAll(callers);
                 //[email protected](g.name+" rules "+callers+" sensitive to "+r+"; dup 'em");
             }
         }
     }
     return rules;
 }
Ejemplo n.º 41
0
 protected HashSet<string> ruleNames2( System.Collections.IEnumerable rules )
 {
     HashSet<string> x = new HashSet<string>();
     foreach ( System.Collections.IEnumerable s in rules )
     {
         x.addAll( ruleNames( s ) );
     }
     return x;
 }
Ejemplo n.º 42
0
        /// <summary>
        /// Test the static #copy() function with a JDK <seealso cref="Set"/> as a source
        /// </summary>
        public virtual void testCopyJDKSet()
        {
            ISet<string> set = new HashSet<string>();

            IList<string> stopwords = TEST_STOP_WORDS;
            IList<string> stopwordsUpper = new List<string>();
            foreach (string @string in stopwords)
            {
              stopwordsUpper.Add(@string.ToUpper(Locale.ROOT));
            }
            set.addAll(TEST_STOP_WORDS);

            CharArraySet copy = CharArraySet.copy(TEST_VERSION_CURRENT, set);

            assertEquals(set.Count, copy.size());
            assertEquals(set.Count, copy.size());

            assertTrue(copy.containsAll(stopwords));
            foreach (string @string in stopwordsUpper)
            {
              assertFalse(copy.contains(@string));
            }

            IList<string> newWords = new List<string>();
            foreach (string @string in stopwords)
            {
              newWords.Add(@string + "_1");
            }
            copy.addAll(newWords);

            assertTrue(copy.containsAll(stopwords));
            assertTrue(copy.containsAll(newWords));
            // new added terms are not in the source set
            foreach (string @string in newWords)
            {
              assertFalse(set.Contains(@string));
            }
        }