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:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.evaluation.phrasematch.PhraseMatchEvaluator.java

@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {

    getContext().getLogger().log(Level.CONFIG, "Entering " + getClass().getSimpleName());

    String documentBaseName = getDocumentBaseName(jcas);
    Set<String> goldSet = getGoldSet(jcas);
    goldCount = goldSet.size();//from   w w  w.  j  a  va  2  s .  co  m
    List<Integer> truePositiveCounts = new ArrayList<Integer>();

    List<String> phrases = getRetrievedPhrases(jcas);

    for (String phrase : phrases) {

        // a phrase can cover 0 - n gold items
        final Set<String> coveredGoldPhrases = matchingStrategy.getCovered(phrase, goldSet);
        truePositiveCounts.add(coveredGoldPhrases.size());

        if (getContext().getLogger().isLoggable(Level.FINEST)) {
            getContext().getLogger().log(Level.FINEST, String.format("Phrase [%s] covered gold phrases: %s",
                    phrase, coveredGoldPhrases.toString()));
        }

        // every gold phrase can be matched only once, such that 0 - n phrases
        // match 0 - 1 gold items
        for (String coveredGoldPhrase : coveredGoldPhrases) {
            goldSet.remove(coveredGoldPhrase);
        }
    }

    // store the result of each document
    DocumentPerformanceResult result = new DocumentPerformanceResult(documentBaseName, truePositiveCounts,
            goldCount);
    documentPerformanceResults.add(result);

    handleDocumentResult(result, phrases);

    if (getContext().getLogger().isLoggable(Level.INFO)) {
        logPhrasesAndGoldSet(jcas, documentBaseName, truePositiveCounts, phrases);
    }
}

From source file:org.apache.maven.index.FullIndexNexusIndexerTest.java

public void testMissingPom() throws Exception {
    Query q = nexusIndexer.constructQuery(MAVEN.ARTIFACT_ID, "missingpom", SearchType.SCORED);

    FlatSearchRequest searchRequest = new FlatSearchRequest(q);

    FlatSearchResponse response = nexusIndexer.searchFlat(searchRequest);

    Set<ArtifactInfo> r = response.getResults();

    assertEquals(r.toString(), 1, r.size());

    ArtifactInfo ai = r.iterator().next();

    assertEquals("missingpom", ai.getGroupId());
    assertEquals("missingpom", ai.getArtifactId());
    assertEquals("1.0", ai.getVersion());
    // See Nexus 2318. It should be null for a jar without classes
    assertNull(ai.getClassNames());//  www  .  j av a 2 s  . co m
}

From source file:org.openmainframe.ade.main.Train.java

@Override
protected void parseArgs(String[] args) throws AdeException {
    final Option helpOpt = new Option("h", "help", false, "Print help message and exit");

    OptionBuilder.withLongOpt(ALL_OPT);/*from  ww w  . j av  a 2s.com*/
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("All analysis groups");
    final Option allAnalysisGroupsOpt = OptionBuilder.create('a');

    OptionBuilder.withLongOpt(GROUPS_OPT);
    OptionBuilder.withArgName("ANALYSIs GROUPS");
    OptionBuilder.hasArgs();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Selected analysis groups");
    final Option selectAnalysisGroupsOpt = OptionBuilder.create('s');

    final OptionGroup inputAnalysisGroupsOptGroup = new OptionGroup().addOption(allAnalysisGroupsOpt)
            .addOption(selectAnalysisGroupsOpt);
    inputAnalysisGroupsOptGroup.setRequired(true);

    OptionBuilder.withLongOpt(UNSELECT_OPT);
    OptionBuilder.withArgName("ANALYSIS GROUPS");
    OptionBuilder.hasArgs();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Unselect analysis groups. Used only with '" + ALL_OPT + "'");
    final Option unselectAnalysisGroupsOpt = OptionBuilder.create('u');

    OptionBuilder.withLongOpt(DURATION_OPT);
    OptionBuilder.withArgName("DURATION (ISO 8601)");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "Duration from/to start/end date. Defaults to infinity. Replaces either 'start-date' or 'end-date'");
    final Option periodOpt = OptionBuilder.create();

    OptionBuilder.withLongOpt(NUM_DAYS_OPT);
    OptionBuilder.withArgName("INT");
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Number of days. same as '" + DURATION_OPT + "'");
    final Option numDaysOpt = OptionBuilder.create('n');

    final OptionGroup periodOptGroup = new OptionGroup().addOption(periodOpt).addOption(numDaysOpt);

    OptionBuilder.withLongOpt(START_DATE_OPT);
    OptionBuilder.withArgName("MM/dd/yyyy[ HH:mm][ Z]");
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription(
            "Start of date range. Optional. Replaces 'duration'/'num-days' when used along with 'end-date'");
    final Option startDateOpt = OptionBuilder.create();

    OptionBuilder.withLongOpt(END_DATE_OPT);
    OptionBuilder.withArgName("MM/dd/yyyy[ HH:mm][ Z]");
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder
            .withDescription("End of date range. Defaults to this moment. Replaces 'duration'/'num-days' when"
                    + " used along with 'start-date'");
    final Option endDateOpt = OptionBuilder.create();

    final Options options = new Options();
    options.addOption(helpOpt);
    options.addOptionGroup(inputAnalysisGroupsOptGroup);
    options.addOption(unselectAnalysisGroupsOpt);
    options.addOptionGroup(periodOptGroup);
    options.addOption(endDateOpt);
    options.addOption(startDateOpt);

    final CommandLineParser parser = new GnuParser();
    CommandLine line;

    try {
        // parse the command line arguments
        line = parser.parse(options, args);
    } catch (MissingOptionException exp) {
        new HelpFormatter().printHelp(HELP + "\nOptions:", options);
        throw new AdeUsageException("Command line parsing failed", exp);
    } catch (ParseException exp) {
        // oops, something went wrong
        throw new AdeUsageException("Argument Parsing failed", exp);
    }

    if (line.hasOption(helpOpt.getLongOpt())) {
        new HelpFormatter().printHelp(HELP, options);
        closeAll();
        System.exit(0);
    }

    if (line.hasOption(UNSELECT_OPT) && !line.hasOption(ALL_OPT)) {
        throw new AdeUsageException("'" + UNSELECT_OPT + "' cannot be used without '" + ALL_OPT + "'");
    }

    final Set<Integer> allAnalysisGroups = Ade.getAde().getDataStore().sources().getAllAnalysisGroups();
    if (line.hasOption(ALL_OPT)) {
        System.out.println("Operating on all available analysis groups");
        if (!line.hasOption(UNSELECT_OPT)) {
            m_analysisGroups = allAnalysisGroups;
        } else {
            final Set<Integer> unselectedAnalysisGroups = parseAnalysisGroups(allAnalysisGroups,
                    line.getOptionValues(UNSELECT_OPT));
            final Set<String> unselectedGroupNames = getGroupNames(unselectedAnalysisGroups);
            System.out.println("Omitting analysis groups: " + unselectedGroupNames.toString());
            m_analysisGroups = new TreeSet<Integer>(allAnalysisGroups);
            m_analysisGroups.removeAll(unselectedAnalysisGroups);
        }
    } else if (line.hasOption(GROUPS_OPT)) {
        m_analysisGroups = parseAnalysisGroups(allAnalysisGroups, line.getOptionValues(GROUPS_OPT));
        final Set<String> operatingAnalysisGroups = getGroupNames(m_analysisGroups);
        System.out.println("Operating on analysis groups: " + operatingAnalysisGroups.toString());
    }

    if ((line.hasOption(NUM_DAYS_OPT) || line.hasOption(DURATION_OPT)) && line.hasOption(START_DATE_OPT)
            && line.hasOption(END_DATE_OPT)) {
        throw new AdeUsageException("Cannot use '" + DURATION_OPT + "'/'" + NUM_DAYS_OPT + "', '"
                + START_DATE_OPT + "' and '" + END_DATE_OPT + "' together");
    }
    if (line.hasOption(NUM_DAYS_OPT)) {
        final String numDaysStr = line.getOptionValue(NUM_DAYS_OPT);
        final int numDays = Integer.parseInt(numDaysStr);
        this.m_period = Period.days(numDays);
    }
    if (line.hasOption(DURATION_OPT)) {
        final String periodStr = line.getOptionValue(DURATION_OPT);
        this.m_period = ISOPeriodFormat.standard().parsePeriod(periodStr);
    }
    if (line.hasOption(START_DATE_OPT)) {
        m_startDate = parseDate(line.getOptionValue(START_DATE_OPT));
    }
    if (line.hasOption(END_DATE_OPT)) {
        m_endDate = parseDate(line.getOptionValue(END_DATE_OPT));
    }
}

From source file:org.apache.fop.render.pdf.PDFBoxAdapterTestCase.java

@Test
public void testType1Subset() throws Exception {
    PDDocument doc = getResource(Type1Subset1);
    FOPPDFSingleByteFont mbfont = new FOPPDFSingleByteFont(getFont(doc, "F15"), "");
    mbfont.addFont(getFont(doc, "F15"));
    PDDocument doc2 = getResource(Type1Subset2);
    mbfont.addFont(getFont(doc2, "F15"));
    Type1Font f = Type1Font.createWithPFB(mbfont.getInputStream());
    Set<String> csDict = new TreeSet<String>(f.getCharStringsDict().keySet());
    Assert.assertEquals(csDict.toString(), "[.notdef, a, d, e, hyphen, l, m, n, p, s, space, t, two, x]");
    Assert.assertEquals(f.getSubrsArray().size(), 518);
    Assert.assertEquals(f.getFamilyName(), "Verdana");
    doc.close();/*from  www  . j  ava  2s . co  m*/
    doc2.close();
}

From source file:net.webpasswordsafe.server.service.LoginServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
public Map<Function, Boolean> getLoginAuthorizations(Set<Function> functions) {
    LOG.debug("inside getLoginAuthorizations");
    User loggedInUser = getLogin();//  w w w .  jav a  2 s . co m
    // if passed null, load everything
    if (null == functions) {
        LOG.debug("functions was passed null");
        functions = new HashSet<Function>(Arrays.asList(Function.values()));
    }
    LOG.debug("functions=" + functions.toString());
    Map<Function, Boolean> authzMap = new HashMap<Function, Boolean>(functions.size());
    for (Function function : functions) {
        authzMap.put(function, authorizer.isAuthorized(loggedInUser, function.name()));
    }
    LOG.debug("authzMap=" + authzMap.toString());
    return authzMap;
}

From source file:eu.juniper.MonitoringLib.java

private ArrayList<String> readJson(ArrayList<String> elementsList, JSONObject jsonObject, PrintWriter writer,
        String TagName) throws FileNotFoundException, IOException, ParseException {
    String appId = "";
    if (jsonObject.get(TagName) == null) {
        elementsList.add("null");
    } else {/*from  w w  w .  j av  a 2 s  .  c om*/
        String Objectscontent = jsonObject.get(TagName).toString();
        if (Objectscontent.startsWith("[{") && Objectscontent.endsWith("}]")) {
            JSONArray jsonArray = (JSONArray) jsonObject.get(TagName);

            for (int temp = 0; temp < jsonArray.size(); temp++) {
                System.out.println("Array:" + jsonArray.toJSONString());
                JSONObject jsonObjectResult = (JSONObject) jsonArray.get(temp);
                System.out.println("Result:" + jsonObjectResult.toJSONString());

                Set<String> jsonObjectResultKeySet = jsonObjectResult.keySet();
                System.out.println("KeySet:" + jsonObjectResultKeySet.toString());

                for (String s : jsonObjectResultKeySet) {
                    System.out.println(s);
                    readJson(elementsList, jsonObjectResult, writer, s);
                }
            }
        } else {
            appId = jsonObject.get(TagName).toString();
            elementsList.add(appId);
        }
    }
    return elementsList;
}

From source file:de.zib.vold.client.VolDClient.java

/**
 * Delete a set of keys./*from w  ww .  ja va  2  s. c  o  m*/
 *
 * @param source The source of the keys to delete.
 * @param set The set of keys to delete.
 */
@Override
public void delete(String source, Set<Key> set) {
    // guard
    {
        log.trace("Delete: " + set.toString());

        checkState();

        if (null == set) {
            throw new IllegalArgumentException("null is no valid argument!");
        }
    }

    // build greatest common scope
    String commonscope;
    {
        List<String> scopes = new ArrayList<String>(set.size());

        for (Key k : set) {
            scopes.add(k.get_scope());
        }

        commonscope = getGreatestCommonPrefix(scopes);
    }

    // build request body
    Set<Key> keys = new HashSet<Key>();
    {
        for (Key entry : set) {
            // remove common prefix from scope
            String scope = entry.get_scope().substring(commonscope.length());
            String type = entry.get_type();
            String keyname = entry.get_keyname();

            keys.add(new Key(scope, type, keyname));
        }
    }

    // build variable map
    String url;
    {
        url = buildURL(commonscope, keys);
        log.debug("DELETE URL: " + url);
    }

    rest.delete(url, HashMap.class);
}

From source file:com.abixen.platform.service.businessintelligence.multivisualization.service.impl.AbstractDatabaseService.java

private String buildQueryForChartData(DatabaseDataSource databaseDataSource, Set<String> chartColumnsSet,
        ResultSetMetaData resultSetMetaData, ChartConfigurationForm chartConfigurationForm)
        throws SQLException {
    StringBuilder outerSelect = new StringBuilder("SELECT ");
    outerSelect.append("subQueryResult."
            + chartColumnsSet.toString().substring(1, chartColumnsSet.toString().length() - 1));
    outerSelect.append(" FROM (");
    outerSelect.append(buildQueryForDataSourceData(databaseDataSource, chartColumnsSet, resultSetMetaData));
    outerSelect.append(") subQueryResult WHERE ");
    outerSelect/*from   w  w w  . j  a v a  2  s .c  o m*/
            .append(jsonFilterService.convertJsonToJpql(chartConfigurationForm.getFilter(), resultSetMetaData));
    return outerSelect.toString();
}

From source file:com.vmware.bdd.plugin.clouderamgr.service.CmClusterValidator.java

private boolean checkRequiredRoles(String serviceName, Set<String> requiredRoles, Set<String> definedRoles,
        List<String> errorMsgList) {
    requiredRoles.removeAll(definedRoles);
    if (!requiredRoles.isEmpty()) {
        errorMsgList.add("Service " + serviceName + " requires roles " + requiredRoles.toString());
        return false;
    }/*  www  .  jav a2s . co  m*/
    return true;
}