java.util.Set

Here are the examples of the java api class java.util.Set taken from open source projects.

1. SchemaCompilerUtil#compile()

Project: airavata
Source File: SchemaCompilerUtil.java
View license
public static void compile(String[] args) {
    if (args.length == 0) {
        return;
    }
    Set flags = new HashSet();
    flags.add("h");
    flags.add("help");
    flags.add("usage");
    flags.add("license");
    flags.add("quiet");
    flags.add("verbose");
    flags.add("version");
    flags.add("dl");
    flags.add("noupa");
    flags.add("nopvr");
    flags.add("noann");
    flags.add("novdoc");
    flags.add("noext");
    flags.add("srconly");
    flags.add("debug");
    Set opts = new HashSet();
    opts.add("out");
    opts.add("name");
    opts.add("src");
    opts.add("d");
    opts.add("cp");
    opts.add("compiler");
    opts.add("javasource");
    // deprecated
    opts.add("jar");
    opts.add("ms");
    opts.add("mx");
    opts.add("repackage");
    opts.add("schemaCodePrinter");
    opts.add("extension");
    opts.add("extensionParms");
    opts.add("allowmdef");
    opts.add("catalog");
    CommandLine cl = new CommandLine(args, flags, opts);
    String[] badopts = cl.getBadOpts();
    if (badopts.length > 0) {
        for (int i = 0; i < badopts.length; i++) System.out.println("Unrecognized option: " + badopts[i]);
        return;
    }
    boolean verbose = (cl.getOpt("verbose") != null);
    boolean quiet = (cl.getOpt("quiet") != null);
    if (verbose)
        quiet = false;
    String outputfilename = cl.getOpt("out");
    String repackage = cl.getOpt("repackage");
    cl.getOpt("schemaCodePrinter");
    SchemaCodePrinter codePrinter = null;
    String name = cl.getOpt("name");
    boolean download = (cl.getOpt("dl") != null);
    boolean noUpa = (cl.getOpt("noupa") != null);
    boolean noPvr = (cl.getOpt("nopvr") != null);
    boolean noAnn = (cl.getOpt("noann") != null);
    boolean noVDoc = (cl.getOpt("novdoc") != null);
    boolean noExt = (cl.getOpt("noext") != null);
    boolean nojavac = (cl.getOpt("srconly") != null);
    boolean debug = (cl.getOpt("debug") != null);
    String allowmdef = cl.getOpt("allowmdef");
    Set mdefNamespaces = (allowmdef == null ? Collections.EMPTY_SET : new HashSet(Arrays.asList(XmlListImpl.split_list(allowmdef))));
    List extensions = new ArrayList();
    String classesdir = cl.getOpt("d");
    File classes = null;
    if (classesdir != null)
        classes = new File(classesdir);
    String srcdir = cl.getOpt("src");
    File src = null;
    if (srcdir != null)
        src = new File(srcdir);
    if (nojavac && srcdir == null && classes != null)
        src = classes;
    // create temp directory
    File tempdir = null;
    if (src == null || classes == null) {
        throw new WorkflowRuntimeException("Code gen src directory or classes directory is null");
    }
    File jarfile = null;
    if (outputfilename == null && classes == null && !nojavac)
        outputfilename = "xmltypes.jar";
    if (outputfilename != null)
        jarfile = new File(outputfilename);
    if (src == null)
        src = IOUtil.createDir(tempdir, "src");
    if (classes == null)
        classes = IOUtil.createDir(tempdir, "classes");
    File[] classpath = null;
    String cpString = cl.getOpt("cp");
    if (cpString != null) {
        String[] cpparts = cpString.split(File.pathSeparator);
        List cpList = new ArrayList();
        for (int i = 0; i < cpparts.length; i++) cpList.add(new File(cpparts[i]));
        classpath = (File[]) cpList.toArray(new File[cpList.size()]);
    } else {
        classpath = CodeGenUtil.systemClasspath();
    }
    String javasource = cl.getOpt("javasource");
    String compiler = cl.getOpt("compiler");
    String jar = cl.getOpt("jar");
    if (verbose && jar != null)
        System.out.println("The 'jar' option is no longer supported.");
    String memoryInitialSize = cl.getOpt("ms");
    String memoryMaximumSize = cl.getOpt("mx");
    File[] xsdFiles = cl.filesEndingWith(".xsd");
    File[] wsdlFiles = cl.filesEndingWith(".wsdl");
    File[] javaFiles = cl.filesEndingWith(".java");
    File[] configFiles = cl.filesEndingWith(".xsdconfig");
    URL[] urlFiles = cl.getURLs();
    if (xsdFiles.length + wsdlFiles.length + urlFiles.length == 0) {
        System.out.println("Could not find any xsd or wsdl files to process.");
        return;
    }
    File baseDir = cl.getBaseDir();
    URI baseURI = baseDir == null ? null : baseDir.toURI();
    XmlErrorPrinter err = new XmlErrorPrinter(verbose, baseURI);
    String catString = cl.getOpt("catalog");
    Parameters params = new Parameters();
    params.setBaseDir(baseDir);
    params.setXsdFiles(xsdFiles);
    params.setWsdlFiles(wsdlFiles);
    params.setJavaFiles(javaFiles);
    params.setConfigFiles(configFiles);
    params.setUrlFiles(urlFiles);
    params.setClasspath(classpath);
    params.setOutputJar(jarfile);
    params.setName(name);
    params.setSrcDir(src);
    params.setClassesDir(classes);
    params.setCompiler(compiler);
    params.setJavaSource(javasource);
    params.setMemoryInitialSize(memoryInitialSize);
    params.setMemoryMaximumSize(memoryMaximumSize);
    params.setNojavac(nojavac);
    params.setQuiet(quiet);
    params.setVerbose(verbose);
    params.setDownload(download);
    params.setNoUpa(noUpa);
    params.setNoPvr(noPvr);
    params.setNoAnn(noAnn);
    params.setNoVDoc(noVDoc);
    params.setNoExt(noExt);
    params.setDebug(debug);
    params.setErrorListener(err);
    params.setRepackage(repackage);
    params.setExtensions(extensions);
    params.setMdefNamespaces(mdefNamespaces);
    params.setCatalogFile(catString);
    params.setSchemaCodePrinter(codePrinter);
    compile(params);
}

2. PerBtwnAllCollectionsT#printSets()

View license
/**
	 * ??Set?Add??:???????
	 */
@SuppressWarnings("rawtypes")
private static void printSets() {
    Set h1 = new HashSet<String>();
    h1.add("List");
    h1.add("Set");
    h1.add("Queue");
    h1.add("Map");
    System.out.println("HashSet Elements:");
    System.out.print("\t" + h1 + "\n");
    Set t1 = new TreeSet<String>();
    t1.add("List");
    t1.add("Set");
    t1.add("Queue");
    t1.add("Map");
    System.out.println("TreeSet Elements:");
    System.out.print("\t" + t1 + "\n");
}

3. UnitThrowAnalysisTest#testJArrayRef()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Test
public void testJArrayRef() {
    ArrayRef arrayRef = Jimple.v().newArrayRef(Jimple.v().newLocal("local1", ArrayType.v(RefType.v("java.lang.Object"), 1)), IntConstant.v(0));
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    expectedRep.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(arrayRef)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
    expectedCatch.add(utility.INDEX_OUT_OF_BOUNDS_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(arrayRef)));
}

4. UnitThrowAnalysisTest#testGArrayRef()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Test
public void testGArrayRef() {
    ArrayRef arrayRef = Grimp.v().newArrayRef(Grimp.v().newLocal("local1", ArrayType.v(RefType.v("java.lang.Object"), 1)), IntConstant.v(0));
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    expectedRep.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(arrayRef)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
    expectedCatch.add(utility.INDEX_OUT_OF_BOUNDS_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(arrayRef)));
}

5. ZeroConfPlugin#registerServiceListenersForAppenders()

Project: chainsaw
Source File: ZeroConfPlugin.java
View license
private void registerServiceListenersForAppenders() {
    Set serviceNames = new HashSet();
    serviceNames.add(MULTICAST_APPENDER_SERVICE_NAME);
    serviceNames.add(SOCKET_APPENDER_SERVICE_NAME);
    serviceNames.add(SOCKETHUB_APPENDER_SERVICE_NAME);
    serviceNames.add(UDP_APPENDER_SERVICE_NAME);
    serviceNames.add(XML_SOCKET_APPENDER_SERVICE_NAME);
    serviceNames.add(TCP_APPENDER_SERVICE_NAME);
    serviceNames.add(NEW_UDP_APPENDER_SERVICE_NAME);
    for (Iterator iter = serviceNames.iterator(); iter.hasNext(); ) {
        String serviceName = iter.next().toString();
        jmDNS.addServiceListener(serviceName, new ZeroConfServiceListener());
        jmDNS.addServiceListener(serviceName, discoveredDevices);
    }
//now add each appender constant
}

6. JXPathTestCase#set()

Project: commons-jxpath
Source File: JXPathTestCase.java
View license
protected static Set set(Object o1, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7) {
    Set list = new HashSet();
    list.add(o1);
    list.add(o2);
    list.add(o3);
    list.add(o4);
    list.add(o5);
    list.add(o6);
    list.add(o7);
    return list;
}

7. UnitThrowAnalysisTest#testJExitMonitorStmt()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Test
public void testJExitMonitorStmt() {
    Stmt s = Jimple.v().newExitMonitorStmt(StringConstant.v("test"));
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}

8. UnitThrowAnalysisTest#testGExitMonitorStmt()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Test
public void testGExitMonitorStmt() {
    Stmt s = Grimp.v().newExitMonitorStmt(StringConstant.v("test"));
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}

9. JXPathTestCase#set()

Project: commons-jxpath
Source File: JXPathTestCase.java
View license
protected static Set set(Object o1, Object o2, Object o3, Object o4, Object o5, Object o6) {
    Set list = new HashSet();
    list.add(o1);
    list.add(o2);
    list.add(o3);
    list.add(o4);
    list.add(o5);
    list.add(o6);
    return list;
}

10. ClientDeployableTest#testLoadClient()

Project: geronimo
Source File: ClientDeployableTest.java
View license
public void testLoadClient() throws Exception {
    URL resource = classLoader.getResource("deployables/app-client1.jar");
    ClientDeployable deployable = new ClientDeployable(resource);
    assertEquals(ModuleType.CAR, deployable.getType());
    Set entrySet = new HashSet(Collections.list(deployable.entries()));
    Set resultSet = new HashSet();
    resultSet.add("META-INF/");
    resultSet.add("META-INF/MANIFEST.MF");
    resultSet.add("META-INF/application-client.xml");
    resultSet.add("Main.java");
    resultSet.add("Main.class");
    assertEquals(resultSet, entrySet);
    InputStream entry = deployable.getEntry("META-INF/application-client.xml");
    assertNotNull(entry);
    entry.close();
    Class main = deployable.getClassFromScope("Main");
    assertEquals("Main", main.getName());
    DDBeanRoot root = deployable.getDDBeanRoot();
    assertNotNull(root);
    assertEquals(ModuleType.CAR, root.getType());
    assertEquals(deployable, root.getDeployableObject());
}

11. HashSetT#main()

View license
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) {
    Set h1 = new HashSet<String>();
    h1.add("List");
    h1.add(new String("List"));
    h1.add("List");
    h1.add("Set");
    h1.add("Queue");
    h1.add("Map");
    // ????
    System.out.println("HashSet Elements:");
    System.out.print("\t" + h1 + "\n");
}

12. CrossTransformTest#makeFeatureVector()

Project: aerosolve
Source File: CrossTransformTest.java
View license
public FeatureVector makeFeatureVector() {
    HashMap stringFeatures = new HashMap<String, Set<String>>();
    Set list = new HashSet<String>();
    list.add("aaa");
    list.add("bbb");
    stringFeatures.put("feature1", list);
    Set list2 = new HashSet<String>();
    list2.add("11");
    list2.add("22");
    stringFeatures.put("feature2", list2);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    return featureVector;
}

13. UnitThrowAnalysisTest#testJEnterMonitorStmt()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Test
public void testJEnterMonitorStmt() {
    Stmt s = Jimple.v().newEnterMonitorStmt(StringConstant.v("test"));
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}

14. UnitThrowAnalysisTest#testGEnterMonitorStmt()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Test
public void testGEnterMonitorStmt() {
    Stmt s = Grimp.v().newEnterMonitorStmt(StringConstant.v("test"));
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}

15. UnitThrowAnalysisTest#testJReturnStmt()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Ignore("Fails")
@Test
public void testJReturnStmt() {
    Stmt s = Jimple.v().newReturnStmt(IntConstant.v(1));
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}

16. UnitThrowAnalysisTest#testGReturnStmt()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Ignore("Fails")
@Test
public void testGReturnStmt() {
    Stmt s = Grimp.v().newReturnStmt(IntConstant.v(1));
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}

17. UnitThrowAnalysisTest#testJReturnVoidStmt()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Ignore("Fails")
@Test
public void testJReturnVoidStmt() {
    Stmt s = Jimple.v().newReturnVoidStmt();
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}

18. UnitThrowAnalysisTest#testGReturnVoidStmt()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Ignore("Fails")
@Test
public void testGReturnVoidStmt() {
    Stmt s = Grimp.v().newReturnVoidStmt();
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}

19. UnitThrowAnalysisTest#testGInstanceFieldRef()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Test
public void testGInstanceFieldRef() {
    Local local = Grimp.v().newLocal("local", utility.INCOMPATIBLE_CLASS_CHANGE_ERROR);
    Set expectedRep = new ExceptionHashSet(utility.VM_AND_RESOLVE_FIELD_ERRORS_REP);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    Set expectedCatch = new ExceptionHashSet(utility.VM_AND_RESOLVE_FIELD_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    Value v = Grimp.v().newInstanceFieldRef(local, Scene.v().makeFieldRef(utility.THROWABLE.getSootClass(), "detailMessage", RefType.v("java.lang.String"), false));
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(v)));
}

20. UnitThrowAnalysisTest#testBArrayLengthInst()

Project: JAADAS
Source File: UnitThrowAnalysisTest.java
View license
@Test
public void testBArrayLengthInst() {
    soot.baf.ArrayLengthInst i = soot.baf.Baf.v().newArrayLengthInst();
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(i)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(i)));
}

21. HashSetsCopyT#main()

View license
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) {
    Set s1 = new HashSet<String>();
    s1.add("List");
    s1.add("Queue");
    s1.add("Set");
    s1.add("Map");
    System.out.println("HashSet Elements:");
    System.out.print("\t" + s1 + "\n");
    Set s2 = copy(s1);
    System.out.println("HashSet Elements After Copy:");
    System.out.print("\t" + s2 + "\n");
}

22. AssertTest#setAssertEquals()

Project: testng
Source File: AssertTest.java
View license
@Test
public void setAssertEquals() {
    Set expected = Sets.newHashSet();
    Set actual = Sets.newHashSet();
    expected.add(1);
    expected.add("a");
    actual.add("a");
    actual.add(1);
    Assert.assertEquals(actual, expected);
}

23. TransducerGraph#getArc()

Project: CoreNLP
Source File: TransducerGraph.java
View license
/**
   * Slow implementation.
   */
public Arc getArc(Object source, Object target) {
    Set arcsFromSource = arcsBySource.get(source);
    Set arcsToTarget = arcsByTarget.get(target);
    Set result = Generics.newHashSet();
    result.addAll(arcsFromSource);
    // intersection
    result.retainAll(arcsToTarget);
    if (result.size() < 1) {
        return null;
    }
    if (result.size() > 1) {
        throw new RuntimeException("Problem in TransducerGraph data structures.");
    }
    // get the only member
    Iterator iterator = result.iterator();
    return (Arc) iterator.next();
}

24. ContextManagerTest#testGetCallerPrincipal()

Project: geronimo
Source File: ContextManagerTest.java
View license
public void testGetCallerPrincipal() throws Exception {
    Subject subject = new Subject();
    GeronimoUserPrincipal userPrincipal = new GeronimoUserPrincipal("foo");
    RealmPrincipal realmPrincipal = new RealmPrincipal("realm", "domain", userPrincipal);
    PrimaryRealmPrincipal primaryRealmPrincipal = new PrimaryRealmPrincipal("realm", "domain", userPrincipal);
    GeronimoGroupPrincipal groupPrincipal = new GeronimoGroupPrincipal("bar");
    Set principals = subject.getPrincipals();
    principals.add(userPrincipal);
    principals.add(realmPrincipal);
    principals.add(primaryRealmPrincipal);
    principals.add(groupPrincipal);
    ContextManager.registerSubject(subject);
    Principal principal = ContextManager.getCurrentPrincipal(subject);
    assertSame("Expected GeronimoCallerPrincipal", userPrincipal, principal);
}

25. AbstractXMLReaderTest#testExposesAttributesKeysAsIterator()

Project: xstream
Source File: AbstractXMLReaderTest.java
View license
public void testExposesAttributesKeysAsIterator() throws Exception {
    HierarchicalStreamReader xmlReader = createReader("<node hello='world' a='b' c='d'><empty/></node>");
    Set expected = new HashSet();
    expected.add("hello");
    expected.add("a");
    expected.add("c");
    Set actual = new HashSet();
    Iterator iterator;
    iterator = xmlReader.getAttributeNames();
    while (iterator.hasNext()) {
        actual.add(iterator.next());
    }
    assertEquals(expected, actual);
    // again, to check iteration is repeatable 
    iterator = xmlReader.getAttributeNames();
    while (iterator.hasNext()) {
        actual.add(iterator.next());
    }
    assertEquals(expected, actual);
}

26. ZipsTest#testIterateAndBreak()

Project: zt-zip
Source File: ZipsTest.java
View license
public void testIterateAndBreak() {
    File src = new File("src/test/resources/demo.zip");
    final Set files = new HashSet();
    files.add("foo.txt");
    files.add("bar.txt");
    files.add("foo1.txt");
    files.add("foo2.txt");
    Zips.get(src).iterate(new ZipEntryCallback() {

        public void process(InputStream in, ZipEntry zipEntry) throws IOException {
            files.remove(zipEntry.getName());
            throw new ZipBreakException();
        }
    });
    assertEquals(3, files.size());
}

27. ZipUtilTest#testIterate()

Project: zt-zip
Source File: ZipUtilTest.java
View license
public void testIterate() {
    File src = file("demo.zip");
    final Set files = new HashSet();
    files.add("foo.txt");
    files.add("bar.txt");
    files.add("foo1.txt");
    files.add("foo2.txt");
    ZipUtil.iterate(src, new ZipInfoCallback() {

        public void process(ZipEntry zipEntry) throws IOException {
            files.remove(zipEntry.getName());
        }
    });
    assertEquals(0, files.size());
}

28. ZipUtilTest#testIterateGivenEntriesZipInfoCallback()

Project: zt-zip
Source File: ZipUtilTest.java
View license
public void testIterateGivenEntriesZipInfoCallback() {
    File src = file("demo.zip");
    final Set files = new HashSet();
    files.add("foo.txt");
    files.add("bar.txt");
    files.add("foo1.txt");
    files.add("foo2.txt");
    ZipUtil.iterate(src, new String[] { "foo.txt", "foo1.txt", "foo2.txt" }, new ZipInfoCallback() {

        public void process(ZipEntry zipEntry) throws IOException {
            files.remove(zipEntry.getName());
        }
    });
    assertEquals(1, files.size());
    assertTrue("Wrong entry hasn't been iterated", files.contains("bar.txt"));
}

29. ZipUtilTest#testIterateGivenEntriesZipEntryCallback()

Project: zt-zip
Source File: ZipUtilTest.java
View license
public void testIterateGivenEntriesZipEntryCallback() {
    File src = file("demo.zip");
    final Set files = new HashSet();
    files.add("foo.txt");
    files.add("bar.txt");
    files.add("foo1.txt");
    files.add("foo2.txt");
    ZipUtil.iterate(src, new String[] { "foo.txt", "foo1.txt", "foo2.txt" }, new ZipEntryCallback() {

        public void process(InputStream in, ZipEntry zipEntry) throws IOException {
            files.remove(zipEntry.getName());
        }
    });
    assertEquals(1, files.size());
    assertTrue("Wrong entry hasn't been iterated", files.contains("bar.txt"));
}

30. ZipUtilTest#testIterateGivenEntriesFromStream()

Project: zt-zip
Source File: ZipUtilTest.java
View license
public void testIterateGivenEntriesFromStream() throws IOException {
    File src = file("demo.zip");
    final Set files = new HashSet();
    files.add("foo.txt");
    files.add("bar.txt");
    files.add("foo1.txt");
    files.add("foo2.txt");
    FileInputStream inputStream = null;
    try {
        inputStream = new FileInputStream(src);
        ZipUtil.iterate(inputStream, new String[] { "foo.txt", "foo1.txt", "foo2.txt" }, new ZipEntryCallback() {

            public void process(InputStream in, ZipEntry zipEntry) throws IOException {
                files.remove(zipEntry.getName());
            }
        });
        assertEquals(1, files.size());
        assertTrue("Wrong entry hasn't been iterated", files.contains("bar.txt"));
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
    }
}

31. ZipUtilTest#testIterateAndBreak()

Project: zt-zip
Source File: ZipUtilTest.java
View license
public void testIterateAndBreak() {
    File src = file("demo.zip");
    final Set files = new HashSet();
    files.add("foo.txt");
    files.add("bar.txt");
    files.add("foo1.txt");
    files.add("foo2.txt");
    ZipUtil.iterate(src, new ZipEntryCallback() {

        public void process(InputStream in, ZipEntry zipEntry) throws IOException {
            files.remove(zipEntry.getName());
            throw new ZipBreakException();
        }
    });
    assertEquals(3, files.size());
}

32. LinearModelTest#makeFeatureVector()

Project: aerosolve
Source File: LinearModelTest.java
View license
public FeatureVector makeFeatureVector() {
    Set list = new HashSet<String>();
    list.add("aaa");
    list.add("bbb");
    // add a feature that is missing in the model
    list.add("ccc");
    HashMap stringFeatures = new HashMap<String, ArrayList<String>>();
    stringFeatures.put("string_feature", list);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    return featureVector;
}

33. DateDiffTransformTest#makeFeatureVector()

View license
public FeatureVector makeFeatureVector() {
    Map<String, Set<String>> stringFeatures = new HashMap<>();
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    Set endDates = new HashSet<String>();
    Set startDates = new HashSet<String>();
    endDates.add("2009-03-01");
    startDates.add("2009-02-27");
    stringFeatures.put("endDates", endDates);
    stringFeatures.put("startDates", startDates);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    featureVector.setFloatFeatures(floatFeatures);
    return featureVector;
}

34. StringCrossFloatTransformTest#makeFeatureVector()

View license
public FeatureVector makeFeatureVector() {
    Map<String, Set<String>> stringFeatures = new HashMap<>();
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    Set list = new HashSet<String>();
    list.add("aaa");
    list.add("b:bb");
    list.add("c:cc");
    stringFeatures.put("strFeature1", list);
    Map<String, Double> map = new HashMap<>();
    map.put("lat", 37.7);
    map.put("long", 40.0);
    floatFeatures.put("loc", map);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    featureVector.setFloatFeatures(floatFeatures);
    return featureVector;
}

35. X509StoreLDAPAttrCerts#engineGetMatches()

Project: bc-java
Source File: X509StoreLDAPAttrCerts.java
View license
/**
     * Returns a collection of matching attribute certificates from the LDAP
     * location.
     * <p>
     * The selector must be a of type
     * <code>X509AttributeCertStoreSelector</code>. If it is not an empty
     * collection is returned.
     * </p>
     * <p>
     * The subject and the serial number should be reasonable criterias for a
     * selector.
     * </p>
     * @param selector The selector to use for finding.
     * @return A collection with the matches.
     * @throws StoreException if an exception occurs while searching.
     */
public Collection engineGetMatches(Selector selector) throws StoreException {
    if (!(selector instanceof X509AttributeCertStoreSelector)) {
        return Collections.EMPTY_SET;
    }
    X509AttributeCertStoreSelector xselector = (X509AttributeCertStoreSelector) selector;
    Set set = new HashSet();
    set.addAll(helper.getAACertificates(xselector));
    set.addAll(helper.getAttributeCertificateAttributes(xselector));
    set.addAll(helper.getAttributeDescriptorCertificates(xselector));
    return set;
}

36. ConcurrentHashMap8Test#testEquals()

View license
/**
     * KeySets with equal elements are equal
     */
public void testEquals() {
    Set a = populatedSet(3);
    Set b = populatedSet(3);
    assertTrue(a.equals(b));
    assertTrue(b.equals(a));
    assertEquals(a.hashCode(), b.hashCode());
    a.add(m1);
    assertFalse(a.equals(b));
    assertFalse(b.equals(a));
    b.add(m1);
    assertTrue(a.equals(b));
    assertTrue(b.equals(a));
    assertEquals(a.hashCode(), b.hashCode());
}

37. BasicDependencyManager#addDependency()

View license
/**
     * Declares a dependency from a child to a parent.
     *
     * @param child the dependent component
     * @param parent the component the child is depending on
     */
public synchronized void addDependency(ObjectName child, ObjectName parent) {
    Set parents = (Set) childToParentMap.get(child);
    if (parents == null) {
        parents = new HashSet();
        childToParentMap.put(child, parents);
    }
    parents.add(parent);
    Set children = (Set) parentToChildMap.get(parent);
    if (children == null) {
        children = new HashSet();
        parentToChildMap.put(parent, children);
    }
    children.add(child);
}

38. DefaultObjectWrapperTest#testLegacyNonListCollectionWrapping()

View license
@Test
public void testLegacyNonListCollectionWrapping() throws TemplateModelException {
    Set set = new TreeSet();
    set.add("a");
    set.add("b");
    set.add("c");
    TemplateSequenceModel seq = (TemplateSequenceModel) OW22.wrap(set);
    assertTrue(seq instanceof SimpleSequence);
    assertEquals(3, seq.size());
    assertEquals("a", OW22.unwrap(seq.get(0)));
    assertEquals("b", OW22.unwrap(seq.get(1)));
    assertEquals("c", OW22.unwrap(seq.get(2)));
}

39. ConcurrentHashMap8Test#testKeySetAddRemove()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * keySet.add adds the key with the established value to the map;
     * remove removes it.
     */
public void testKeySetAddRemove() {
    ConcurrentHashMap map = map5();
    Set set1 = map.keySet();
    Set set2 = map.keySet(true);
    set2.add(six);
    assertTrue(((ConcurrentHashMap.KeySetView) set2).getMap() == map);
    assertTrue(((ConcurrentHashMap.KeySetView) set1).getMap() == map);
    assertEquals(set2.size(), map.size());
    assertEquals(set1.size(), map.size());
    assertTrue((Boolean) map.get(six));
    assertTrue(set1.contains(six));
    assertTrue(set2.contains(six));
    set2.remove(six);
    assertNull(map.get(six));
    assertFalse(set1.contains(six));
    assertFalse(set2.contains(six));
}

40. ConcurrentHashMap8Test#testEquals()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * KeySets with equal elements are equal
     */
public void testEquals() {
    Set a = populatedSet(3);
    Set b = populatedSet(3);
    assertTrue(a.equals(b));
    assertTrue(b.equals(a));
    assertEquals(a.hashCode(), b.hashCode());
    a.add(m1);
    assertFalse(a.equals(b));
    assertFalse(b.equals(a));
    b.add(m1);
    assertTrue(a.equals(b));
    assertTrue(b.equals(a));
    assertEquals(a.hashCode(), b.hashCode());
}

41. NarMojo#filterMarkedDependencies()

Project: nifi-maven
Source File: NarMojo.java
View license
protected DependencyStatusSets filterMarkedDependencies(Set artifacts) throws MojoExecutionException {
    // remove files that have markers already
    FilterArtifacts filter = new FilterArtifacts();
    filter.clearFilters();
    filter.addFilter(getMarkedArtifactFilter());
    Set unMarkedArtifacts;
    try {
        unMarkedArtifacts = filter.filter(artifacts);
    } catch (ArtifactFilterException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
    // calculate the skipped artifacts
    Set skippedArtifacts = new HashSet();
    skippedArtifacts.addAll(artifacts);
    skippedArtifacts.removeAll(unMarkedArtifacts);
    return new DependencyStatusSets(unMarkedArtifacts, null, skippedArtifacts);
}

42. ConcurrentHashMap8Test#testKeySetAddRemove()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * keySet.add adds the key with the established value to the map;
     * remove removes it.
     */
public void testKeySetAddRemove() {
    ConcurrentHashMap map = map5();
    Set set1 = map.keySet();
    Set set2 = map.keySet(true);
    set2.add(six);
    assertTrue(((ConcurrentHashMap.KeySetView) set2).getMap() == map);
    assertTrue(((ConcurrentHashMap.KeySetView) set1).getMap() == map);
    assertEquals(set2.size(), map.size());
    assertEquals(set1.size(), map.size());
    assertTrue((Boolean) map.get(six));
    assertTrue(set1.contains(six));
    assertTrue(set2.contains(six));
    set2.remove(six);
    assertNull(map.get(six));
    assertFalse(set1.contains(six));
    assertFalse(set2.contains(six));
}

43. ConcurrentHashMap8Test#testEquals()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * KeySets with equal elements are equal
     */
public void testEquals() {
    Set a = populatedSet(3);
    Set b = populatedSet(3);
    assertTrue(a.equals(b));
    assertTrue(b.equals(a));
    assertEquals(a.hashCode(), b.hashCode());
    a.add(m1);
    assertFalse(a.equals(b));
    assertFalse(b.equals(a));
    b.add(m1);
    assertTrue(a.equals(b));
    assertTrue(b.equals(a));
    assertEquals(a.hashCode(), b.hashCode());
}

44. ObsTest#setGroupMembers_shouldMarkTheObsAsDirtyWhenTheSetIsReplacedWithAnotherWithDifferentMembers()

Project: openmrs-core
Source File: ObsTest.java
View license
/**
	 * @see Obs#setGroupMembers(Set)
	 * @verifies mark the obs as dirty when the set is replaced with another with different members
	 */
@Test
public void setGroupMembers_shouldMarkTheObsAsDirtyWhenTheSetIsReplacedWithAnotherWithDifferentMembers() throws Exception {
    Obs obs = new Obs();
    Set members1 = new HashSet<>();
    members1.add(new Obs());
    obs.setGroupMembers(members1);
    resetObs(obs);
    Set members2 = new HashSet<>();
    members2.add(new Obs());
    obs.setGroupMembers(members2);
    assertTrue(obs.isDirty());
}

45. ObsTest#setGroupMembers_shouldNotMarkTheObsAsDirtyWhenTheSetIsReplacedWithAnotherWithSameMembers()

Project: openmrs-core
Source File: ObsTest.java
View license
/**
	 * @see Obs#setGroupMembers(Set)
	 * @verifies not mark the obs as dirty when the set is replaced with another with same members
	 */
@Test
public void setGroupMembers_shouldNotMarkTheObsAsDirtyWhenTheSetIsReplacedWithAnotherWithSameMembers() throws Exception {
    Obs obs = new Obs();
    Obs o = new Obs();
    Set members1 = new HashSet<>();
    members1.add(o);
    obs.setGroupMembers(members1);
    resetObs(obs);
    Set members2 = new HashSet<>();
    members2.add(o);
    obs.setGroupMembers(members2);
    assertFalse(obs.isDirty());
}

46. CmSynchronizer#reconcileOfficialInstructors()

Project: sakai
Source File: CmSynchronizer.java
View license
protected void reconcileOfficialInstructors(Element esElement, EnrollmentSet enrollmentSet) {
    List newInstructorElements = esElement.getChild("official-instructors").getChildren("official-instructor");
    Set newUserEids = new HashSet();
    for (Iterator iter = newInstructorElements.iterator(); iter.hasNext(); ) {
        String userEid = ((Element) iter.next()).getText();
        newUserEids.add(userEid);
    }
    Set officialInstructors = enrollmentSet.getOfficialInstructors();
    if (officialInstructors == null) {
        officialInstructors = new HashSet();
        enrollmentSet.setOfficialInstructors(officialInstructors);
    }
    officialInstructors.clear();
    officialInstructors.addAll(newUserEids);
    cmAdmin.updateEnrollmentSet(enrollmentSet);
}

47. ItemService#cloneItem()

Project: sakai
Source File: ItemService.java
View license
public ItemData cloneItem(ItemDataIfc item) {
    ItemData cloned = new ItemData(item.getSection(), item.getSequence(), item.getDuration(), item.getInstruction(), item.getDescription(), item.getTypeId(), item.getGrade(), item.getScore(), item.getScoreDisplayFlag(), item.getDiscount(), item.getMinScore(), item.getHint(), item.getHasRationale(), item.getStatus(), item.getCreatedBy(), item.getCreatedDate(), item.getLastModifiedBy(), item.getLastModifiedDate(), null, null, null, item.getTriesAllowed(), item.getPartialCreditFlag());
    // perform deep copy, set ItemTextSet, itemMetaDataSet and itemFeedbackSet
    Set newItemTextSet = copyItemTextSet(cloned, item.getItemTextSet());
    Set newItemMetaDataSet = copyItemMetaDataSet(cloned, item.getItemMetaDataSet());
    Set newItemFeedbackSet = copyItemFeedbackSet(cloned, item.getItemFeedbackSet());
    Set newItemAttachmentSet = copyItemAttachmentSet(cloned, item.getItemAttachmentSet());
    String newItemInstruction = AssessmentService.copyStringAttachment(item.getInstruction());
    cloned.setItemTextSet(newItemTextSet);
    cloned.setItemMetaDataSet(newItemMetaDataSet);
    cloned.setItemFeedbackSet(newItemFeedbackSet);
    cloned.setItemAttachmentSet(newItemAttachmentSet);
    cloned.setAnswerOptionsSimpleOrRich(item.getAnswerOptionsSimpleOrRich());
    cloned.setAnswerOptionsRichCount(item.getAnswerOptionsRichCount());
    cloned.setInstruction(newItemInstruction);
    return cloned;
}

48. VirtualInstanceFactoryTest#testFindGuestsWithoutAHostByOrg()

View license
/**
     * Commeting out test for satellite.
    public void testFindGuestsWithNonVirtHostByOrg() throws Exception {
        Set expectedViews = new HashSet();

        expectedViews.add(builder.createGuest().withNonVirtHost()
                .withPersistence().build().asGuestAndNonVirtHostView());
        expectedViews.add(builder.createGuest().withNonVirtHost()
                .withPersistence().build().asGuestAndNonVirtHostView());
        expectedViews.add(builder.createGuest().withNonVirtHostInAnotherOrg()
                .withPersistence().build().asGuestAndNonVirtHostView());
        expectedViews.add(builder.createGuest().withVirtHostInAnotherOrg()
                .withPersistence().build().asGuestAndNonVirtHostView());

        builder.createGuest().withVirtHost().withPersistence().build();
        builder.createGuest().withPersistence().build();

        Set actualViews = virtualInstanceDAO
                .findGuestsWithNonVirtHostByOrg(user.getOrg());

        assertTrue(CollectionUtils
                .isEqualCollection(expectedViews, actualViews));
    }*/
public void testFindGuestsWithoutAHostByOrg() throws Exception {
    Set expectedViews = new HashSet();
    expectedViews.add(builder.createGuest().withPersistence().build().asGuestAndNonVirtHostView());
    expectedViews.add(builder.createGuest().withPersistence().build().asGuestAndNonVirtHostView());
    builder.createGuest().withNonVirtHostInAnotherOrg().withPersistence().build();
    builder.createGuest().withNonVirtHost().withPersistence().build();
    builder.createGuest().withVirtHost().withPersistence().build();
    Set actualViews = virtualInstanceDAO.findGuestsWithoutAHostByOrg(user.getOrg());
    assertTrue(CollectionUtils.isEqualCollection(expectedViews, actualViews));
}

49. CollectionsTest#testLinkedHashSetRetainsOrdering()

Project: xstream
Source File: CollectionsTest.java
View license
public void testLinkedHashSetRetainsOrdering() {
    Set set = new LinkedHashSet();
    set.add("Z");
    set.add("C");
    set.add("X");
    LinkedHashSet result = (LinkedHashSet) assertBothWays(set, "<linked-hash-set>\n" + "  <string>Z</string>\n" + "  <string>C</string>\n" + "  <string>X</string>\n" + "</linked-hash-set>");
    Object[] values = result.toArray();
    assertEquals("Z", values[0]);
    assertEquals("C", values[1]);
    assertEquals("X", values[2]);
}

50. CustomMultiscaleQuantizeTransformTest#makeFeatureVector()

View license
public FeatureVector makeFeatureVector() {
    Map<String, Set<String>> stringFeatures = new HashMap<>();
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    Set list = new HashSet<String>();
    list.add("aaa");
    list.add("bbb");
    stringFeatures.put("strFeature1", list);
    Map<String, Double> map = new HashMap<>();
    map.put("lat", 37.7);
    map.put("long", 40.0);
    map.put("zero", 0.0);
    map.put("negative", -1.0);
    floatFeatures.put("loc", map);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    featureVector.setFloatFeatures(floatFeatures);
    return featureVector;
}

51. DateValTransformTest#makeFeatureVector()

Project: aerosolve
Source File: DateValTransformTest.java
View license
public FeatureVector makeFeatureVector() {
    Map<String, Set<String>> stringFeatures = new HashMap<>();
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    Set dates = new HashSet<String>();
    dates.add("2009-03-01");
    dates.add("2009-02-27");
    stringFeatures.put("dates", dates);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    featureVector.setFloatFeatures(floatFeatures);
    return featureVector;
}

52. DefaultStringTokenizerTransformTest#makeFeatureVector()

View license
public FeatureVector makeFeatureVector() {
    Map<String, Set<String>> stringFeatures = new HashMap<>();
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    Set list = new HashSet<String>();
    list.add("I like blueberry pie, apple pie; and I also like blue!");
    list.add("I'm so  excited: I   like blue!?!!");
    stringFeatures.put("strFeature1", list);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    featureVector.setFloatFeatures(floatFeatures);
    return featureVector;
}

53. ListTransformTest#makeFeatureVector()

Project: aerosolve
Source File: ListTransformTest.java
View license
public FeatureVector makeFeatureVector() {
    Map<String, Set<String>> stringFeatures = new HashMap<>();
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    Set list = new HashSet<String>();
    list.add("aaa");
    list.add("bbb");
    stringFeatures.put("strFeature1", list);
    Map<String, Double> map = new HashMap<>();
    map.put("lat", 37.7);
    map.put("long", 40.0);
    floatFeatures.put("loc", map);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    featureVector.setFloatFeatures(floatFeatures);
    return featureVector;
}

54. SelfCrossTransformTest#makeFeatureVector()

View license
public FeatureVector makeFeatureVector() {
    HashMap stringFeatures = new HashMap<String, Set<String>>();
    Set list = new HashSet<String>();
    list.add("aaa");
    list.add("bbb");
    stringFeatures.put("feature1", list);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    return featureVector;
}

55. SetAssert_raw_set_assertions_chained_after_superclass_method_Test#test_bug_485()

View license
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void test_bug_485() {
    // https://github.com/joel-costigliola/assertj-core/issues/485
    Set set = new java.util.HashSet<>();
    set.add("Key1");
    set.add("Key2");
    assertThat(set).as("").contains("Key1", "Key2");
    assertThat(set).as("").containsOnly("Key1", "Key2");
}

56. X509CRLObject#hasUnsupportedCriticalExtension()

Project: bc-java
Source File: X509CRLObject.java
View license
/**
     * Will return true if any extensions are present and marked
     * as critical as we currently dont handle any extensions!
     */
public boolean hasUnsupportedCriticalExtension() {
    Set extns = getCriticalExtensionOIDs();
    if (extns == null) {
        return false;
    }
    extns.remove(Extension.issuingDistributionPoint.getId());
    extns.remove(Extension.deltaCRLIndicator.getId());
    return !extns.isEmpty();
}

57. X509CRLObject#hasUnsupportedCriticalExtension()

Project: bc-java
Source File: X509CRLObject.java
View license
/**
     * Will return true if any extensions are present and marked
     * as critical as we currently dont handle any extensions!
     */
public boolean hasUnsupportedCriticalExtension() {
    Set extns = getCriticalExtensionOIDs();
    if (extns == null) {
        return false;
    }
    extns.remove(RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT);
    extns.remove(RFC3280CertPathUtilities.DELTA_CRL_INDICATOR);
    return !extns.isEmpty();
}

58. X509CRLObject#hasUnsupportedCriticalExtension()

Project: bc-java
Source File: X509CRLObject.java
View license
/**
     * Will return true if any extensions are present and marked
     * as critical as we currently dont handle any extensions!
     */
public boolean hasUnsupportedCriticalExtension() {
    Set extns = getCriticalExtensionOIDs();
    if (extns == null) {
        return false;
    }
    extns.remove(RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT);
    extns.remove(RFC3280CertPathUtilities.DELTA_CRL_INDICATOR);
    return !extns.isEmpty();
}

59. X509CRLObject#hasUnsupportedCriticalExtension()

Project: bc-java
Source File: X509CRLObject.java
View license
/**
     * Will return true if any extensions are present and marked
     * as critical as we currently dont handle any extensions!
     */
public boolean hasUnsupportedCriticalExtension() {
    Set extns = getCriticalExtensionOIDs();
    if (extns == null) {
        return false;
    }
    extns.remove(Extension.issuingDistributionPoint.getId());
    extns.remove(Extension.deltaCRLIndicator.getId());
    return !extns.isEmpty();
}

60. X509CRLObject#hasUnsupportedCriticalExtension()

Project: bc-java
Source File: X509CRLObject.java
View license
/**
     * Will return true if any extensions are present and marked
     * as critical as we currently dont handle any extensions!
     */
public boolean hasUnsupportedCriticalExtension() {
    Set extns = getCriticalExtensionOIDs();
    if (extns == null) {
        return false;
    }
    extns.remove(RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT);
    extns.remove(RFC3280CertPathUtilities.DELTA_CRL_INDICATOR);
    return !extns.isEmpty();
}

61. GroupCategorySet#union()

Project: che
Source File: GroupCategorySet.java
View license
/**
	 * Creates a new group category set containing the union of the given two
	 * group category sets
	 *
	 * @param one the first set of group categories
	 * @param two the second set of group categories
	 *
	 * @return the union
	 */
public static GroupCategorySet union(GroupCategorySet one, GroupCategorySet two) {
    Assert.isNotNull(one);
    Assert.isNotNull(two);
    // therefore best used as static final fields.
    if (one == two)
        return one;
    if (one == NONE)
        return two;
    if (two == NONE)
        return one;
    Set combined = new HashSet();
    combined.addAll(one.asList());
    combined.addAll(two.asList());
    return new GroupCategorySet(combined);
}

62. NestedHS#payload()

Project: fast-serialization
Source File: NestedHS.java
View license
static byte[] payload() throws IOException {
    Set root = new HashSet();
    Set s1 = root;
    Set s2 = new HashSet();
    for (int i = 0; i < 100; i++) {
        Set t1 = new HashSet();
        Set t2 = new HashSet();
        // make it not equal to t2
        t1.add("foo");
        s1.add(t1);
        s1.add(t2);
        s2.add(t1);
        s2.add(t2);
        s1 = t1;
        s2 = t2;
    }
    return serialize(root);
}

63. GBeanNameTest#testEquals()

Project: geronimo
Source File: GBeanNameTest.java
View license
public void testEquals() {
    GBeanName name = new GBeanName("testDomain:prop1=value1,prop2=value2");
    assertEquals(name, name);
    assertEquals(new GBeanName("testDomain:prop2=value2,prop1=value1"), name);
    assertFalse(name.equals(new GBeanName("foo:prop1=value1,prop2=value2")));
    assertFalse(name.equals(new GBeanName("testDomain:prop1=value1")));
    assertFalse(name.equals(new GBeanName("testDomain:prop2=value2")));
    assertFalse(name.equals(new GBeanName("testDomain:prop2=value2")));
    assertFalse(name.equals(new GBeanName("testDomain:prop1=value1,prop2=value2,prop3=value3")));
    Set set = new HashSet();
    set.add(name);
    set.add(name);
    assertEquals(1, set.size());
}

64. CertificatePropertiesFileLoginModule#commit()

View license
public boolean commit() throws LoginException {
    Set principals = subject.getPrincipals();
    principals.add(principal);
    String userName = (String) users.get(principal.getName());
    principals.add(new GeronimoUserPrincipal(userName));
    Iterator e = groups.keySet().iterator();
    while (e.hasNext()) {
        String groupName = (String) e.next();
        Set users = (Set) groups.get(groupName);
        Iterator iter = users.iterator();
        while (iter.hasNext()) {
            String user = (String) iter.next();
            if (userName.equals(user)) {
                principals.add(new GeronimoGroupPrincipal(groupName));
                break;
            }
        }
    }
    return true;
}

65. HTreeSetTest#issue116_isEmpty()

Project: mapdb
Source File: HTreeSetTest.java
View license
@Test
public void issue116_isEmpty() {
    File f = TT.tempFile();
    Set s = DBMaker.fileDB(f.getPath()).make().hashSet("name").make();
    assertTrue(s.isEmpty());
    assertEquals(0, s.size());
    s.add("aa");
    assertEquals(1, s.size());
    assertFalse(s.isEmpty());
    s.remove("aa");
    assertTrue(s.isEmpty());
    assertEquals(0, s.size());
    f.delete();
}

66. Operation#getAllFaultsSet()

Project: openjdk
Source File: Operation.java
View license
public Set<Fault> getAllFaultsSet() {
    Set transSet = new HashSet();
    transSet.addAll(_faults);
    Iterator iter = _faults.iterator();
    Fault fault;
    Set tmpSet;
    while (iter.hasNext()) {
        tmpSet = ((Fault) iter.next()).getAllFaultsSet();
        transSet.addAll(tmpSet);
    }
    return transSet;
}

67. CourseManagementServiceTest#testIsEnrolled()

View license
@Test
public void testIsEnrolled() throws Exception {
    Set enrollmentSetEids = new HashSet();
    enrollmentSetEids.add("BIO101_F2006_01_ES01");
    // We don't care about bad EnrollmentSet eids here... we're just interested in Enrollments
    enrollmentSetEids.add("bad eid");
    Assert.assertTrue(cm.isEnrolled("josh", enrollmentSetEids));
    // Graders are not enrolled
    Assert.assertTrue(!cm.isEnrolled("grader1", enrollmentSetEids));
    Assert.assertTrue(!cm.isEnrolled("grader2", enrollmentSetEids));
}

68. UserPaneTest#addPanes()

Project: spacewalk
Source File: UserPaneTest.java
View license
private List addPanes() {
    List panes = new ArrayList(PaneFactory.getAllPanes().values());
    UserFactory.save(user);
    Long id = user.getId();
    user = null;
    user = UserFactory.lookupById(id);
    Set userPanes = new HashSet();
    userPanes.add(panes.get(0));
    userPanes.add(panes.get(1));
    user.setHiddenPanes(userPanes);
    UserFactory.save(user);
    user = null;
    user = UserFactory.lookupById(id);
    assertEquals(new HashSet(panes.subList(0, 2)), new HashSet(user.getHiddenPanes()));
    return panes.subList(0, 2);
}

69. Namespace#getPageNames()

Project: tapestry4
Source File: Namespace.java
View license
public List getPageNames() {
    Set names = new HashSet();
    names.addAll(_pages.keySet());
    names.addAll(_specification.getPageNames());
    List result = new ArrayList(names);
    Collections.sort(result);
    return result;
}

70. IvyMenuContributionItem#doCollectContainer()

View license
private void doCollectContainer(Map /* <IProject, Set<IvyClasspathContainer>> */
containers, IvyClasspathContainerImpl ivycp) {
    IJavaProject javaProject = ivycp.getConf().getJavaProject();
    if (javaProject == null) {
        return;
    }
    Set /* <IvyClasspathContainer> */
    cplist = (Set) containers.get(javaProject.getProject());
    if (cplist == null) {
        cplist = new HashSet();
        containers.put(javaProject.getProject(), cplist);
    }
    cplist.add(ivycp);
}

71. AxisService2WSDL20#generateRPCSignature()

Project: axis2-java
Source File: AxisService2WSDL20.java
View license
private String generateRPCSignature(Map inMessageElementDetails, Map outMessageElementDetails) {
    String in = "";
    String out = "";
    String inOut = "";
    Set inElementSet = inMessageElementDetails.keySet();
    Set outElementSet = outMessageElementDetails.keySet();
    Iterator inElementIterator = inElementSet.iterator();
    while (inElementIterator.hasNext()) {
        String inElementName = (String) inElementIterator.next();
        if (outElementSet.contains(inElementName)) {
            inOut = inOut + inElementName + " " + WSDL2Constants.RPC_INOUT + " ";
            outElementSet.remove(inElementName);
        } else {
            in = in + inElementName + " " + WSDL2Constants.RPC_IN + " ";
        }
    }
    Iterator outElementIterator = outElementSet.iterator();
    while (outElementIterator.hasNext()) {
        String outElementName = (String) outElementIterator.next();
        out = out + outElementName + " " + WSDL2Constants.RPC_RETURN + " ";
    }
    return in + out + inOut;
}

72. ClassFileUtilities#getClassDependencies()

Project: batik
Source File: ClassFileUtilities.java
View license
public static Set getClassDependencies(InputStream is, Set classpath, boolean rec) throws IOException {
    Set result = new HashSet();
    Set done = new HashSet();
    computeClassDependencies(is, classpath, done, result, rec);
    return result;
}

73. PathMatchingResourcePatternResolver#doFindMatchingFileSystemResources()

View license
/**
	 * Find all resources in the file system that match the given location pattern
	 * via the Ant-style PathMatcher.
	 * @param rootDir the root directory in the file system
	 * @param subPattern the sub pattern to match (below the root directory)
	 * @return the Set of matching Resource instances
	 * @throws IOException in case of I/O errors
	 * @see #retrieveMatchingFiles
	 * @see PathMatcher
	 */
protected Set doFindMatchingFileSystemResources(File rootDir, String subPattern) throws IOException {
    if (logger.isDebugEnabled()) {
        logger.debug("Looking for matching resources in directory tree [" + rootDir.getPath() + "]");
    }
    Set matchingFiles = retrieveMatchingFiles(rootDir, subPattern);
    Set result = new LinkedHashSet(matchingFiles.size());
    for (Iterator it = matchingFiles.iterator(); it.hasNext(); ) {
        File file = (File) it.next();
        result.add(new FileSystemResource(file));
    }
    return result;
}

74. ECAlgorithmsTest#getTestCurves()

Project: bc-java
Source File: ECAlgorithmsTest.java
View license
private ArrayList getTestCurves() {
    ArrayList x9s = new ArrayList();
    Set names = new HashSet(AllTests.enumToList(ECNamedCurveTable.getNames()));
    names.addAll(AllTests.enumToList(CustomNamedCurves.getNames()));
    Iterator it = names.iterator();
    while (it.hasNext()) {
        String name = (String) it.next();
        X9ECParameters x9 = ECNamedCurveTable.getByName(name);
        if (x9 != null) {
            addTestCurves(x9s, x9);
        }
        x9 = CustomNamedCurves.getByName(name);
        if (x9 != null) {
            addTestCurves(x9s, x9);
        }
    }
    return x9s;
}

75. X509LDAPCertStoreSpi#getCACertificates()

Project: bc-java
Source File: X509LDAPCertStoreSpi.java
View license
private Set getCACertificates(X509CertSelector xselector) throws CertStoreException {
    String[] attrs = { params.getCACertificateAttribute() };
    String attrName = params.getLdapCACertificateAttributeName();
    String subjectAttributeName = params.getCACertificateSubjectAttributeName();
    Set set = certSubjectSerialSearch(xselector, attrs, attrName, subjectAttributeName);
    if (set.isEmpty()) {
        set.addAll(search(null, "*", attrs));
    }
    return set;
}

76. X509LDAPCertStoreSpi#getCrossCertificates()

Project: bc-java
Source File: X509LDAPCertStoreSpi.java
View license
private Set getCrossCertificates(X509CertSelector xselector) throws CertStoreException {
    String[] attrs = { params.getCrossCertificateAttribute() };
    String attrName = params.getLdapCrossCertificateAttributeName();
    String subjectAttributeName = params.getCrossCertificateSubjectAttributeName();
    Set set = certSubjectSerialSearch(xselector, attrs, attrName, subjectAttributeName);
    if (set.isEmpty()) {
        set.addAll(search(null, "*", attrs));
    }
    return set;
}

77. ContinuationsManagerImpl#getForest()

View license
public Set getForest() {
    Set rootWebContinuations = new HashSet();
    // identify the root continuations, once done no more need to lock
    synchronized (this.expirations) {
        for (Iterator iter = this.expirations.iterator(); iter.hasNext(); ) {
            WebContinuation webContinuation = (WebContinuation) iter.next();
            while (webContinuation.getParentContinuation() != null) {
                webContinuation = webContinuation.getParentContinuation();
            }
            rootWebContinuations.add(webContinuation);
        }
    }
    Set clonedRootWebContinuations = new HashSet();
    for (Iterator iter = rootWebContinuations.iterator(); iter.hasNext(); ) {
        WebContinuation rootContinuation = (WebContinuation) iter.next();
        clonedRootWebContinuations.add(rootContinuation.clone());
    }
    return clonedRootWebContinuations;
}

78. SitemapLanguage#addViewForLabel()

Project: cocoon
Source File: SitemapLanguage.java
View license
/**
     * Add a view for a label. This is used to register all views that start from
     * a given label.
     *
     * @param label the label (or pseudo-label) for the view
     * @param view the view name
     */
public void addViewForLabel(String label, String view) {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("views:addViewForLabel(" + label + ", " + view + ")");
    }
    Set views = (Set) this.labelViews.get(label);
    if (views == null) {
        views = new HashSet();
        this.labelViews.put(label, views);
    }
    views.add(view);
}

79. RuntimeAttributeRepository#addFieldAttribute()

View license
/**
     * Adds an attribute to a field.
     *
     * @since 2.1
     */
public void addFieldAttribute(Field f, Object attribute) {
    checkSealed();
    String signature = f.getName();
    if (f.getDeclaringClass() != clazz) {
        throw new IllegalArgumentException("There is no " + signature + " in " + clazz.getName() + ". It is defined in " + f.getDeclaringClass().getName());
    }
    Set attributeSet = (Set) fieldAttributes.get(signature);
    if (attributeSet == null) {
        attributeSet = new HashSet();
        fieldAttributes.put(signature, attributeSet);
    }
    attributeSet.add(attribute);
}

80. WeakHashtable#entrySet()

Project: commons-logging
Source File: WeakHashtable.java
View license
/**
     [email protected] Hashtable
     */
public Set entrySet() {
    purge();
    Set referencedEntries = super.entrySet();
    Set unreferencedEntries = new HashSet();
    for (Iterator it = referencedEntries.iterator(); it.hasNext(); ) {
        Map.Entry entry = (Map.Entry) it.next();
        Referenced referencedKey = (Referenced) entry.getKey();
        Object key = referencedKey.getValue();
        Object value = entry.getValue();
        if (key != null) {
            Entry dereferencedEntry = new Entry(key, value);
            unreferencedEntries.add(dereferencedEntry);
        }
    }
    return unreferencedEntries;
}

81. WeakHashtable#keySet()

Project: commons-logging
Source File: WeakHashtable.java
View license
/**
     [email protected] Hashtable
     */
public Set keySet() {
    purge();
    Set referencedKeys = super.keySet();
    Set unreferencedKeys = new HashSet();
    for (Iterator it = referencedKeys.iterator(); it.hasNext(); ) {
        Referenced referenceKey = (Referenced) it.next();
        Object keyValue = referenceKey.getValue();
        if (keyValue != null) {
            unreferencedKeys.add(keyValue);
        }
    }
    return unreferencedKeys;
}

82. OptimisticMapWrapper#checkForConflicts()

View license
// TODO: Shouldn't we return a collection rather than a single key here?
public Object checkForConflicts() {
    CopyingTxContext txContext = (CopyingTxContext) getActiveTx();
    Set keys = txContext.changedKeys();
    Set externalKeys = txContext.externalChangedKeys();
    for (Iterator it2 = keys.iterator(); it2.hasNext(); ) {
        Object key = it2.next();
        if (externalKeys.contains(key)) {
            return key;
        }
    }
    return null;
}

83. TypeMap#registerJdbcType()

Project: ddlutils
Source File: TypeMap.java
View license
/**
     * Registers a jdbc type.
     * 
     * @param typeCode The type code (one of the [email protected] java.sql.Types} constants)
     * @param typeName The type name (case is ignored)
     * @param category The type category
     */
protected static void registerJdbcType(int typeCode, String typeName, JdbcTypeCategoryEnum category) {
    Integer typeId = new Integer(typeCode);
    _typeNameToTypeCode.put(typeName.toUpperCase(), typeId);
    _typeCodeToTypeName.put(typeId, typeName.toUpperCase());
    Set typesInCategory = (Set) _typesPerCategory.get(category);
    if (typesInCategory == null) {
        typesInCategory = new HashSet();
        _typesPerCategory.put(category, typesInCategory);
    }
    typesInCategory.add(typeId);
}

84. NameMappings#addLookupOnly()

Project: flex-falcon
Source File: NameMappings.java
View license
public void addLookupOnly(String namespaceURI, String cls) {
    Set classes = lookupOnly.get(namespaceURI);
    if (classes == null) {
        classes = new HashSet<String>();
        lookupOnly.put(namespaceURI, classes);
    }
    classes.add(cls);
}

85. PropertiesFileLoginModuleNoCache#commit()

View license
public boolean commit() throws LoginException {
    Set principals = subject.getPrincipals();
    principals.add(new GeronimoUserPrincipal(username));
    Iterator e = groups.keySet().iterator();
    while (e.hasNext()) {
        String groupName = (String) e.next();
        Set users = (Set) groups.get(groupName);
        Iterator iter = users.iterator();
        while (iter.hasNext()) {
            String user = (String) iter.next();
            if (username.equals(user)) {
                principals.add(new GeronimoGroupPrincipal(groupName));
                break;
            }
        }
    }
    return true;
}

86. PropertiesLoginModuleManager#getGroupMembers()

View license
public Set getGroupMembers(String groupPrincipal) throws GeronimoSecurityException {
    Set memberSet = new HashSet();
    groups.clear();
    refreshGroups();
    if (groups.getProperty(groupPrincipal) == null) {
        return memberSet;
    }
    String[] members = ((String) groups.getProperty(groupPrincipal)).split(",");
    memberSet.addAll(Arrays.asList(members));
    return memberSet;
}

87. ConnectionTrackingCoordinator#handleObtained()

View license
public void handleObtained(ConnectionTrackingInterceptor connectionTrackingInterceptor, ConnectionInfo connectionInfo) {
    InstanceContext instanceContext = (InstanceContext) currentInstanceContexts.get();
    if (instanceContext == null) {
        return;
    }
    Map resources = instanceContext.getConnectionManagerMap();
    Set infos = (Set) resources.get(connectionTrackingInterceptor);
    if (infos == null) {
        infos = new HashSet();
        resources.put(connectionTrackingInterceptor, infos);
    }
    infos.add(connectionInfo);
}

88. AbstractDeployCommand#getDeployerName()

Project: geronimo
Source File: AbstractDeployCommand.java
View license
private ObjectName getDeployerName() {
    Set deployers = kernel.listGBeans(JMXUtil.getObjectName(DEPLOYER_NAME));
    if (deployers.isEmpty()) {
        fail("No Deployer GBean present in running Geronimo server. " + "This usually indicates a serious problem with the configuration of " + "your running Geronimo server.  If " + "the deployer is present but not started, the workaround is to run " + "a deploy command like 'start geronimo/geronimo-gbean-deployer/1.0/car'.  " + "If the deployer service is not present at all (it was undeployed) then " + "you need to either re-install Geronimo or get a deployment plan for the " + "runtime deployer and distribute it while the server is not running and " + "then start the server with a command like the above.  For help on this, " + "write to [email protected] and include the contents of your " + "config-store/index.properties and var/config/config.xml files.");
        return null;
    }
    Iterator j = deployers.iterator();
    ObjectName deployer = (ObjectName) j.next();
    if (j.hasNext()) {
        fail("More than one deployer found");
        return null;
    }
    return deployer;
}

89. DynamicGBeanDelegate#getProperties()

Project: geronimo
Source File: DynamicGBeanDelegate.java
View license
/**
     * Gets all properties (with both a getter and setter), in the form of
     * propertyName
     */
public String[] getProperties() {
    Set one = getters.keySet();
    Set two = setters.keySet();
    List out = new ArrayList();
    for (Iterator it = one.iterator(); it.hasNext(); ) {
        String name = (String) it.next();
        if (Character.isLowerCase(name.charAt(0)) && two.contains(name)) {
            out.add(name);
        }
    }
    return (String[]) out.toArray(new String[out.size()]);
}

90. BasicKernel#listGBeansByInterface()

Project: geronimo
Source File: BasicKernel.java
View license
public Set listGBeansByInterface(String[] interfaces) {
    Set gbeans = new HashSet();
    Set all = null;
    try {
        all = listGBeans(ObjectName.getInstance("*:*"));
    } catch (MalformedObjectNameException e) {
        throw new IllegalStateException("How can *:* be an invalid pattern");
    }
    for (Iterator it = all.iterator(); it.hasNext(); ) {
        ObjectName name = (ObjectName) it.next();
        try {
            GBeanInfo info = getGBeanInfo(name);
            Set intfs = info.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                String candidate = interfaces[i];
                if (intfs.contains(candidate)) {
                    gbeans.add(name);
                    break;
                }
            }
        } catch (GBeanNotFoundException e) {
        }
    }
    return gbeans;
}

91. ConfigurationUtil#getConfigurationManager()

Project: geronimo
Source File: ConfigurationUtil.java
View license
/**
     * Gets a reference or proxy to the ConfigurationManager running in the specified kernel.
     *
     * @return The ConfigurationManager
     *
     * @throws IllegalStateException Occurs if a ConfigurationManager cannot be identified
     */
public static ConfigurationManager getConfigurationManager(Kernel kernel) {
    Set names = kernel.listGBeans(new GBeanQuery(null, ConfigurationManager.class.getName()));
    for (Iterator iterator = names.iterator(); iterator.hasNext(); ) {
        ObjectName objectName = (ObjectName) iterator.next();
        try {
            if (kernel.getGBeanState(objectName) != State.RUNNING_INDEX) {
                iterator.remove();
            }
        } catch (GBeanNotFoundException e) {
            iterator.remove();
        }
    }
    if (names.isEmpty()) {
        throw new IllegalStateException("A Configuration Manager could not be found in the kernel");
    }
    if (names.size() > 1) {
        throw new IllegalStateException("More than one Configuration Manager was found in the kernel");
    }
    ObjectName configurationManagerName = (ObjectName) names.iterator().next();
    return (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);
}

92. ConfigurationUtil#getEditableConfigurationManager()

Project: geronimo
Source File: ConfigurationUtil.java
View license
/**
     * Gets a reference or proxy to an EditableConfigurationManager running in the specified kernel, if there is one.
     *
     * @return The EdtiableConfigurationManager, or none if there is not one available.
     *
     * @throws IllegalStateException Occurs if there are multiple EditableConfigurationManagers in the kernel.
     */
public static EditableConfigurationManager getEditableConfigurationManager(Kernel kernel) {
    Set names = kernel.listGBeans(new GBeanQuery(null, EditableConfigurationManager.class.getName()));
    for (Iterator iterator = names.iterator(); iterator.hasNext(); ) {
        ObjectName objectName = (ObjectName) iterator.next();
        try {
            if (kernel.getGBeanState(objectName) != State.RUNNING_INDEX) {
                iterator.remove();
            }
        } catch (GBeanNotFoundException e) {
            iterator.remove();
        }
    }
    if (names.isEmpty()) {
        // may be one, just not editable
        return null;
    }
    if (names.size() > 1) {
        throw new IllegalStateException("More than one Configuration Manager was found in the kernel");
    }
    ObjectName configurationManagerName = (ObjectName) names.iterator().next();
    return (EditableConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, EditableConfigurationManager.class);
}

93. MBeanServerDelegate#queryNames()

Project: geronimo
Source File: MBeanServerDelegate.java
View license
public Set queryNames(ObjectName pattern, QueryExp query) {
    Set names = kernel.listGBeans(pattern);
    if (query == null) {
        return names;
    }
    Set filteredNames = new HashSet(names.size());
    for (Iterator iterator = names.iterator(); iterator.hasNext(); ) {
        // this must be done for each objectName applied
        query.setMBeanServer(this);
        ObjectName name = (ObjectName) iterator.next();
        try {
            if (query.apply(name)) {
                filteredNames.add(name);
            }
        } catch (Exception e) {
        }
    }
    return filteredNames;
}

94. MBeanServerDelegate#queryMBeans()

Project: geronimo
Source File: MBeanServerDelegate.java
View license
public Set queryMBeans(ObjectName pattern, QueryExp query) {
    Set names = queryNames(pattern, query);
    Set objectInstances = new HashSet(names.size());
    for (Iterator iterator = names.iterator(); iterator.hasNext(); ) {
        ObjectName name = (ObjectName) iterator.next();
        try {
            objectInstances.add(getObjectInstance(name));
        } catch (InstanceNotFoundException e) {
        }
    }
    return objectInstances;
}

95. ConfiguredIdentityNamedUsernamePasswordLoginModule#logout()

View license
public boolean logout() throws LoginException {
    if (namedUsernamePasswordCredential == null) {
        return true;
    }
    Set pvtCreds = subject.getPrivateCredentials(UsernamePasswordCredential.class);
    if (pvtCreds.contains(namedUsernamePasswordCredential)) {
        pvtCreds.remove(namedUsernamePasswordCredential);
    }
    try {
        namedUsernamePasswordCredential.destroy();
    } catch (DestroyFailedException e) {
    }
    namedUsernamePasswordCredential = null;
    return true;
}

96. NamedUPCredentialLoginModule#logout()

View license
public boolean logout() throws LoginException {
    if (nupCredential == null)
        return true;
    Set pvtCreds = subject.getPrivateCredentials(NamedUsernamePasswordCredential.class);
    if (pvtCreds.contains(nupCredential)) {
        pvtCreds.remove(nupCredential);
    }
    try {
        nupCredential.destroy();
    } catch (DestroyFailedException e) {
    }
    nupCredential = null;
    return true;
}

97. UPCredentialLoginModule#logout()

View license
public boolean logout() throws LoginException {
    if (upCredential == null)
        return true;
    Set pvtCreds = subject.getPrivateCredentials(UsernamePasswordCredential.class);
    if (pvtCreds.contains(upCredential)) {
        pvtCreds.remove(upCredential);
    }
    try {
        upCredential.destroy();
    } catch (DestroyFailedException e) {
    }
    upCredential = null;
    return true;
}

98. PropertiesFileLoginModule#commit()

View license
public boolean commit() throws LoginException {
    Set principals = subject.getPrincipals();
    principals.add(new GeronimoUserPrincipal(username));
    Iterator e = groups.keySet().iterator();
    while (e.hasNext()) {
        String groupName = (String) e.next();
        Set users = (Set) groups.get(groupName);
        Iterator iter = users.iterator();
        while (iter.hasNext()) {
            String user = (String) iter.next();
            if (username.equals(user)) {
                principals.add(new GeronimoGroupPrincipal(groupName));
                break;
            }
        }
    }
    return true;
}

99. AggregateCondition#getUnsatisfied()

View license
/**
     * Gets the unsatisfied conditions.
     *
     * @return the unstatisfied conditions
     */
public Set getUnsatisfied() {
    if (destroyed)
        throw new IllegalStateException("destroyed");
    Set unsatisfied = new HashSet();
    for (Iterator iterator = conditions.entrySet().iterator(); iterator.hasNext(); ) {
        Map.Entry entry = (Map.Entry) iterator.next();
        ServiceCondition condition = (ServiceCondition) entry.getKey();
        StandardServiceConditionContext context = (StandardServiceConditionContext) entry.getValue();
        if (!context.isSatisfied()) {
            if (condition.isSatisfied()) {
                // the condition is satisfied
                // record this fact in the context
                context.setSatisfied();
            } else {
                unsatisfied.add(condition);
            }
        }
    }
    // notify anyone awaiting satisfaction
    if (unsatisfied.isEmpty()) {
        satisfiedSignal.signalAll();
    }
    return unsatisfied;
}

100. NonRestartableStopCondition#updateConditions()

View license
private void updateConditions() {
    if (isDestroyed())
        throw new IllegalStateException("destroyed");
    Set conditions = getConditions();
    // add the new conditions
    Set stopConditions = serviceFactory.getStopConditions();
    for (Iterator iterator = stopConditions.iterator(); iterator.hasNext(); ) {
        ServiceCondition condition = (ServiceCondition) iterator.next();
        if (!conditions.contains(condition)) {
            addCondition(condition);
        }
    }
    // remove the conditions that were dropped
    for (Iterator iterator = conditions.iterator(); iterator.hasNext(); ) {
        ServiceCondition serviceCondition = (ServiceCondition) iterator.next();
        if (!stopConditions.contains(serviceCondition)) {
            removeCondition(serviceCondition);
        }
    }
}