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:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SparqlEvaluateVTwo.java

public Map<String, List<Literal>> sparqlEvaluateForLiterals(EditConfigurationVTwo editConfig,
        Map<String, String> varToSparql) {
    Map<String, List<String>> uriScope = editConfig.getUrisInScope();
    Map<String, List<Literal>> literalScope = editConfig.getLiteralsInScope();

    Map<String, List<Literal>> varToLiterals = new HashMap<String, List<Literal>>();
    for (String var : varToSparql.keySet()) {
        String query = varToSparql.get(var);
        log.debug("Var name " + var + " and query = " + query);
        /* skip if var set to use a system generated value */
        if (query == null || EditConfigurationVTwo.USE_SYSTEM_VALUE.equals(query)) {
            log.debug("Query is null or using system value so will not continue with rest of method");
            continue;
        }/*w  w w . j  a va 2  s.co m*/
        List<String> queryStrings = new ArrayList<String>();
        queryStrings.add(query);
        editConfig.getN3Generator().subInMultiUris(uriScope, queryStrings);
        log.debug("Query after substituting uris in scope: " + queryStrings.toString());
        editConfig.getN3Generator().subInMultiLiterals(literalScope, queryStrings);
        log.debug("Query after substituting literals in scope: " + queryStrings.toString());
        varToLiterals.put(var, queryToLiteral(queryStrings.get(0))); //might result in (key -> null)
    }

    return varToLiterals;
}

From source file:org.yamj.core.tools.player.PlayerTools.java

/**
 * Scan a list of IP addresses for players
 *
 * @param baseIpAddress//  w w w . j a  v a2  s. co  m
 * @param port
 * @param scanStart
 * @param scanEnd
 * @param timeout
 * @return
 */
private static List<String> scanForPlayers(String baseIpAddress, int port, int scanStart, int scanEnd,
        int timeout) {
    List<String> playerList = new ArrayList<>();

    for (int i = (scanStart < 1 ? 1 : scanStart); i <= (scanEnd > 255 ? 255 : scanEnd); i++) {
        try (Socket mySocket = new Socket()) {
            String ipToScan = baseIpAddress + i;
            LOG.debug("Scanning {}", ipToScan);

            SocketAddress address = new InetSocketAddress(ipToScan, port);
            mySocket.connect(address, timeout);

            try (PrintWriter out = new PrintWriter(mySocket.getOutputStream(), true);
                    BufferedReader in = new BufferedReader(new InputStreamReader(mySocket.getInputStream()))) {
                out.println("setting");
                String fromServer;
                while ((fromServer = in.readLine()) != null) {
                    if (fromServer.equals(XML_PLAYER_IDENT)) {
                        playerList.add(ipToScan);
                        break;
                    }
                }
            }
        } catch (IOException ex) {
            LOG.trace("IO error during scan", ex);
        }
    }

    LOG.info("Found {} players: {}", playerList.size(), playerList.toString());
    return playerList;
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SparqlEvaluateVTwo.java

public Map<String, List<String>> sparqlEvaluateForUris(EditConfigurationVTwo editConfig,
        Map<String, String> varToSparql) {
    Map<String, List<String>> uriScope = editConfig.getUrisInScope();
    Map<String, List<Literal>> literalScope = editConfig.getLiteralsInScope();

    Map<String, List<String>> varToUris = new HashMap<String, List<String>>();

    for (String var : varToSparql.keySet()) {
        String query = varToSparql.get(var);
        log.debug("Var name " + var + " and query = " + query);
        /* skip if var set to use a system generated value */
        if (query == null || EditConfigurationVTwo.USE_SYSTEM_VALUE.equals(query)) {
            log.debug("Query is null or using system value so will not continue with rest of method");
            continue;
        }//from  ww w  .java  2  s. c  om
        List<String> queryStrings = new ArrayList<String>();
        queryStrings.add(query);
        editConfig.getN3Generator().subInMultiUris(uriScope, queryStrings);
        log.debug("Query after substituting uris in scope: " + queryStrings.toString());
        editConfig.getN3Generator().subInMultiLiterals(literalScope, queryStrings);
        log.debug("Query after substituting literals in scope: " + queryStrings.toString());
        List<String> uriFromQuery = queryToUri(queryStrings.get(0));
        if (uriFromQuery != null) {
            //Added parens and output
            varToUris.put(var, uriFromQuery);
        } else
            log.debug("sparqlEvaluateForUris(): for var " + var + " the following query evaluated to null:\n"
                    + queryStrings.get(0) + "\n(end of query)\n");
    }

    return varToUris;
}

From source file:com.cd.reddit.http.util.RedditRequestResponse.java

@Override
public String toString() {
    List<String> builder = new ArrayList<String>(10);
    String nl = System.getProperty("line.separator");

    builder.add("--- RESPONSE CODE ---");
    builder.add(nl);//from  ww  w .j  a  v  a  2s. c  o  m
    builder.add(Integer.toString(status));
    builder.add(nl);
    builder.add(nl);

    builder.add("--- RESPONSE BODY ---");
    builder.add(nl);
    builder.add(body);
    builder.add(nl);
    builder.add(nl);

    return builder.toString();
}

From source file:net.duckling.ddl.service.devent.impl.NoticeServiceImpl.java

@Override
public void writeNotification(List<Notice> data) {
    try {/*w  ww .  ja  v a2 s .c o  m*/
        noticeDao.batchWriteNotices(data);
        MobileNoticeQueue.add(data);
    } catch (Exception e) {
        LOG.error(data.toString(), e);
    }
}

From source file:org.esupportail.portlet.filemanager.services.evaluators.ListUserMultivaluedAttributesEvaluatorEditor.java

/**
 * @param arg0 list of values//  w  ww .  j a  v a 2 s .co m
 * @param arg1 attribute name
 * @param arg2 mode
 * @throws IllegalArgumentException
 * @see org.springframework.beans.propertyeditors.PropertiesEditor#setAsText(java.lang.String)
 */
private void setAsText(final List<String> arg0, final String arg1, final String arg2)
        throws IllegalArgumentException {
    List<UserMultivaluedAttributesEvaluator> list = new LinkedList<UserMultivaluedAttributesEvaluator>();
    for (String value : arg0) {
        list.add(new UserMultivaluedAttributesEvaluator(arg1, value, arg2));
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("In : [" + arg0 + ", " + arg1 + ", " + arg2 + "] out : " + list.toString());
    }
    this.editedProperties = list;
}

From source file:deployer.publishers.artifact.PythonRequirementsPublisherTest.java

@Test
public void testGenerateEntries() throws DeploymentException, ArchiveException, IOException {

    wheels[0] = "";
    ByteBuffer buffer = TestUtils.createSampleOpenShiftWebAppTarBallWithEmptyFiles(wheels);

    // prepare the deployment artifact
    DeploymentMetadata metadata = new DeploymentMetadata();
    DeploymentArtifact artifact = new DeploymentArtifact(metadata, buffer);

    // generateEntries
    PythonRequirementsPublisher publisher = new PythonRequirementsPublisher();
    List<ArtifactDataEntry> entries = (List) publisher.generateEntries(artifact);

    // initial checks
    Assert.assertEquals(entries.size(), 1);
    ArtifactDataEntry entry = entries.get(0);
    Assert.assertEquals(entry.getEntry().getName(), "requirements.txt");

    // write contents out to file
    String filepath = "/tmp/" + entry.getEntry().getName();
    File requirementsFile = new File(filepath);
    FileOutputStream output = new FileOutputStream(requirementsFile);
    IOUtils.write(entry.getData(), output);

    // read file and check lines
    String[] assertionLines = new String[5];
    assertionLines[0] = "";
    assertionLines[1] = "coverage==3.7.1";
    assertionLines[2] = "cryptography==0.7.2";
    assertionLines[3] = "django_crispy_forms==1.4.0";
    assertionLines[4] = "enum34==1.0.4";

    FileInputStream fis = new FileInputStream(requirementsFile);
    BufferedReader br = new BufferedReader(new InputStreamReader(fis));
    String line = null;/*from   w ww  .j  av a 2 s  . c o m*/
    List<String> requirementContents = new ArrayList<String>();
    while ((line = br.readLine()) != null) {
        if (line.contains("=="))
            requirementContents.add(line);
    }

    for (int i = 1; i < assertionLines.length; i++) {
        line = assertionLines[i];
        Assert.assertTrue(line + " not found in: " + requirementContents.toString(),
                requirementContents.contains(line));
    }
}

From source file:gemlite.shell.service.batch.ImportService.java

/***
 * valid parameter for define a job/*from  w  w w .  j av a 2s.  com*/
 * 
 * @param param
 * @return
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private boolean validParameters(BatchParameter param) {
    // ?
    if (StringUtils.equals("file", param.getTemplate())) {
        if (StringUtils.isEmpty(param.getFile())) {
            LogUtil.getCoreLog().info("'file' should not be null");
            return false;
        } else {
            // 1.file://classpath://
            String str = param.getFile();
            if (!str.startsWith("file") && !str.startsWith("classpath")) {
                File f = new File(str);
                str = f.toURI().toString();
                param.setFile(str);
            }
        }
    }

    if (StringUtils.isEmpty(param.getTable())) {
        String table = DomainRegistry.regionToTable(param.getRegion());
        if (StringUtils.isEmpty(table)) {
            LogUtil.getCoreLog().info("region to table failed.");
            return false;
        }
        LogUtil.getCoreLog().info("Set 'table'='region'= " + table);
        param.setTable(table);
    }
    if (StringUtils.isEmpty(param.getColumns())) {
        IMapperTool tool = DomainRegistry.getMapperTool(param.getRegion());
        if (tool != null) {
            List<String> names = tool.getValueFieldNames();
            String clsName = tool.getValueClass().getName();
            if (names != null) {
                String str = names.toString();
                str = str.substring(1, str.length() - 1);
                LogUtil.getCoreLog().info("Columns from class(" + clsName + "):" + str);
            }
        }
        return false;
    }
    return true;
}

From source file:com.github.panthers.maven.plugins.fromConfig.AbstractFromConfigMojo.java

/**
 * Returns the available versions of the artifact of the given range.
 * Filtered based on configuration//from   w  w w. j a v  a2  s.  c o m
 * @param artifactItemsWithRange
 * @return
 * @throws MojoExecutionException
 */
@SuppressWarnings("unchecked")
private List<DefaultArtifactVersion> getAvailableVersions(ArtifactItemsWithRange artifactItemsWithRange)
        throws MojoExecutionException {
    VersionRange artifactVersionRange;
    try {
        artifactVersionRange = VersionRange.createFromVersionSpec(artifactItemsWithRange.getVersionRange());
    } catch (InvalidVersionSpecificationException e) {
        throw new MojoExecutionException("Version range is invalid.");
    }
    Artifact artifact;
    if (StringUtils.isEmpty(artifactItemsWithRange.getClassifier())) {
        artifact = factory.createDependencyArtifact(artifactItemsWithRange.getGroupId(),
                artifactItemsWithRange.getArtifactId(), artifactVersionRange, artifactItemsWithRange.getType(),
                artifactItemsWithRange.getClassifier(), Artifact.SCOPE_COMPILE);
    } else {
        artifact = factory.createDependencyArtifact(artifactItemsWithRange.getGroupId(),
                artifactItemsWithRange.getArtifactId(), artifactVersionRange, artifactItemsWithRange.getType(),
                null, Artifact.SCOPE_COMPILE);
    }
    List<DefaultArtifactVersion> availableVersions = new ArrayList<DefaultArtifactVersion>();
    try {
        List<DefaultArtifactVersion> allVersions = artifactMetadataSource.retrieveAvailableVersions(artifact,
                local, remoteRepos);
        if (artifactItemsWithRange.getIncludeSnapshots()) {
            availableVersions.addAll(allVersions);
            getLog().debug("Adding all versions " + allVersions.toString());
        } else {
            Collections.sort(allVersions);
            Collections.reverse(allVersions);
            if ("SNAPSHOT".equals(allVersions.get(0).getQualifier())
                    && artifactItemsWithRange.getIncludeLatestSnapshot()) { //If latest is snapshot and include latest exists add this
                availableVersions.add(allVersions.get(0));
            } else if (!"SNAPSHOT".equals(allVersions.get(0).getQualifier())) {
                availableVersions.add(allVersions.get(0));
            }
            for (int i = 1; i < allVersions.size(); i++) { //Get all other artifacts without snapshot
                if (!"SNAPSHOT".equals(allVersions.get(i).getQualifier())) {
                    availableVersions.add(allVersions.get(i));
                }
            }
        }
    } catch (ArtifactMetadataRetrievalException e) {
        throw new MojoExecutionException("Could not retrieve available versions");
    }
    getLog().debug("Final versions to process : " + availableVersions.toString());
    return availableVersions;
}

From source file:eu.cloud4soa.soa.git.GitProxyTest.java

@Test
public void getPublicKeysForUser() {
    User user = new User();
    user.setId(new Long(0));
    user.setFullname("Test");
    user.setUriID(userInstanceUriId);/*  www  .  j  a  va 2 s  .  c  om*/
    user.setUsername("testUsername");
    List<Object> userList = new ArrayList<Object>();
    userList.add(user);
    when(userdao.findBy("uriID", userInstanceUriId)).thenReturn(userList);

    PubKey pubkey1 = new PubKey();
    pubkey1.setId(new Long(0));
    pubkey1.setPubkey("pubkey1");
    pubkey1.setUser(user);

    PubKey pubkey2 = new PubKey();
    pubkey2.setId(new Long(0));
    pubkey2.setPubkey("pubkey2");
    pubkey2.setUser(user);

    List<PubKey> pubkeysList = new ArrayList<PubKey>();
    pubkeysList.add(pubkey1);
    pubkeysList.add(pubkey2);

    when(pubkeydao.findByUser(user)).thenReturn(pubkeysList);

    try {
        List<PubKey> publicKeysForUser = gitservices.getPublicKeysForUser(userInstanceUriId);
        logger.info(publicKeysForUser.toString());
        Assert.assertNotNull(publicKeysForUser);
        Assert.assertEquals(2, publicKeysForUser.size());
    } catch (SOAException ex) {
        Assert.fail("SOA Error in getPublicKeysForUser: " + ex.getMessage());
    } catch (Exception ex) {
        logger.error("Error in getPublicKeysForUser: " + ex.getMessage());
        Assert.fail("Error in getPublicKeysForUser: " + ex.getMessage());
    }
}