Example usage for java.util ArrayList toString

List of usage examples for java.util ArrayList toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.google.zxing.client.android.history.HistoryActivity.java

@SuppressWarnings("deprecation")
public void postHttpItens(String logado, String eventos, String atividades, String data_envio) {
    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(
            "http://www.inscrevaseonline.com.br/testeintelligence/credenciamento/retorno.php");

    try {/*  ww w. java 2  s  .c om*/
        ArrayList<NameValuePair> valores = new ArrayList<NameValuePair>();
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("credenciador", logado.toString());
            jsonObject.put("atividade", atividades.toString());
            jsonObject.put("evento", eventos.toString());
            jsonObject.put("inscrito", historyManager.listarTodosQr());
            // jsonObject.put("data_envio",
            // data_envio.toString().replace("\"", ""));
        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        valores.add(new BasicNameValuePair("credenciamento", jsonObject.toString()));

        httpPost.setEntity(new UrlEncodedFormEntity(valores));
        final HttpResponse envios = httpClient.execute(httpPost);
        Log.i("Script", valores.toString());
        final String resp = EntityUtils.toString(envios.getEntity());

        runOnUiThread(new Runnable() {
            public void run() {
                try {
                    JSONObject respostJson = new JSONObject(resp);
                    boolean retorno = respostJson.getBoolean("retorno");
                    if (retorno == true) {
                        historyManager.clearHistory();
                        progDialog.dismiss();
                        Toast.makeText(getBaseContext(), R.string.toast_dados_enviados, Toast.LENGTH_LONG)
                                .show();
                        finish();
                    } else {
                        progDialog.dismiss();
                        Toast.makeText(getBaseContext(), R.string.toast_dados_nao_enviados, Toast.LENGTH_LONG)
                                .show();
                    }

                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    Toast.makeText(getBaseContext(), R.string.toast_dados_nao_enviados, Toast.LENGTH_LONG)
                            .show();
                }
            }
        });
    } catch (ClientProtocolException e) {
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.npower.wurfl.Wurfl.java

String getDeviceWhereCapabilityIsDefined(String devID, String capaName) {

    if (!isDeviceIn(devID)) {
        log.error("ERROR: Device ID " + devID + " not defined in WURFL.(getDeviceWhereCapabilityIsDefined())");
        return "";
    }/*  w  w  w . ja v  a2s  .co m*/
    if (!isCapabilityIn(capaName)) {
        log.error("ERROR: capability " + capaName
                + " not defined in WURFL.(getDeviceWhereCapabilityIsDefined())");
        return "";
    }

    if (isCapabilityDefinedInDevice(devID, capaName)) {
        return devID;
    }

    // I know the application assumes that the WURFL is valid,
    // but since a little glitch can go a long way, we do what we can to avoid
    // infinite loops
    String looper = devID;
    int i = 0;
    ArrayList<String> fb_path = new ArrayList<String>();
    while (!isCapabilityDefinedInDevice(looper, capaName)) {
        looper = getFallBackForDevice(looper);
        i++;
        fb_path.add(looper);
        if (i > 100) {
            log.error("ERROR: WURFL file is probably not valid. Infinite-loop detected:");
            log.error("loop of device IDs: " + fb_path.toString());
            return "generic";
        }
    }

    return looper; // of course, it assumes that generic has all the
    // capabilities
}

From source file:org.kuali.kfs.module.cam.document.AssetTransferDocument.java

/**
 * @see org.kuali.rice.kns.document.DocumentBase#postProcessSave(org.kuali.rice.kns.rule.event.KualiDocumentEvent)
 *///from   w  ww  .  j a  v  a  2 s  .c  o m

public void postProcessSave(KualiDocumentEvent event) {
    super.postProcessSave(event);

    if (!(event instanceof SaveDocumentEvent)) { // don't lock until they route
        ArrayList capitalAssetNumbers = new ArrayList<Long>();
        if (this.getCapitalAssetNumber() != null) {
            capitalAssetNumbers.add(this.getCapitalAssetNumber());
        }

        if (!this.getCapitalAssetManagementModuleService().storeAssetLocks(capitalAssetNumbers,
                this.getDocumentNumber(), CamsConstants.DocumentTypeName.ASSET_TRANSFER, null)) {
            throw new ValidationException(
                    "Asset " + capitalAssetNumbers.toString() + " is being locked by other documents.");
        }
    }
}

From source file:ac.ucy.cs.spdx.service.Compatibility.java

@POST
@Path("/edge/")
@Consumes(MediaType.TEXT_PLAIN)/*from   w w w  .  j a  v a 2  s .  c  o  m*/
@Produces(MediaType.APPLICATION_JSON)
public String addEdge(String jsonString) {

    ObjectMapper mapper = new ObjectMapper();
    JsonNode licenseEdge = null;
    try {
        licenseEdge = mapper.readTree(jsonString);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    ArrayList<String> licenseNodes = new ArrayList<String>();
    String nodeIdentifier = licenseEdge.get("nodeIdentifier").toString();
    nodeIdentifier = nodeIdentifier.substring(1, nodeIdentifier.length() - 1);

    String transitivity = licenseEdge.get("transitivity").toString();
    transitivity = transitivity.substring(1, transitivity.length() - 1);
    Boolean isTransitive = Boolean.parseBoolean(transitivity);

    JsonNode nodesJSON = licenseEdge.get("nodeIdentifiers");

    for (int i = 0; i < nodesJSON.size(); i++) {
        String node = nodesJSON.get(i).get("identifier").toString();
        node = node.substring(1, node.length() - 1);
        licenseNodes.add(node);
    }

    try {
        LicenseGraph.connectNode(isTransitive, nodeIdentifier,
                licenseNodes.toArray(new String[licenseNodes.size()]));
    } catch (LicenseEdgeAlreadyExistsException e) {
        e.printStackTrace();
        return "{\"status\":\"failure\",\"message\":\"" + e.getMessage() + "\"}";
    }

    LicenseGraph.exportGraph();

    return "{\"status\":\"success\",\"message\":\"" + nodeIdentifier + " -> " + licenseNodes.toString()
            + " added in the system.\"}";// {"nodeIdentifier":"Caldera","transitivity":"true","nodeIdentifiers":[{"identifier":"Apache-2.0"}]}
}

From source file:org.powertac.customer.model.LiftTruck.java

private void finishShift(ArrayList<Integer> blockData, ArrayList<Integer> shiftData) {
    if (blockData.isEmpty()) {
        log.error("Config error for " + getName() + ": empty block for shift " + shiftData.toString());
    } else {/*from ww w  .  j  ava 2 s .  c o m*/
        addShift(shiftData, blockData);
    }
}

From source file:com.example.android.enghack_receipt_scanner.OcrCaptureActivity.java

/**
 * onTap is called to capture the first TextBlock under the tap location and return it to
 * the Initializing Activity./*from  w  w  w.  j a v a2s  .co  m*/
 *
 * @param rawX - the raw position of the tap
 * @param rawY - the raw position of the tap.
 * @return true if the activity is ending.
 */
private boolean onTap(float rawX, float rawY) {
    //OcrGraphic graphic = mGraphicOverlay.getGraphicAtLocation(rawX, rawY);
    TextBlock text = null;
    Intent data = new Intent();
    ArrayList<TextBlock> output = new ArrayList<>();
    Set<OcrGraphic> mGraphics = mGraphicOverlay.mGraphics;
    for (OcrGraphic graphic : mGraphics) {
        if (graphic != null) {
            text = graphic.getTextBlock();
            if (text != null) {
                output.add(text);
                Log.d("TextBlockObject",
                        text.getValue() + "  " + text.getBoundingBox().top + "  " + text.getBoundingBox().left
                                + "  " + text.getBoundingBox().bottom + "  " + text.getBoundingBox().right);
            } else {
                Log.d(TAG, "text data is null");
            }
        } else {
            Log.d(TAG, "no text detected");
        }
    }
    if (output.size() == 0) {
        return false;
    }
    Log.d("CONTENTS OF RAW OUTPUT", output.toString());
    ArrayList<Product> products = cleanTextBlockInfo(output);
    if (products == null) {
        // Catch no price safely
        return false;
    }
    ArrayList<String> serializedProducts = new ArrayList<>();
    try {
        for (Product item : products) {
            String tempSerial = item.serialize();
            Log.d("SERIALIZED", tempSerial);
            serializedProducts.add(tempSerial);
        }
    } catch (Exception e) {
        Log.d("ADDING_SERIALIZED", e.getClass().toString());
        Log.d("ADDING_SERIALIZED", e.getMessage());
    }

    data.putExtra("TextBlockObject", serializedProducts);

    setResult(CommonStatusCodes.SUCCESS, data);
    finish();
    return text != null;
}

From source file:org.openecomp.sdnc.sli.aai.AAIDeclarations.java

static final Map<String, String> ctxGetBeginsWith(SvcLogicContext ctx, String prefix) {
    Map<String, String> tmpPrefixMap = new HashMap<String, String>();

    if (prefix == null || prefix.isEmpty()) {
        return tmpPrefixMap;
    }/*from  w ww.ja  v a2  s.co m*/

    for (String key : ctx.getAttributeKeySet()) {
        if (key.startsWith(prefix)) {
            String tmpKey = key.substring(prefix.length() + 1);
            tmpPrefixMap.put(tmpKey, ctx.getAttribute(key));
        }
    }

    Map<String, String> prefixMap = new HashMap<String, String>();
    Pattern p = Pattern.compile(".*\\[\\d\\]");

    SortedSet<String> keys = new TreeSet(tmpPrefixMap.keySet());
    for (String key : keys) {
        Matcher m = p.matcher(key);
        if (m.matches()) {
            continue;
        } else if (key.endsWith("_length")) {
            String listKey = key.substring(0, key.indexOf("_length"));
            int max = Integer.parseInt(tmpPrefixMap.get(key));

            ArrayList<String> data = new ArrayList<String>();
            for (int x = 0; x < max; x++) {
                String tmpKey = String.format("%s[%d]", listKey, x);
                String tmpValue = tmpPrefixMap.get(tmpKey);
                if (tmpValue != null && !tmpValue.isEmpty()) {
                    data.add(tmpValue);
                }
            }
            if (!data.isEmpty()) {
                prefixMap.put(listKey, data.toString());
            } else {
                prefixMap.put(key, tmpPrefixMap.get(key));
            }
        } else {
            prefixMap.put(key, tmpPrefixMap.get(key));
        }
    }

    return prefixMap;
}

From source file:org.apache.hadoop.hbase.util.RegionMover.java

/**
 * Excludes the servername whose hostname and port portion matches the list given in exclude file
 * @param regionServers/* ww  w .j  a va  2s .  com*/
 * @param excludeFile
 * @throws IOException
 */
private void stripExcludes(ArrayList<String> regionServers, String excludeFile) throws IOException {
    if (excludeFile != null) {
        ArrayList<String> excludes = readExcludes(excludeFile);
        Iterator<String> i = regionServers.iterator();
        while (i.hasNext()) {
            String rs = i.next();
            String rsPort = rs.split(ServerName.SERVERNAME_SEPARATOR)[0] + ":"
                    + rs.split(ServerName.SERVERNAME_SEPARATOR)[1];
            if (excludes.contains(rsPort)) {
                i.remove();
            }
        }
        LOG.info("Valid Region server targets are:" + regionServers.toString());
        LOG.info("Excluded Servers are" + excludes.toString());
    }
}

From source file:com.intuit.wasabi.tests.service.IntegrationMutualExclusion.java

/**
 * Tests mutual exclusions.//from  w ww.j  a v a 2 s . co m
 */
@Test(dependsOnGroups = { "ping" })
public void t_testMutualExclusion() {
    ArrayList<Experiment> experiments = new ArrayList<>(Constants.EXP_SPAWN_COUNT);

    LOGGER.info("Testing mutual exclusion functionality...");
    LOGGER.info("Creating " + Constants.EXP_SPAWN_COUNT
            + " new experiments to test mutual exclusions functionality...");

    for (int i = 0; i < Constants.EXP_SPAWN_COUNT; i++) {
        Experiment experiment = ExperimentFactory.createExperiment();

        Experiment created = postExperiment(experiment);
        experiment.setState(Constants.EXPERIMENT_STATE_DRAFT);
        assertEqualModelItems(created, experiment, new DefaultNameExclusionStrategy("id", "creationTime",
                "modificationTime", "ruleJson", "description", "rule"));
        experiment.update(created);

        // Make this experiment mutually exclusive with all previous experiment added in this loop.
        if (experiments.size() > 0) {
            LOGGER.info("Making this experiment " + experiment
                    + " mutually exclusive with all previous experiments: " + experiments.toString());
            postExclusions(experiment, experiments);
        }

        // check if all exclusions are correct
        List<Experiment> mutualExclusiveExperiments = getExclusions(experiment);
        if (experiments.size() > 0) {
            assertEqualModelItemsNoOrder(mutualExclusiveExperiments, experiments,
                    new DefaultNameExclusionStrategy("creationTime", "modificationTime", "ruleJson"));
        } else {
            Assert.assertEquals(experiments.size(), 0);
        }

        // check if there are other non-mutual experiments and if there are, if they at least are in the same
        // application
        List<Experiment> nonMutualExclusiveExperiments = getExclusions(experiment, true, false);
        for (Experiment nonMutex : nonMutualExclusiveExperiments) {
            Assert.assertFalse(mutualExclusiveExperiments.contains(nonMutex),
                    "Unexpected mutual exclusive experiment!");
            Assert.assertEquals(nonMutex.applicationName, experiment.applicationName,
                    "Application names differ.");
        }

        if (experiments.size() > 0) {
            for (Experiment exp : experiments) {
                Assert.assertFalse(nonMutualExclusiveExperiments.contains(exp));
            }
        } else {
            Assert.assertEquals(experiments.size(), 0);
        }

        experiments.add(experiment);
    }

    // delete an exclusion and ensure it was successful
    List<Experiment> exclusiveExperimentsPre = getExclusions(experiments.get(0));
    deleteExclusion(experiments.get(0), exclusiveExperimentsPre.get(0));
    List<Experiment> exclusiveExperimentsPost = getExclusions(experiments.get(0));
    exclusiveExperimentsPre.remove(0);
    assertEqualModelItems(exclusiveExperimentsPost, exclusiveExperimentsPre,
            new DefaultNameExclusionStrategy("creationTime", "modificationTime", "ruleJson"));
}

From source file:web.SaveglobalquotaController.java

/**
 * This method is called by the spring framework. The configuration
 * for this controller to be invoked is based on the pagetype and
 * is set in the urlMapping property in the spring config file.
 *
 * @param request the <code>HttpServletRequest</code>
 * @param response the <code>HttpServletResponse</code>
 * @throws ServletException//from w w  w. jav a 2s  . c  o  m
 * @throws IOException
 * @return ModelAndView this instance is returned to spring
 */
public synchronized ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    // ***************************************************************************
    // This will initialize common data in the abstract class and the return result is of no value.
    // The abstract class initializes protected variables, login, collabrum, logininfo.
    // Which can be accessed in all controllers if they want to.
    // ***************************************************************************

    try {
        ModelAndView m = super.handleRequest(request, response);
    } catch (Exception e) {
        return handleError("error in handleRequest", e);
    }

    if (!WebUtil.isLicenseProfessional(login)) {
        return handleError("Cannot manage SaveglobalquotaController feature in deluxe version.");
    }

    // ***************************************************************************
    // This is the only line of code you need to get all session info initialized!
    // Always be the first line before anything else is done. Add to each controller's
    // handlRequest method. Also recollabrum to extend SessionObject.
    // ***************************************************************************
    outOfSession(request, response);

    if (RegexStrUtil.isNull(login) || (loginInfo == null)) {
        return handleUserpageError("Login/loginInfo is null in SaveglobalquotaController.");
    }

    String strSize = request.getParameter(DbConstants.SIZE);
    String strQCnt = request.getParameter(DbConstants.QCNT);

    logger.info("qcnt = " + strQCnt);
    logger.info("size = " + strSize);

    int size = 0;
    int qcnt = 0;

    if (!RegexStrUtil.isNull(strSize)) {
        size = new Integer(strSize).intValue();
    }

    if (!RegexStrUtil.isNull(strQCnt)) {
        qcnt = new Integer(strQCnt).intValue();
    }

    ArrayList entryIdList = new ArrayList();
    ArrayList entryListVals = new ArrayList();

    if (entryIdList == null || entryListVals == null) {
        return handleError("cannot new ArrayList() for either entryListVals or entryIdList vals");
    } else {
        for (int i = 0; i < size; i++) {
            String val = new Integer(i).toString();
            logger.info("val = " + val);
            String myString = "col" + val;
            logger.info("myString = " + myString);
            entryIdList.add(RegexStrUtil.goodNameStr(request.getParameter(myString)));
            logger.info("entryidnum = " + i + "=" + request.getParameter(myString));
            myString = "colentry" + val;
            logger.info("myString = " + myString);
            entryListVals.add(RegexStrUtil.goodNameStr(request.getParameter(myString)));
            logger.info("entryidval = " + i + " = " + request.getParameter(myString));
        }
    }

    ArrayList qNameListVals = new ArrayList();
    ArrayList qNameList = new ArrayList();
    ArrayList qTypeList = new ArrayList();

    if (qNameListVals == null || qNameList == null || qTypeList == null) {
        return handleError("cannot new ArrayList() for qNameListVals");
    } else {
        for (int i = 0; i < qcnt; i++) {
            String val = new Integer(i).toString();
            //if (!RegexStrUtil.isNull(request.getParameter(val))) {  
            if (!RegexStrUtil.isNull(val)) {
                String myString = "qcol" + val;
                qNameList.add(RegexStrUtil.goodNameStr(request.getParameter(myString)));
                logger.info(i + request.getParameter(myString));
                myString = "qcolname" + val;
                qNameListVals.add(RegexStrUtil.goodNameStr(request.getParameter(myString)));
                logger.info(i + request.getParameter(myString));
                myString = "qtype" + val;
                qTypeList.add(RegexStrUtil.goodNameStr(request.getParameter(myString)));
                logger.info(i + request.getParameter(myString));
            }
        }
    }
    logger.info("qNameList = " + qNameList.toString());
    logger.info("qNameListVals = " + qNameListVals.toString());
    logger.info("qTypeList = " + qTypeList.toString());
    logger.info("entryIdList = " + entryIdList.toString());
    logger.info("entryListVals = " + entryListVals.toString());

    /**
    *  show the quota size
    */
    List quotaList = null;
    List divisions = null;
    List areas = null;
    List sections = null;
    List groups = null;
    try {
        LdapApi ldapConnection = new LdapApi();
        if (ldapConnection == null) {
            return handleError("ldapConnection is null, SaveglobalquotaController");
        } else {
            areas = ldapConnection.getStructureValues(LdapConstants.ldapArea);
            groups = ldapConnection.getStructureValues(LdapConstants.ldapGroup);
            sections = ldapConnection.getStructureValues(LdapConstants.ldapSection);
            divisions = ldapConnection.getStructureValues(LdapConstants.ldapDivision);
            if (areas != null && areas.size() > 0) {
                logger.info("areas = " + areas.toString());
            }
            if (groups != null && groups.size() > 0) {
                logger.info("groups = " + groups.toString());
            }
            if (sections != null && sections.size() > 0) {
                logger.info("sections = " + sections.toString());
            }
            if (divisions != null && divisions.size() > 0) {
                logger.info("divisions = " + divisions.toString());
            }
        }
    } catch (Exception e) {
        return handleError("ldap error while retrieving quota types getStructureValues()", e);
    }

    /**
    *  dirDao
    */
    DirectoryDao dirDao = (DirectoryDao) daoMapper.getDao(DbConstants.DIRECTORY);
    try {
        if ((dirDao == null)) {
            return handleError("dirDao is null in SaveglobalquotaController collabrum, " + login);
        } else {
            dirDao.saveGlobalQuotas(login, entryIdList, entryListVals, qNameList, qNameListVals, qTypeList);

            quotaList = dirDao.getGlobalQuotas(login, DbConstants.READ_FROM_MASTER);
            quotaList = dirDao.getGlobalMatch(areas, groups, sections, divisions, quotaList,
                    LdapUtil.getOrganization());
        }
    } catch (BaseDaoException e) {
        return handleError("Exception occured, getQuotaSize(), SaveglobalquotaController for login " + login,
                e);
    }

    CobrandDao cobrandDao = (CobrandDao) getDaoMapper().getDao(DbConstants.COBRAND);
    if (cobrandDao == null) {
        return handleUserpageError("CobrandDao is null, SaveglobalquotaController");
    }

    Userpage cobrand = null;
    try {
        cobrand = cobrandDao.getUserCobrand(loginInfo.getValue(DbConstants.LOGIN_ID));
    } catch (BaseDaoException e) {
        return handleError("Exception occured, getUserCobrand(), SaveglobalquotaController for login " + login,
                e);
    }

    String viewName = DbConstants.VIEW_GLOBAL_QUOTAS;
    Map myModel = new HashMap();
    myModel.put(DbConstants.LOGIN_INFO, loginInfo);
    myModel.put(DbConstants.QUOTAS, quotaList);
    myModel.put(DbConstants.COBRAND, cobrand);
    myModel.put(DbConstants.DIR_EXISTS, rbDirectoryExists);
    myModel.put(DbConstants.USER_PAGE, userpage);
    if (DiaryAdmin.isDiaryAdmin(login)) {
        myModel.put(DbConstants.BUSINESS_EXISTS, "1");
    } else {
        myModel.put(DbConstants.BUSINESS_EXISTS, isBizExists(login));
    }
    return new ModelAndView(viewName, "model", myModel);
}