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:com.liferay.asset.publisher.lar.test.AssetPublisherExportImportTest.java

protected void assertAssetEntries(List<AssetEntry> expectedAssetEntries, List<AssetEntry> actualAssetEntries) {

    Assert.assertEquals(actualAssetEntries.toString(), expectedAssetEntries.size(), actualAssetEntries.size());

    Iterator<AssetEntry> expectedAssetEntriesIterator = expectedAssetEntries.iterator();
    Iterator<AssetEntry> actualAssetEntriesIterator = expectedAssetEntries.iterator();

    while (expectedAssetEntriesIterator.hasNext() && actualAssetEntriesIterator.hasNext()) {

        AssetEntry expectedAssetEntry = expectedAssetEntriesIterator.next();
        AssetEntry actualAssetEntry = actualAssetEntriesIterator.next();

        Assert.assertEquals(expectedAssetEntry.getClassName(), actualAssetEntry.getClassName());
        Assert.assertEquals(expectedAssetEntry.getClassUuid(), actualAssetEntry.getClassUuid());
    }/*from   w ww  . j av  a 2 s.  c  om*/
}

From source file:com.sms.server.service.transcode.AndroidAudioTranscode.java

public List<String> createTranscodeCommand(MediaElement mediaElement, TranscodeProfile profile) {
    List<String> command = new ArrayList<>();

    // Transcoder path
    command.add(transcodeService.getTranscoder().getPath());

    // Input media file
    command.add("-i");
    command.add(mediaElement.getPath());

    // Test if we need to transcode
    if (profile.isAudioTranscodeRequired()) {
        if (transcodeService.getAudioCommands(mediaElement, profile) == null) {
            return null;
        }//  w  w  w.  j  av a2  s. c om
        command.addAll(transcodeService.getAudioCommands(mediaElement, profile));
    } else {
        command.add("-c:a");
        command.add("copy");
    }

    // Format
    command.add("-f");
    command.add(TranscodeService.getAudioFileFormatFromCodec(profile.getAudioCodec()));

    // Output Pipe
    command.add("-");

    LogService.getInstance().addLogEntry(LogService.Level.DEBUG, CLASS_NAME, command.toString(), null);
    return command;
}

From source file:com.yougou.api.service.impl.ApiKeyServiceImpl.java

@Override
@Transactional/*  ww w  .  j  av  a 2  s . com*/
public ApiKey saveGenerateKey(String userName, String merchantCode) {
    // ?
    String appKey = new java.rmi.server.UID().toString().replaceAll("(:|-)", "_");
    // ??
    List<String> appSecretSections = Arrays.asList(appKey.split(""));
    Collections.shuffle(appSecretSections);
    String appSecret = MD5Encryptor.encrypt(appSecretSections.toString());
    ApiKey apiKey = new ApiKey();
    apiKey.setId(UUIDUtil.getUUID());
    apiKey.setAppKey(appKey);
    apiKey.setAppSecret(appSecret);
    apiKey.setStatus(ApiKeyStatus.DISABLE);
    apiKey.setUpdateTime(DateUtil.format(new Date(), "yyyy-MM-dd hh:mm:ss"));
    apiKey.setUpdateUser(StringUtils.isEmpty(merchantCode) ? userName : merchantCode);

    Map<String, List<Object[]>> sqlBatchs = new LinkedHashMap<String, List<Object[]>>();

    String sql = "insert into tbl_merchant_api_key(id, app_key, app_secret,status,update_user,update_time)"
            + " values(?, ?, ?,?, ?, ?)";
    List<Object[]> sqlParams = new ArrayList<Object[]>();
    sqlParams.add(new Object[] { apiKey.getId(), appKey, appSecret, 1,
            StringUtils.isEmpty(merchantCode) ? userName : merchantCode,
            DateUtil.format(new Date(), "yyyy-MM-dd hh:mm:ss") });
    sqlBatchs.put(sql, sqlParams);

    boolean result = JDBCUtils.getInstance().executeBatch(sqlBatchs);
    if (result) {

        logger.info(" app key ?  appkeyId:" + apiKey.getAppKey());
        MerchantOperationLog operationLog = new MerchantOperationLog();
        operationLog.setId(UUIDUtil.getUUID());
        operationLog.setMerchantCode(appKey);
        operationLog.setOperated(new Date());
        operationLog.setOperationNotes("appkey");
        operationLog.setOperationType(OperationType.AppKey_ADD);
        operationLog.setOperator(userName);
        merchantOperationLogService.saveMerchantOperationLog(operationLog);
    }
    //      try {
    //         //saveApiKey(new ApiKey[]{apiKey});
    //         //apiKeyDao.save(apiKey);
    //         //System.out.println(a);
    //      } catch (Exception e) {
    //         logger.error(e);
    //       
    //      }

    return apiKey;

}

From source file:com.vmware.bdd.plugin.ironfan.impl.RolePackageMapping.java

public List<DistroRead> getDistros() {
    loadManifest();//from  w  ww. j a v  a2 s.  co  m
    List<DistroRead> drs = new ArrayList<DistroRead>();
    List<String> vendors = getSupportedVendors();
    List<String> errorVendors = new ArrayList<String>();
    for (Distro distro : distros.values()) {
        DistroRead dr = distro.convert();
        //check vendor name is whether configured in serengeti.properties
        if (!vendors.contains(dr.getVendor().toLowerCase())) {
            if (!errorVendors.contains(dr.getVendor())) {
                errorVendors.add(dr.getVendor());
            }
        }
        drs.add(dr);
    }
    StringBuffer errorMsg = new StringBuffer();
    if (!errorVendors.isEmpty()) {
        String errorVendorsStr = errorVendors.toString();
        errorMsg.append(errorVendorsStr).append(" not configured. To configure ").append(errorVendorsStr)
                .append(", add ").append(errorVendorsStr)
                .append(" to the serengeti.distro_vendor property in the serengeti.properties file.");
    }
    if (errorMsg.length() > 0) {
        throw BddException.INTERNAL(null, errorMsg.toString());
    }
    return drs;
}

From source file:com.ebay.jetstream.dynamicconfig.ConfigUploaderToMongo.java

private void uploadAndPublishAllBeanIdsFromFile() throws Exception {
    File beanFile = new File(beanDefXml);
    List<String> beanIdsList = XmlUtil.getBeanIds(beanFile);
    if (beanIdsList != null && !beanIdsList.isEmpty()) {
        LOGGER.info("Number of Bean Ids are [" + beanIdsList.size() + "]" + " from bean definition file : "
                + beanDefXml);//www . jav  a  2  s  .  c  o  m
        LOGGER.info("Bean Ids are : " + beanIdsList.toString());

        //beanIds = (String[])beanIdsList.toArray();
        for (String beanId : beanIdsList) {
            if (beanId != null && beanId.trim().length() > 0) {
                String beanDefinition = XmlUtil.getBeanDefinition(beanId, beanFile);
                beanDefinition = appendBeanTags(beanDefinition);

                if (beanDefinition != null && beanDefinition.trim().length() > 0) {
                    LOGGER.info("Uploading following spring bean definition for " + beanId
                            + " from bean definition file : " + beanDefXml);
                    LOGGER.info("\n" + beanDefinition);
                    //CalEventHelper.

                    uploadSingle(beanId, beanDefinition);
                    publishSingle(beanId);
                } else {
                    LOGGER.info("Did NOT find bean definition for " + beanId + " from bean definition file : "
                            + beanDefXml);
                }
            } else {
                LOGGER.info("Did NOT do upload because of Bean Id being [" + beanId + "]");
            }
        }
    }
}

From source file:com.photon.phresco.framework.impl.CIManagerImpl.java

private CIJobStatus doJob(CIJob job, String jobType) throws PhrescoException {
    S_LOGGER.debug("Entering Method CIManagerImpl.createJob(CIJob job)");
    try {//  w w  w  .j  av a 2s  .c  o  m
        cli = getCLI(job);
        List<String> argList = new ArrayList<String>();
        argList.add(jobType);
        argList.add(job.getName());
        String configPath = PhrescoFrameworkFactory.getServiceManager().getCiConfigPath();
        ConfigProcessor processor = new ConfigProcessor(new URL(configPath));
        customizeNodes(processor, job);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        S_LOGGER.debug("argList " + argList.toString());
        int result = cli.execute(argList, processor.getConfigAsStream(), System.out, baos);

        String message = "Job created successfully";
        if (result == -1) {
            byte[] byteArray = baos.toByteArray();
            message = new String(byteArray);
        }

        S_LOGGER.debug("message " + message);
        setSvnCredential(job);

        setMailCredential(job);
        return new CIJobStatus(result, message);
    } catch (IOException e) {
        throw new PhrescoException(e);
    } catch (JDOMException e) {
        throw new PhrescoException(e);
    } finally {
        if (cli != null) {
            try {
                cli.close();
            } catch (IOException e) {
                if (debugEnabled) {
                    S_LOGGER.error(e.getLocalizedMessage());
                }
            } catch (InterruptedException e) {
                if (debugEnabled) {
                    S_LOGGER.error(e.getLocalizedMessage());
                }
            }
        }
    }
}

From source file:corner.cache.services.impl.CacheableDefinitionParserImpl.java

/**
 * @see corner.cache.services.CacheableDefinitionParser#parseAsKey(org.apache.tapestry5.ioc.Invocation, java.lang.reflect.Method, corner.cache.services.CacheManager)
 *///w  w w.  j a  va 2 s .  c o m
@Override
public String parseAsKey(Invocation invocation, Method method) {
    Cacheable cacheable = method.getAnnotation(Cacheable.class);
    if (cacheable == null) {
        return null;
    }
    Definition define = null;
    //if (define == null) { // ?
    Builder defineBuilder = CacheableDefine.Definition.newBuilder();
    Annotation[][] parametersAnnotations = method.getParameterAnnotations();
    for (int i = 0; i < parametersAnnotations.length; i++) {
        Annotation[] pa = parametersAnnotations[i];
        for (Annotation a : pa) {
            if (a instanceof CacheKeyParameter) {
                defineBuilder.addParameterIndex(i);
            }
        }
    }
    define = defineBuilder.build();

    // ?
    List<String> keyParameter = new ArrayList<String>();
    Object pObj;
    Class pType;
    for (int i = 0; i < define.getParameterIndexCount(); i++) {
        int pIndex = define.getParameterIndex(i);
        pObj = invocation.getParameter(pIndex);
        pType = null;
        if (pObj != null) {
            pType = entityService.getEntityClass(pObj);
        }
        if (pType == null) {
            pType = method.getParameterTypes()[pIndex];
        }
        ValueEncoder encoder = valueEncoderSource.getValueEncoder(pType);
        keyParameter.add(encoder.toClient(pObj));
    }
    //key
    String key = null;
    String keyFormat = cacheable.keyFormat();
    logger.debug("key parameter:{}", keyParameter);
    if (!StringUtils.hasText(keyFormat)) {
        key = DigestUtils.shaHex(method.toString() + keyParameter.toString());
    } else {
        key = String.format(keyFormat, keyParameter.toArray(new Object[0]));
    }

    CacheStrategy strategy = this.source.findStrategy(cacheable.strategy());
    CacheNsParameter[] nses = cacheable.namespaces();
    if (strategy == null) {
        throw new RuntimeException("fail to find cache strategy instance!");
    }
    return strategy.appendNamespace(cacheManager, cacheable.clazz(), nses, key, keyParameter.toArray());
}

From source file:net.librec.data.convertor.TextDataConvertor.java

/**
 * Read data from the data file. Note that we didn't take care of the
 * duplicated lines./*from  w w w .j  a v a 2 s .c o m*/
 *
 * @param dataColumnFormat
 *            the format of input data file
 * @param inputDataPath
 *            the path of input data file
 * @param binThold
 *            the threshold to binarize a rating. If a rating is greater
 *            than the threshold, the value will be 1; otherwise 0. To
 *            disable this appender, i.e., keep the original rating value,
 *            set the threshold a negative value
 * @throws IOException
 *            if the <code>inputDataPath</code> is not valid.
 */
private void readData(String dataColumnFormat, String inputDataPath, double binThold) throws IOException {
    LOG.info(String.format("Dataset: %s", StringUtil.last(inputDataPath, 38)));
    // Table {row-id, col-id, rate}
    Table<Integer, Integer, Double> dataTable = HashBasedTable.create();
    // Table {row-id, col-id, timestamp}
    Table<Integer, Integer, Long> timeTable = null;
    // Map {col-id, multiple row-id}: used to fast build a rating matrix
    Multimap<Integer, Integer> colMap = HashMultimap.create();
    // BiMap {raw id, inner id} userIds, itemIds
    if (this.userIds == null) {
        this.userIds = HashBiMap.create();
    }
    if (this.itemIds == null) {
        this.itemIds = HashBiMap.create();
    }
    final List<File> files = new ArrayList<File>();
    final ArrayList<Long> fileSizeList = new ArrayList<Long>();
    SimpleFileVisitor<Path> finder = new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
            fileSizeList.add(file.toFile().length());
            files.add(file.toFile());
            return super.visitFile(file, attrs);
        }
    };
    Files.walkFileTree(Paths.get(inputDataPath), finder);
    LOG.info("All dataset files " + files.toString());
    long allFileSize = 0;
    for (Long everyFileSize : fileSizeList) {
        allFileSize = allFileSize + everyFileSize.longValue();
    }
    LOG.info("All dataset files size " + Long.toString(allFileSize));
    int readingFileCount = 0;
    long loadAllFileByte = 0;
    // loop every dataFile collecting from walkFileTree
    for (File dataFile : files) {
        LOG.info("Now loading dataset file " + dataFile.toString().substring(
                dataFile.toString().lastIndexOf(File.separator) + 1, dataFile.toString().lastIndexOf(".")));
        readingFileCount += 1;
        loadFilePathRate = readingFileCount / (float) files.size();
        long readingOneFileByte = 0;
        FileInputStream fis = new FileInputStream(dataFile);
        FileChannel fileRead = fis.getChannel();
        ByteBuffer buffer = ByteBuffer.allocate(BSIZE);
        int len;
        String bufferLine = new String();
        byte[] bytes = new byte[BSIZE];
        while ((len = fileRead.read(buffer)) != -1) {
            readingOneFileByte += len;
            loadDataFileRate = readingOneFileByte / (float) fileRead.size();
            loadAllFileByte += len;
            loadAllFileRate = loadAllFileByte / (float) allFileSize;
            buffer.flip();
            buffer.get(bytes, 0, len);
            bufferLine = bufferLine.concat(new String(bytes, 0, len));
            bufferLine = bufferLine.replaceAll("\r", "\n");
            String[] bufferData = bufferLine.split("(\n)+");
            boolean isComplete = bufferLine.endsWith("\n");
            int loopLength = isComplete ? bufferData.length : bufferData.length - 1;
            for (int i = 0; i < loopLength; i++) {
                String line = new String(bufferData[i]);
                String[] data = line.trim().split("[ \t,]+");
                String user = data[0];
                String item = data[1];
                Double rate = ((dataColumnFormat.equals("UIR") || dataColumnFormat.equals("UIRT"))
                        && data.length >= 3) ? Double.valueOf(data[2]) : 1.0;

                // binarize the rating for item recommendation task
                if (binThold >= 0) {
                    rate = rate > binThold ? 1.0 : 0.0;
                }

                // inner id starting from 0
                int row = userIds.containsKey(user) ? userIds.get(user) : userIds.size();
                userIds.put(user, row);

                int col = itemIds.containsKey(item) ? itemIds.get(item) : itemIds.size();
                itemIds.put(item, col);

                dataTable.put(row, col, rate);
                colMap.put(col, row);
                // record rating's issuing time
                if (StringUtils.equals(dataColumnFormat, "UIRT") && data.length >= 4) {
                    if (timeTable == null) {
                        timeTable = HashBasedTable.create();
                    }
                    // convert to million-seconds
                    long mms = 0L;
                    try {
                        mms = Long.parseLong(data[3]); // cannot format
                        // 9.7323480e+008
                    } catch (NumberFormatException e) {
                        mms = (long) Double.parseDouble(data[3]);
                    }
                    long timestamp = timeUnit.toMillis(mms);
                    timeTable.put(row, col, timestamp);
                }
            }
            if (!isComplete) {
                bufferLine = bufferData[bufferData.length - 1];
            }
            buffer.clear();
        }
        fileRead.close();
        fis.close();
    }
    int numRows = numUsers(), numCols = numItems();
    // build rating matrix
    preferenceMatrix = new SparseMatrix(numRows, numCols, dataTable, colMap);
    if (timeTable != null)
        datetimeMatrix = new SparseMatrix(numRows, numCols, timeTable, colMap);
    // release memory of data table
    dataTable = null;
    timeTable = null;
}

From source file:com.spoiledmilk.ibikecph.search.SearchAutocompleteActivity.java

private void spawnSearchThreads(final Location loc, final String searchText, final Address addr,
        final String tag) {

    if (lastAddress != null && lastAddress.equals(addr) && adapter != null && adapter.getCount() != 0) {
        return;// ww  w .jav a 2 s .co  m
    } else {
        lastAddress = addr;
    }
    if (!Util.isNetworkConnected(this)) {
        Util.launchNoConnectionDialog(this);
        progressBar.setVisibility(View.INVISIBLE);
    } else {
        // fetch the Kortforsyningen autocomplete
        kmsThread = new Thread(new Runnable() {
            @Override
            public void run() {
                // final List<JsonNode> kortforsyningenList = new ArrayList<JsonNode>();
                final ArrayList<SearchListItem> data = new ArrayList<SearchListItem>();
                if (!(addr.street == null || addr.street.trim().equals(""))) {

                    List<JsonNode> list = HTTPAutocompleteHandler.getKortforsyningenAutocomplete(loc, addr);

                    int count = 0;
                    if (list != null) {
                        for (JsonNode node : list) {
                            if (count == 10) {
                                break;
                            }
                            KortforData kd = new KortforData(node);
                            if (kd.getCity() != null && addr.city != null
                                    && kd.getCity().toLowerCase(Locale.US).contains(addr.city)) {
                                LOG.d("kd = " + kd);
                            }
                            if (addr.zip != null && !addr.zip.equals("") && kd.getZip() != null) {
                                if (!addr.zip.trim().toLowerCase(Locale.UK)
                                        .equals(kd.getZip().toLowerCase(Locale.UK))) {
                                    continue;
                                }
                            }
                            LOG.d("kd = " + kd);
                            if (kd.getCity() != null && addr.city != null
                                    && kd.getCity().toLowerCase(Locale.US).contains(addr.city)
                                    && kd.getCity().contains("Aarhus")) {
                                LOG.d("kd.city = " + kd.getCity() + " addr city = " + addr.city);
                            }
                            if (addr.city != null && !addr.city.equals("") && !addr.city.equals(addr.street)
                                    && kd.getCity() != null) {
                                if (!(addr.city.trim().toLowerCase(Locale.UK)
                                        .contains(kd.getCity().toLowerCase(Locale.UK))
                                        || kd.getCity().trim().toLowerCase(Locale.UK)
                                                .contains(addr.city.toLowerCase(Locale.UK)))) {
                                    continue;
                                }
                            }
                            LOG.d("adding a kd to the list " + kd);
                            data.add(kd);
                            count++;
                        }

                    }
                }
                if (!addr.isAddress()) {
                    List<JsonNode> places = HTTPAutocompleteHandler.getKortforsyningenPlaces(loc, addr);
                    if (places != null) {
                        int count = 0;
                        if (places != null) {
                            LOG.d("places count = " + places.size() + " data = " + places.toString());
                            for (JsonNode node : places) {
                                if (count == 10) {
                                    break;
                                }
                                KortforData kd = new KortforData(node);
                                if (addr.zip != null && !addr.zip.equals("") && kd.getZip() != null) {
                                    if (!addr.zip.trim().toLowerCase(Locale.UK)
                                            .equals(kd.getZip().toLowerCase(Locale.UK))) {
                                        continue;
                                    }
                                }
                                if (addr.city != null && !addr.city.equals("") && !addr.city.equals(addr.street)
                                        && kd.getCity() != null) {
                                    if (!(addr.city.trim().toLowerCase(Locale.UK)
                                            .contains(kd.getCity().toLowerCase(Locale.UK))
                                            || kd.getCity().trim().toLowerCase(Locale.UK)
                                                    .contains(addr.city.toLowerCase(Locale.UK)))) {
                                        continue;
                                    }
                                }
                                data.add(kd);
                                count++;
                            }

                        }
                    }
                }
                isOirestFetched = true;
                runOnUiThread(new Runnable() {
                    public void run() {
                        updateListData(data, tag, addr);

                    }
                });
            }

        });
        kmsThread.start();
        if (textSrch.getText().toString().length() >= 3 && addr.isFoursquare()) {
            // fetch the Foursquare autocomplete
            foursquareThread = new Thread(new Runnable() {
                @Override
                public void run() {
                    List<JsonNode> list = HTTPAutocompleteHandler.getFoursquareAutocomplete(addr,
                            SearchAutocompleteActivity.this, loc);
                    final ArrayList<SearchListItem> data = new ArrayList<SearchListItem>();
                    if (list != null) {
                        int count = 0;
                        for (JsonNode node : list) {
                            if (count == 3) {
                                break;
                            }
                            JsonNode location = node.path("location");
                            if (location.has("lat") && location.has("lng")
                                    && location.get("lat").asDouble() != 0
                                    && location.get("lng").asDouble() != 0) {
                                String country = location.has("country") ? location.get("country").asText()
                                        : "";
                                if (country.contains("Denmark") || country.contains("Dansk")
                                        || country.contains("Danmark")) {
                                    FoursquareData fd = new FoursquareData(node);
                                    fd.setDistance(loc.distanceTo(
                                            Util.locationFromCoordinates(fd.getLatitude(), fd.getLongitude())));
                                    data.add(fd);
                                    count++;
                                }
                            }
                        }
                    }
                    isFoursquareFetched = true;
                    runOnUiThread(new Runnable() {
                        public void run() {
                            updateListData(data, tag, addr);
                        }
                    });
                }
            });
            foursquareThread.start();
        } else {
            isFoursquareFetched = true;
        }
    }
}