Example usage for java.util List toString

List of usage examples for java.util List toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.crce.interns.dao.impl.SendEmailDAOImpl.java

/**
 * // w  ww  . j  a  v  a2  s . c o m
 * @param companyName
 * @return String
 */

@Override
public String fetchCompanyStudents(String companyName) {

    String senderList = "";
    Session session = sessionFactory.openSession();
    String SQL_QUERY = "Select company_id from Company where lower(company_name) like '" + companyName + "'";
    Query query = session.createQuery(SQL_QUERY);
    List list = query.list();
    System.out.println("List " + list.toString());
    for (Object j : list) {
        System.out.println("called for j");
        String SQL_QUERY1 = "Select username from QuickStats where company_id = "
                + Integer.parseInt(j.toString()) + "and year like '"
                + Integer.toString(Calendar.getInstance().get(Calendar.YEAR)) + "'";
        Query query1 = session.createQuery(SQL_QUERY1);
        List list1 = query1.list();
        System.out.println(list1.toString());
        //String recipient = list1.toString();
        for (Object i : list1) {
            System.out.println("called for i");
            String SQL_QUERY2 = "Select emailId from PersonalProfile where userName like '" + i + "'";
            Query query2 = session.createQuery(SQL_QUERY2);
            List list2 = query2.list();
            System.out.println(list2.toString());
            String recipient = list2.toString();
            System.out.println(recipient);
            //String recipient = "Single" + o.toString() + "@gmail.com";
            senderList = senderList.concat(recipient + " ");
        }
    }
    System.out.println(senderList);
    return senderList;
}

From source file:org.auraframework.test.source.StringSourceExternalLoader.java

@SuppressWarnings("unchecked")
private Object invokeAction(String qualifiedName, Map<String, Object> actionParams)
        throws AuraExecutionException {
    try {/*ww w .  j a  va  2 s.  c o  m*/
        HttpPost post = getPostMethod(qualifiedName, actionParams);
        HttpResponse response = testServletConfig.getHttpClient().execute(post);
        assert HttpStatus.SC_OK == response.getStatusLine().getStatusCode();

        HttpEntity entity = response.getEntity();
        String rawResponse = entity == null ? null : EntityUtils.toString(entity);
        assert AuraBaseServlet.CSRF_PROTECT
                .equals(rawResponse.substring(0, AuraBaseServlet.CSRF_PROTECT.length()));

        if (rawResponse.endsWith("/*ERROR*/")) {
            throw new AuraExecutionException("Error response:" + rawResponse, null);
        }
        Map<String, Object> json = (Map<String, Object>) new JsonReader()
                .read(rawResponse.substring(AuraBaseServlet.CSRF_PROTECT.length()));
        ArrayList<Map<String, Object>> actions = (ArrayList<Map<String, Object>>) json.get("actions");
        assert 1 == actions.size();
        Map<String, Object> action = (Map<String, Object>) ((List<Object>) json.get("actions")).get(0);
        List<Object> errors = (List<Object>) action.get("error");
        if (errors != null && errors.size() > 0) {
            throw new AuraExecutionException(errors.toString(), null);
        }
        assert "SUCCESS".equals(action.get("state"));
        return action.get("returnValue");

    } catch (Exception e) {
        throw new AuraExecutionException(e, null);
    }
}

From source file:edu.jhuapl.dorset.agents.StockAgent.java

protected JsonObject processData(String json, String keyWordCompanyName) {

    Gson gson = new Gson();
    JsonObject returnObj = new JsonObject();
    JsonObject jsonObj = gson.fromJson(json, JsonObject.class);

    if (jsonObj != null) {

        if ((jsonObj.get("dataset")) != null) {
            JsonArray jsonDataArray = (JsonArray) (((JsonObject) jsonObj.get("dataset")).get("data"));

            ArrayList<JsonElement> responseDataArrayList = new ArrayList<>();
            ArrayList<JsonElement> responseLabelsArrayList = new ArrayList<>();

            for (int i = 0; i < jsonDataArray.size(); i++) {
                JsonArray jsonDataArrayNested = (JsonArray) (jsonDataArray.get(i));
                responseDataArrayList.add(jsonDataArrayNested.get(4));
                responseLabelsArrayList.add(jsonDataArrayNested.get(0));
            }/*from   w  w  w .ja v  a2 s.  c  o  m*/
            Collections.reverse(responseDataArrayList);
            Collections.reverse(responseLabelsArrayList);

            List<JsonElement> returnDataJsonList = responseDataArrayList
                    .subList(responseDataArrayList.size() - DAYS_IN_A_MONTH, responseDataArrayList.size());

            JsonArray returnDataJsonListStr = new JsonArray();
            for (int i = 0; i < returnDataJsonList.size(); i++) {
                returnDataJsonListStr.add(returnDataJsonList.get(i));
            }

            JsonObject jsonData = new JsonObject();
            jsonData.add(keyWordCompanyName, returnDataJsonListStr);

            returnObj.addProperty("data", jsonData.toString());

            List<JsonElement> returnLabelsJsonList = responseLabelsArrayList
                    .subList(responseLabelsArrayList.size() - DAYS_IN_A_MONTH, responseLabelsArrayList.size());

            returnObj.addProperty("labels", returnLabelsJsonList.toString());

            returnObj.addProperty("title", keyWordCompanyName + " Stock Ticker");
            returnObj.addProperty("xaxis", "Day");
            returnObj.addProperty("yaxis", "Close of day market price ($)");
            returnObj.addProperty("plotType", "lineplot");

        }

    }

    return returnObj;
}

From source file:info.novatec.testit.livingdoc.interpreter.collection.CollectionInterpreter.java

protected List<Fixture> getFixtureList()
        throws IllegalArgumentException, InvocationTargetException, IllegalAccessException {
    LOG.debug(ENTRY);/*from ww  w .  ja  v a  2s  . c om*/
    List<?> results = getCollectionProvider();

    if (results == null) {
        results = toList(fixture.getTarget());
    }

    if (results == null) {
        Call query = new Call(fixture.check("query"));
        results = toList(query.execute());
    }

    if (results == null) {
        throw new IllegalArgumentException("results parameter is neither an Object[] nor a Collection");
    }

    List<Fixture> fixtures = new ArrayList<Fixture>();
    for (Object object : results) {
        fixtures.add(fixture.fixtureFor(object));
    }

    LOG.debug(EXIT_WITH, fixtures.toString());
    return fixtures;
}

From source file:com.google.code.joliratools.bind.apt.JAXROProcessorJSONTest.java

/**
 * Test the process with the -Ajaxroproc= parameters.
 * // w  w  w. j a  v  a2s  .  co  m
 * @throws Exception
 *             something failed
 */
@Test
public void testProcessInvalidProc() throws Exception {
    final Compilation compilation = createCompilation();

    compilation.doCompile(new PrintWriter(System.out), "-Ajaxroproc=jfk");

    final List<Diagnostic<? extends JavaFileObject>> diagnostics = compilation.getDiagnostics();

    assertEquals(diagnostics.toString(), 2, diagnostics.size());
}

From source file:com.google.code.joliratools.bind.apt.JAXROProcessorJSONTest.java

/**
 * Test the process with the -Ajaxroproc= parameters.
 * /*from   w  w w .ja  v a2 s .co m*/
 * @throws Exception
 *             something failed
 */
@Test
public void testProcessProcNone() throws Exception {
    final Compilation compilation = createCompilation();

    compilation.doCompile(new PrintWriter(System.out), "-Ajaxroproc=none");

    final List<Diagnostic<? extends JavaFileObject>> diagnostics = compilation.getDiagnostics();

    assertEquals(diagnostics.toString(), 1, diagnostics.size());
}

From source file:com.vmware.photon.controller.api.frontend.backends.TenantXenonBackend.java

@Override
public TaskEntity prepareSetSecurityGroups(String id, List<String> securityGroups) throws ExternalException {

    logger.info("Updating the security groups of tenant {} to {}", id, securityGroups.toString());

    TenantEntity tenantEntity = findById(id);
    List<SecurityGroup> currSecurityGroups = new ArrayList<>();
    for (SecurityGroupEntity groupEntity : tenantEntity.getSecurityGroups()) {
        currSecurityGroups.add(new SecurityGroup(groupEntity.getName(), groupEntity.isInherited()));
    }/* w ww . j a va  2  s  .c  o  m*/
    Pair<List<SecurityGroup>, List<String>> result = SecurityGroupUtils
            .mergeSelfSecurityGroups(currSecurityGroups, securityGroups);

    tenantEntity.setSecurityGroups(result.getLeft().stream()
            .map(g -> new SecurityGroupEntity(g.getName(), g.isInherited())).collect(Collectors.toList()));

    TaskEntity taskEntity = taskBackend.createQueuedTask(tenantEntity, Operation.SET_TENANT_SECURITY_GROUPS);

    StepEntity stepEntity = taskBackend.getStepBackend().createQueuedStep(taskEntity, tenantEntity,
            Operation.SET_TENANT_SECURITY_GROUPS);
    if (!result.getRight().isEmpty()) {
        stepEntity.addWarning(new SecurityGroupsAlreadyInheritedException(result.getRight()));
    }

    taskBackend.getStepBackend().createQueuedStep(taskEntity, tenantEntity,
            Operation.PUSH_TENANT_SECURITY_GROUPS);

    return taskEntity;
}

From source file:it.unibas.spicy.persistence.xml.operators.LoadXMLFile.java

private INode findNodeInSchema(List<String> pathSteps) {
    if (logger.isTraceEnabled())
        logger.debug("Searching schema node: " + pathSteps);
    //TODO: check efficiency of caching
    INode node = nodeMap.get(pathSteps.toString());
    if (node == null) {
        if (logger.isTraceEnabled())
            logger.debug("Node not found in cache. Searching...");
        FindNodeFromPathWithVirtualNodes nodeFinder = new FindNodeFromPathWithVirtualNodes();
        node = nodeFinder.findNodeInSchema(dataSource.getIntermediateSchema(), pathSteps);
    }/*  w ww. j  a v a  2 s.  co  m*/
    if (node != null) {
        if (logger.isTraceEnabled())
            logger.debug("Result: " + node.getLabel());
        nodeMap.put(pathSteps.toString(), node);
    }
    return node;
}

From source file:net.sf.jtmt.clustering.KMeansClusterer.java

/**
 * Cluster.//w w  w. j a v  a 2s  .  co  m
 *
 * @param collection the collection
 * @return the list
 */
public List<Cluster> cluster(DocumentCollection collection) {
    int numDocs = collection.size();
    int numClusters = 0;
    if (initialClusterAssignments == null) {
        // compute initial cluster assignments
        IdGenerator idGenerator = new IdGenerator(numDocs);
        numClusters = (int) Math.floor(Math.sqrt(numDocs));
        initialClusterAssignments = new String[numClusters];
        for (int i = 0; i < numClusters; i++) {
            int docId = idGenerator.getNextId();
            initialClusterAssignments[i] = collection.getDocumentNameAt(docId);
        }
    } else {
        numClusters = initialClusterAssignments.length;
    }

    // build initial clusters
    List<Cluster> clusters = new ArrayList<Cluster>();
    for (int i = 0; i < numClusters; i++) {
        Cluster cluster = new Cluster("C" + i);
        cluster.addDocument(initialClusterAssignments[i], collection.getDocument(initialClusterAssignments[i]));
        clusters.add(cluster);
    }
    log.debug("..Initial clusters:" + clusters.toString());

    List<Cluster> prevClusters = new ArrayList<Cluster>();

    // Repeat until termination conditions are satisfied
    for (;;) {
        // For every cluster i, (re-)compute the centroid based on the
        // current member documents. (We have moved 2.2 above 2.1 because
        // this needs to be done before every iteration).
        RealMatrix[] centroids = new RealMatrix[numClusters];
        for (int i = 0; i < numClusters; i++) {
            RealMatrix centroid = clusters.get(i).getCentroid();
            centroids[i] = centroid;
        }
        // For every document d, find the cluster i whose centroid is 
        // most similar, assign d to cluster i. (If a document is 
        // equally similar from all centroids, then just dump it into 
        // cluster 0).
        for (int i = 0; i < numDocs; i++) {
            int bestCluster = 0;
            double maxSimilarity = Double.MIN_VALUE;
            RealMatrix document = collection.getDocumentAt(i);
            String docName = collection.getDocumentNameAt(i);
            for (int j = 0; j < numClusters; j++) {
                double similarity = clusters.get(j).getSimilarity(document);
                if (similarity > maxSimilarity) {
                    bestCluster = j;
                    maxSimilarity = similarity;
                }
            }
            for (Cluster cluster : clusters) {
                if (cluster.getDocument(docName) != null) {
                    cluster.removeDocument(docName);
                }
            }
            clusters.get(bestCluster).addDocument(docName, document);
        }
        log.debug("..Intermediate clusters: " + clusters.toString());

        // Check for termination -- minimal or no change to the assignment
        // of documents to clusters.
        if (CollectionUtils.isEqualCollection(clusters, prevClusters)) {
            break;
        }
        prevClusters.clear();
        prevClusters.addAll(clusters);
    }
    // Return list of clusters
    log.debug("..Final clusters: " + clusters.toString());
    return clusters;
}

From source file:org.oncoblocks.centromere.web.controller.RequestUtils.java

/**
 * Extracts request parameters and matches them to available database query parameters, as defined
 *   in the {@code model} class definition.
 *
 * @param request {@link HttpServletRequest}
 * @return/*from  w w  w  .j av  a2 s.c  o  m*/
 */
public static List<QueryCriteria> getQueryCriteriaFromRequest(Class<? extends Model<?>> model,
        HttpServletRequest request) {
    logger.info(String.format("Generating QueryCriteria for request parameters: model=%s params=%s",
            model.getName(), request.getQueryString()));
    List<QueryCriteria> criteriaList = new ArrayList<>();
    Map<String, QueryParameterDescriptor> paramMap = getAvailableQueryParameters(model);
    for (Map.Entry entry : request.getParameterMap().entrySet()) {
        String paramName = (String) entry.getKey();
        String[] paramValue = ((String[]) entry.getValue())[0].split(",");
        if (!excludedParameters.contains(paramName)) {
            if (paramMap.containsKey(paramName)) {
                QueryParameterDescriptor descriptor = paramMap.get(paramName);
                QueryCriteria criteria = createCriteriaFromRequestParameter(descriptor.getFieldName(),
                        paramValue, descriptor.getType(), descriptor.getEvaluation());
                criteriaList.add(criteria);
            } else {
                logger.warn(String.format("Unable to map request parameter to available model parameters: %s",
                        paramName));
                throw new InvalidParameterException("Invalid request parameter: " + paramName);
            }
        }
    }
    logger.info(String.format("Generated QueryCriteria for request: %s", criteriaList.toString()));
    return criteriaList;
}