/** * 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; }
/// <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); }
/// <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; }
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; }
/// <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; }
/// <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; } }
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; }
/// <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)); } }
/** * 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; }
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; }
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 ); } }
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 ); } } }
/// <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); } }