Example usage for java.util Collection toString

List of usage examples for java.util Collection toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:ubic.BAMSandAllen.MatrixPairs.ConnectivityLiteratureMatrixPair.java

public ConnectivityLiteratureMatrixPair(Direction direction) throws Exception {
    super(Nomenclature.BAMS);

    // allenCatalog = new StructureCatalogLoader();
    squareConnectivity = false;/*from w  ww.j ava  2s . c o  m*/
    this.direction = direction;
    BrainRegionClassSelector selector = new BrainRegionClassSelector();

    if (squareConnectivity && direction.equals(Direction.APPENDED)) {
        throw new RuntimeException("Error square matrix incompatable with appended connectivity");
    }
    StructureCatalogAnalyze forMatrix = new StructureCatalogAnalyze(selector);
    // could be an option here for propigated or non-propigated connection matrix
    forMatrix.readModel(SetupParameters.getDataFolder() + "Propigated.rdf");

    DoubleMatrix<String, String> dataMatrix = forMatrix.makeConnectionMatrix(direction);

    matrixA = new ABAMSDataMatrix(dataMatrix, "Connectivity", new CorrelationAdjacency(dataMatrix));

    // get Allen leaf regions and convert them to BAMS regions
    StructureCatalogLoader loader = new StructureCatalogLoader();
    Collection<String> leafsABA = loader.getLeafs();
    Collection<String> leafsBAMS = new HashSet<String>();
    for (String leafABA : leafsABA) {
        leafsBAMS.addAll(loader.getBAMSMappedRegions(leafABA));
    }

    // remove the non leaf nodes
    Collection<String> nonLeafs = (Collection<String>) Util.subtract(matrixA.getColNames(), leafsBAMS);
    log.info("Removing " + nonLeafs.size() + " regions " + nonLeafs.toString());
    matrixA = matrixA.removeColumns(nonLeafs);

    // log.info( "Removing bed Nuclei Stria" );
    // removeBedNucleiStria();

    // matrixA = matrixA.removeRows( Util.findZeroRows( matrixA ) );

    matrixA = matrixA.removeZeroColumns();
    matrixB = matrixB.removeZeroColumns();

    log.info("got Matrix A - connections");
}

From source file:org.apache.james.smtpserver.SendMailHandler.java

/**
 * Adds header to the message//from   w ww.j  av  a2  s.  com
 *
 */
public HookResult onMessage(SMTPSession session, Mail mail) {

    session.getLogger().debug("sending mail");

    try {
        queue.enQueue(mail);
        Collection<MailAddress> theRecipients = mail.getRecipients();
        String recipientString = "";
        if (theRecipients != null) {
            recipientString = theRecipients.toString();
        }
        if (session.getLogger().isInfoEnabled()) {
            String infoBuffer = "Successfully spooled mail " + mail.getName() + " from " + mail.getSender()
                    + " on " + session.getRemoteAddress().getAddress().toString() + " for " + recipientString;
            session.getLogger().info(infoBuffer.toString());
        }
    } catch (MessagingException me) {
        session.getLogger().error("Unknown error occurred while processing DATA.", me);
        return new HookResult(HookReturnCode.DENYSOFT,
                DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.UNDEFINED_STATUS)
                        + " Error processing message.");
    }

    return new HookResult(HookReturnCode.OK,
            DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.CONTENT_OTHER) + " Message received");

}

From source file:org.codehaus.mojo.latex.LaTeXMojo.java

private boolean requiresBuilding(File dir, File pdfFile) throws IOException {
    Collection texFiles = FileUtils.listFiles(dir, new String[] { "tex", "bib" }, true);
    getLog().info(texFiles.toString());
    if (pdfFile.exists()) {
        boolean upToDate = true;
        Iterator it = texFiles.iterator();
        while (it.hasNext() && upToDate) {
            File file = (File) it.next();
            if (FileUtils.isFileNewer(file, pdfFile)) {
                if (getLog().isInfoEnabled()) {
                    getLog().info("Changes detected on " + file.getAbsolutePath());
                }//from  w  w  w  .jav  a 2s  .c om
                return true;
            }
            if (getLog().isInfoEnabled()) {
                getLog().info("No change detected on " + file.getAbsolutePath());
            }
        }
        if (getLog().isInfoEnabled()) {
            getLog().info("Skipping: no LaTeX changes detected in " + dir.getCanonicalPath());
        }
        return false;
    } else {
        return true;
    }
}

From source file:org.apache.solr.handler.XmlUpdateRequestHandlerTest.java

@Test
public void testReadDoc() throws Exception {
    String xml = "<doc boost=\"5.5\">" + "  <field name=\"id\" boost=\"2.2\">12345</field>"
            + "  <field name=\"name\">kitten</field>" + "  <field name=\"cat\" boost=\"3\">aaa</field>"
            + "  <field name=\"cat\" boost=\"4\">bbb</field>" + "  <field name=\"cat\" boost=\"5\">bbb</field>"
            + "  <field name=\"ab\">a&amp;b</field>" + "</doc>";

    XMLStreamReader parser = inputFactory.createXMLStreamReader(new StringReader(xml));
    parser.next(); // read the START document...
    //null for the processor is all right here
    XMLLoader loader = new XMLLoader();
    SolrInputDocument doc = loader.readDoc(parser);

    // Read boosts
    assertEquals(5.5f, doc.getDocumentBoost(), 0.1);
    assertEquals(1.0f, doc.getField("name").getBoost(), 0.1);
    assertEquals(2.2f, doc.getField("id").getBoost(), 0.1);
    // Boost is the product of each value
    assertEquals((3 * 4 * 5.0f), doc.getField("cat").getBoost(), 0.1);

    // Read values
    assertEquals("12345", doc.getField("id").getValue());
    assertEquals("kitten", doc.getField("name").getValue());
    assertEquals("a&b", doc.getField("ab").getValue()); // read something with escaped characters

    Collection<Object> out = doc.getField("cat").getValues();
    assertEquals(3, out.size());// w ww  . ja  v a 2 s  .com
    assertEquals("[aaa, bbb, bbb]", out.toString());
}

From source file:org.apache.atlas.repository.graph.GraphHelper.java

public static String vertexString(final AtlasVertex vertex) {
    StringBuilder properties = new StringBuilder();
    for (String propertyKey : vertex.getPropertyKeys()) {
        Collection<?> propertyValues = vertex.getPropertyValues(propertyKey, Object.class);
        properties.append(propertyKey).append("=").append(propertyValues.toString()).append(", ");
    }/*from w  w w .j  a v a2s  . c  o m*/

    return "v[" + vertex.getIdForDisplay() + "], Properties[" + properties + "]";
}

From source file:org.apache.solr.client.solrj.request.TestCoreAdmin.java

@Test
public void testValidCoreRename() throws Exception {
    Collection<String> names = cores.getAllCoreNames();
    assertFalse(names.toString(), names.contains("coreRenamed"));
    assertTrue(names.toString(), names.contains("core1"));
    CoreAdminRequest.renameCore("core1", "coreRenamed", getSolrAdmin());
    names = cores.getAllCoreNames();//from   w w w.jav  a2 s  .  co  m
    assertTrue(names.toString(), names.contains("coreRenamed"));
    assertFalse(names.toString(), names.contains("core1"));
    // rename it back
    CoreAdminRequest.renameCore("coreRenamed", "core1", getSolrAdmin());
    names = cores.getAllCoreNames();
    assertFalse(names.toString(), names.contains("coreRenamed"));
    assertTrue(names.toString(), names.contains("core1"));
}

From source file:org.grails.datastore.gorm.neo4j.Neo4jMappingContext.java

/**
 * Finds an entity for the statically mapped set of labels
 *
 * @param labels The labels/*w  w w . j a  v a2s  .  c  o  m*/
 * @return The entity
 * @throws NonPersistentTypeException if no entity is found
 */
public GraphPersistentEntity findPersistentEntityForLabels(Collection<String> labels) {
    final GraphPersistentEntity entity = entitiesByLabel.get(labels);
    if (entity != null) {
        return entity;
    }
    throw new NonPersistentTypeException(labels.toString());
}

From source file:com.fatwire.dta.sscrawler.reporting.reporters.SameContentPageletReporter.java

public synchronized void endCollecting() {
    report.startReport();//from  www  .j  a v  a2 s.com
    report.addHeader("group", "pagename", "suspected parameters", "uri");

    for (final Entry<String, List<QueryString>> e : map.entrySet()) {
        final List<QueryString> l = e.getValue();
        if (l.size() > 1) {
            group++;
            final Collection<String> suspects = getMultiValuedKeys(l);
            for (final QueryString qs : l) {
                report.addRow(Integer.toString(group), qs.getParameters().get(HelperStrings.PAGENAME),
                        suspects.toString(), qs.toString());
            }
        }
    }
    report.finishReport();
}

From source file:test.NonRedundantBackgroundKnowledgeTest.java

@Test
public void testToConstantVariable() {
    RelationalPredicate pred = StateSpec.toRelationalPredicate("(above ?X ?Y)");
    Collection<RelationalArgument> variables = new HashSet<RelationalArgument>();
    String result = sut_.toConstantFormVariable(pred, variables);
    assertEquals(result, "(above ?X&:(<> ?X free) ?Y&:(<> ?Y free ?X))");
    assertEquals(variables.toString(), variables.size(), 2);
    assertTrue(variables.contains(new RelationalArgument("?X")));
    assertTrue(variables.contains(new RelationalArgument("?Y")));

    // Same variables, so no need to test them
    pred = StateSpec.toRelationalPredicate("(on ?X ?)");
    result = sut_.toConstantFormVariable(pred, variables);
    assertEquals(result, "(on ?X free)");
    assertEquals(variables.toString(), variables.size(), 2);
    assertTrue(variables.contains(new RelationalArgument("?X")));
    assertTrue(variables.contains(new RelationalArgument("?Y")));
}

From source file:com.persistent.cloudninja.controller.AuthFilterUtils.java

/**
 * //w  w  w  .  ja v  a  2  s  .c  o  m
 * @param cloudNinjaUser
 * @param cookieName
 * @return
 */
public static Cookie createNewCookieForACSAuthenticatedUser(CloudNinjaUser cloudNinjaUser, String cookieName) {
    Collection<GrantedAuthority> authorities = cloudNinjaUser.getUser().getAuthorities();
    if (authorities != null) {
        GrantedAuthority[] grantedAuthorities = new GrantedAuthority[authorities.size()];
        authorities.toArray(grantedAuthorities);
    }

    StringBuffer sb = new StringBuffer(5);

    sb.append(CloudNinjaConstants.COOKIE_TENANTID_PREFIX)
            .append(CloudNinjaConstants.COOKIE_FIELD_AND_VALUE_SEPARATOR).append(cloudNinjaUser.getTenantId())
            .append(CloudNinjaConstants.COOKIE_FIELDS_SEPARATOR);

    sb.append(CloudNinjaConstants.COOKIE_USERNAME_PREFIX)
            .append(CloudNinjaConstants.COOKIE_FIELD_AND_VALUE_SEPARATOR)
            .append(cloudNinjaUser.getUser().getUsername()).append(CloudNinjaConstants.COOKIE_FIELDS_SEPARATOR);

    sb.append(CloudNinjaConstants.COOKIE_AUTHORITIES_PREFIX)
            .append(CloudNinjaConstants.COOKIE_FIELD_AND_VALUE_SEPARATOR).append(authorities.toString())
            .append(CloudNinjaConstants.COOKIE_FIELDS_SEPARATOR);

    sb.append(CloudNinjaConstants.COOKIE_AUTH_SESSION_START_PREFIX)
            .append(CloudNinjaConstants.COOKIE_FIELD_AND_VALUE_SEPARATOR)
            .append(cloudNinjaUser.getAuthenticatedSessionStartTime().getTime())
            .append(CloudNinjaConstants.COOKIE_FIELDS_SEPARATOR);

    sb.append(CloudNinjaConstants.COOKIE_AUTH_SESSION_END_PREFIX)
            .append(CloudNinjaConstants.COOKIE_FIELD_AND_VALUE_SEPARATOR)
            .append(cloudNinjaUser.getAuthenticatedSessionExpiryTime().getTime())
            .append(CloudNinjaConstants.COOKIE_FIELDS_SEPARATOR);

    String newCookieValue = sb.toString();

    Cookie newCookie = new Cookie(cookieName, newCookieValue);
    newCookie.setPath("/");
    return newCookie;
}