Example usage for java.util Set toString

List of usage examples for java.util Set toString

Introduction

In this page you can find the example usage for java.util Set toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:Test.java

public static void main(String[] args) throws Exception {
    SelectorProvider provider = SelectorProvider.provider();
    NetworkChannel socketChannel = provider.openSocketChannel();
    SocketAddress address = new InetSocketAddress(3080);
    socketChannel = socketChannel.bind(address);

    Set<SocketOption<?>> socketOptions = socketChannel.supportedOptions();

    System.out.println(socketOptions.toString());
    socketChannel.setOption(StandardSocketOptions.IP_TOS, 3);
    Boolean keepAlive = socketChannel.getOption(StandardSocketOptions.SO_KEEPALIVE);
}

From source file:org.imesh.sample.jclouds.softlayer.Main.java

public static void main(String[] args) {
    SoftLayerIaaSProvider provider = new SoftLayerIaaSProvider(userName, apiKey);

    // Un-comment required method calls to test their functionality

    Set<? extends Location> locations = provider.listLocations();
    log.info("Locations: " + locations.toString());
    Set<? extends Hardware> hardware = provider.listHardware();
    log.info("Hardware: " + hardware.toString());
    Set<? extends Image> images = provider.listImages();
    log.info("Images: " + images.toString());
    Set<? extends ComputeMetadata> instances = provider.listInstances();
    printInstances(instances);/*  www  . j  av  a 2s  . co m*/

    //provider.createInstance(imageId, locationId, hardwareId, OsFamily.UBUNTU, "12.04", "service.com", "vm-1", "A=1234,B=1234,C=1234");
    //provider.terminateInstanceByName("vm-1");
}

From source file:ubic.pubmedgate.resolve.focusedAnalysis.TopRegions.java

/**
 * @param args// w  ww. j ava2  s.c  o  m
 */
public static void main(String[] args) throws Exception {
    // iterate and dump out regions - use Excel to sort and present
    ParamKeeper keeper = new ParamKeeper();

    boolean allComp = true;
    // if training then check for accepted
    Model modelLoad;
    String fileProperty;
    boolean reason = true;
    EvaluationRDFModel allCompModel = null;

    if (allComp) {
        modelLoad = ModelFactory.createDefaultModel();
        fileProperty = "resolve.Lexicon.resolution.RDF.allComp";
        modelLoad.read(new FileInputStream(Config.config.getString(fileProperty)), null);
        allCompModel = new EvaluationRDFModel(modelLoad, reason);
    }

    fileProperty = "resolve.Lexicon.resolution.RDF";
    modelLoad = ModelFactory.createDefaultModel();
    modelLoad.read(new FileInputStream(Config.config.getString(fileProperty)), null);

    EvaluationRDFModel model = new EvaluationRDFModel(modelLoad, reason);

    Set<Resource> commonSpeciesMentions = new HashSet<Resource>();
    Set<Resource> commonAllSpeciesMentions = new HashSet<Resource>();
    Set<String> commonSpecies = SpeciesCounter.getCommonSpeciesLinStrings();

    for (String common : commonSpecies) {
        common = common.substring(common.lastIndexOf(":") + 1);
        Set<Resource> mentionsForSpecies = model.getMentionsForSpecies(common);
        commonSpeciesMentions.addAll(mentionsForSpecies);
        if (allComp)
            commonAllSpeciesMentions.addAll(allCompModel.getMentionsForSpecies(common));
    }

    int count = 0;
    for (Resource concept : model.getConcepts()) {
        Map<String, String> line = new HashMap<String, String>();
        line.put("conceptURI", concept.getURI());
        line.put("conceptLabel", "\"" + JenaUtil.getLabel(concept) + "\"");

        Set<Resource> terms = model.getTermsFromConcepts(concept);
        line.put("terms", terms.size() + "");

        Set<Resource> mentions = model.getMentionsFromTerms(terms);
        line.put("unique mentions", mentions.size() + "");

        line.put("mentionFrequency", model.sumMentionFrequencies(mentions) + "");

        Set<Resource> commonMentions = (Set<Resource>) Util.intersect(commonSpeciesMentions, mentions);
        line.put("unique Common Mentions", commonMentions.size() + "");
        line.put("Common mentionFrequency", model.sumMentionFrequencies(commonMentions) + "");

        Set<Resource> rejectMentions = new HashSet<Resource>();
        Set<Resource> spec2genMentions = new HashSet<Resource>();
        for (Resource mention : mentions) {
            if (model.rejected(mention, concept)) {
                rejectMentions.add(mention);
            }
            if (model.specToGen(mention, concept)) {
                spec2genMentions.add(mention);
            }
        }
        line.put("Rejected Mentions", rejectMentions.size() + "");
        line.put("Spec2Gen Mentions", spec2genMentions.size() + "");
        String baseURI = concept.getURI();
        baseURI = baseURI.substring(0, baseURI.lastIndexOf('#'));
        line.put("Base URI", baseURI);

        Set<String> termStrings = new HashSet<String>();
        for (Resource term : terms) {
            termStrings.add(JenaUtil.getLabel(term));
        }
        line.put("terms", termStrings.toString());
        line.put("termCount", termStrings.size() + "");

        if (allComp) {
            Set<Resource> allMentions = allCompModel.getMentionsFromTerms(terms);

            line.put("unique allCompMentions", allMentions.size() + "");
            line.put("allCompMentions frequency", model.sumMentionFrequencies(allMentions) + "");

            Set<Resource> commonMentionsAll = (Set<Resource>) Util.intersect(commonAllSpeciesMentions,
                    allMentions);

            line.put("unique allComp Common Mentions", commonMentionsAll.size() + "");
            line.put("frequency allComp Common Mentions",
                    allCompModel.sumMentionFrequencies(commonMentionsAll) + "");
        }

        keeper.addParamInstance(line);
        if (count++ % 100 == 0) {
            log.info(count);
            //                if (count > 100) break;
        }

    }

    keeper.writeExcel(Config.config.getString("whitetext.resolve.results.folder") + "TopRegions.xls");

}

From source file:org.collectionspace.services.IntegrationTests.xmlreplay.XmlReplayEval.java

protected static String dumpContext(JexlContext jc) {
    String result = "";
    if (jc instanceof MapContextWKeys) {
        Set keys = ((MapContextWKeys) jc).getKeys();
        result = keys.toString();
    } else {//  w ww.  ja  va  2  s .  c  om
        result = jc.toString();
    }
    return result;
}

From source file:ubic.pubmedgate.resolve.depreciated.BagOfWordsResolver.java

public static Set<Set<String>> makeSetofBags(Set<String> lexicon) {
    // what if we treat each entry as a bag of words
    // delims taken from ngrampipefactory
    Set<Set<String>> lexiconSets = new HashSet<Set<String>>();
    for (String name : lexicon) {
        Set<String> bagOfWords = makeBagOfWords(name);
        if (lexiconSets.contains(bagOfWords)) {
            log.info(name + " is already in under " + bagOfWords.toString());
        }/*from ww  w  . j  a v a 2  s  .  c  o  m*/
        lexiconSets.add(bagOfWords);
    }
    log.info("Size before:" + lexicon.size());
    log.info("Size after:" + lexiconSets.size());
    return lexiconSets;
}

From source file:net.nifheim.beelzebu.coins.common.utils.dependencies.DependencyManager.java

public static void loadDependencies(Set<Dependency> dependencies) throws RuntimeException {
    core.getMethods().log("Identified the following dependencies: " + dependencies.toString());

    File libDir = new File(core.getDataFolder(), "lib");
    if (!(libDir.exists() || libDir.mkdirs())) {
        throw new RuntimeException("Unable to create lib dir - " + libDir.getPath());
    }/* w  w  w .  j  a va  2 s  . co  m*/

    // Download files.
    List<File> filesToLoad = new ArrayList<>();
    dependencies.forEach(dependency -> {
        try {
            filesToLoad.add(downloadDependency(libDir, dependency));
        } catch (Exception e) {
            core.getMethods().log("Exception whilst downloading dependency " + dependency.name());
        }
    });

    // Load classes.
    filesToLoad.forEach(file -> {
        try {
            loadJar(file);
        } catch (Throwable t) {
            core.getMethods().log("Failed to load dependency jar " + file.getName());
        }
    });
}

From source file:ubic.pubmedgate.interactions.focusedAnalysis.SplitConnectionsBySpecies.java

public static void getCounts() throws Exception {
    // String testSet = "Annotated";
    // String annotationSet = "Suzanne";
    ////  ww  w  . jav  a  2  s . c  o  m
    // String baseFolder = Config.config.getString( "whitetext.iteractions.ppiBaseFolder" )
    // + "Saved Results/SL/CV/WhiteTextNegFixFull/predict/WhiteTextNegFixFull";
    // String filename = Config.config.getString( "whitetext.iteractions.ppiBaseFolder" )
    // + "Corpora/Original-Modified/WhiteTextNegFixFull.xml";
    //
    // GateInterface p2g = new GateInterface();
    // p2g.setUnSeenCorpNull();
    //
    // AirolaXMLReader XMLReader = new AirolaXMLReader( filename, p2g, annotationSet );
    // SLOutputReader SLReader = new SLOutputReader( new File( baseFolder ) );
    String trainingSet = "WhiteTextNegFixFull";
    String testSet = "WhiteTextUnseen";
    String annotationSet = "Mallet";

    String baseFolder = Config.config.getString("whitetext.iteractions.ppiBaseFolder")
            + "Saved Results/SL/CC/NegFixFullOnUnseen/";
    String filename = Config.config.getString("whitetext.iteractions.ppiBaseFolder")
            + "Corpora/Original-Modified/WhiteTextUnseen.orig.xml";

    GateInterface p2g = new GateInterface();

    AirolaXMLReader XMLReader = new AirolaXMLReader(filename, p2g, annotationSet);
    SLOutputReader SLReader = new SLOutputReader(trainingSet, testSet, baseFolder);

    Map<String, String> pairIDtoPMID = XMLReader.getPairIDToPMID();

    List<String> posPredictions = SLReader.getPositivePredictions();

    CountingMap<String> speciesConCount = new CountingMap<String>();
    CountingMap<String> final2000Rows = new CountingMap<String>();
    CountingMap<String> final2000Accepts = new CountingMap<String>();

    LoadInteractionSpreadsheet final2000 = AllCuratorsCombined.getFinal2000Results();

    for (String pairID : posPredictions) {
        String PMID = pairIDtoPMID.get(pairID);
        ConnectionsDocument doc = p2g.getByPMID(PMID);
        Set<String> species = doc.getLinnaeusSpecies();
        speciesConCount.incrementAll(species);

        int final2000RowCount = final2000.getPairIDRowCount(pairID);
        int final2000AcceptCount = final2000.getPairIDAcceptCount(pairID);

        // ugly, but makes sense, increment the number of rows seen
        for (String spec : species) {
            for (int i = 0; i < final2000RowCount; i++) {
                final2000Rows.increment(spec);
            }
            for (int i = 0; i < final2000AcceptCount; i++) {
                final2000Accepts.increment(spec);
            }
        }
    }
    log.info("Pos predictions:" + posPredictions.size());

    log.info("speciesConCount:" + speciesConCount.size());

    StringToStringSetMap speciesStrings = SpeciesUtil.getSpeciesStrings(p2g, p2g.getUnseenCorp()).strings;
    ParamKeeper keeper = new ParamKeeper();
    for (String specieID : speciesConCount.keySet()) {
        Map<String, String> result = new HashMap<String, String>();
        result.put("speciesID", specieID);
        Set<String> speciesText = speciesStrings.get(specieID);
        if (speciesText == null)
            speciesText = new HashSet<String>();
        result.put("species text", speciesText.toString());
        result.put("connection count", "" + speciesConCount.get(specieID));
        result.put("final2000RowCount", "" + final2000Rows.get(specieID));
        result.put("final2000AcceptCount", "" + final2000Accepts.get(specieID));

        keeper.addParamInstance(result);
    }
    keeper.writeExcel(
            Config.config.getString("whitetext.iteractions.results.folder") + "connectionsBySpecies.xls");
    log.info(Config.config.getString("whitetext.iteractions.results.folder") + "connectionsBySpecies.xls");
    // p2g.get

}

From source file:org.wso2.carbon.identity.application.authenticator.iwa.IWAAuthenticationUtil.java

/**
 * Create GSSCredential as Subject//from   www  . j  a v  a  2  s  .  c o m
 *
 * @param subject login context subject
 * @return GSSCredential
 * @throws PrivilegedActionException
 */
private static GSSCredential createCredentialsForSubject(final Subject subject)
        throws PrivilegedActionException {
    final PrivilegedExceptionAction<GSSCredential> action = new PrivilegedExceptionAction<GSSCredential>() {
        public GSSCredential run() throws GSSException {
            return gssManager.createCredential(null, GSSCredential.INDEFINITE_LIFETIME,
                    GSSUtil.GSS_SPNEGO_MECH_OID, GSSCredential.ACCEPT_ONLY);
        }
    };

    if (log.isDebugEnabled()) {
        Set<Principal> principals = subject.getPrincipals();
        String principalName = null;
        if (principals != null) {
            principalName = principals.toString();
        }
        log.debug("Creating gss credentials as principal : " + principalName);
    }
    return Subject.doAs(subject, action);
}

From source file:com.dell.asm.asmcore.asmmanager.util.DeviceGroupUtil.java

/**
 * Validate Users/*from   w ww .  j av a 2  s .  co  m*/
 * 
 * @param entity - device group entity to be validated
 * 
 * @throws AsmManagerCheckedException
 */
public static void validateUserObject(DeviceGroupEntity entity) throws AsmManagerCheckedException {

    Set<Long> invalidUserIds = invalidGroupUserIds(entity);

    if (invalidUserIds.size() > 0) {
        throw new AsmManagerCheckedException(AsmManagerCheckedException.REASON_CODE.INVALID_ID,
                AsmManagerMessages.userIdsNotFound(invalidUserIds.toString()));
    }

}

From source file:org.jenkinsci.constant_pool_scanner.ConstantPoolScannerTest.java

private static void assertDependencies(Class<?> from, Class<?>... to) throws IOException {
    Set<String> expected = new TreeSet<String>();
    for (Class<?> c : to) {
        expected.add(c.getName());/*  w  ww .  j a v a2s .  c  o  m*/
    }
    expected.add(from.getName());
    byte[] bytecode = IOUtils.toByteArray(
            from.getClassLoader().getResourceAsStream(from.getName().replace('.', '/') + ".class"));
    Set<String> actual = ConstantPoolScanner.dependencies(bytecode);
    assertEquals(expected.toString(), actual.toString());
}