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:org.sonatype.nexus.index.FullIndexNexusIndexerTest.java

public void testSearchGroupedClasses() throws Exception {
    {//from w  w w  . java2 s.  c  o m
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "com/thoughtworks/qdox");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GAGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);
        Map<String, ArtifactInfoGroup> r = response.getResults();

        assertEquals(r.toString(), 2, r.size()); // qdox and testng

        assertTrue(r.containsKey("qdox : qdox"));
        assertTrue(r.containsKey("org.testng : testng"));
        assertEquals("qdox : qdox", r.get("qdox : qdox").getGroupKey());
        assertEquals("org.testng : testng", r.get("org.testng : testng").getGroupKey());
    }

    {
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "com.thoughtworks.qdox");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GAGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);
        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size());

        assertTrue(r.containsKey("qdox : qdox"));
        assertTrue(r.containsKey("org.testng : testng"));
        assertEquals("qdox : qdox", r.get("qdox : qdox").getGroupKey());
        assertEquals("org.testng : testng", r.get("org.testng : testng").getGroupKey());
    }

    {
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "thoughtworks");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GAGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);
        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size());
        assertTrue(r.containsKey("qdox : qdox"));
        assertTrue(r.containsKey("org.testng : testng"));
        assertEquals("qdox : qdox", r.get("qdox : qdox").getGroupKey());
        assertEquals("org.testng : testng", r.get("org.testng : testng").getGroupKey());
    }

    {
        // an implicit class name wildcard
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "Logger");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);

        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size());

        Iterator<ArtifactInfoGroup> it = r.values().iterator();

        ArtifactInfoGroup ig1 = it.next();
        assertEquals(r.toString(), "org.slf4j", ig1.getGroupKey());

        ArtifactInfoGroup ig2 = it.next();
        assertEquals(r.toString(), "org.testng", ig2.getGroupKey());
    }

    {
        // a lower case search
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "logger");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);
        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size());

        Iterator<ArtifactInfoGroup> it = r.values().iterator();

        ArtifactInfoGroup ig1 = it.next();
        assertEquals(r.toString(), "org.slf4j", ig1.getGroupKey());

        ArtifactInfoGroup ig2 = it.next();
        assertEquals(r.toString(), "org.testng", ig2.getGroupKey());
    }

    {
        // explicit class name wildcard without terminator
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "*.Logger");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);
        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size());
        Iterator<ArtifactInfoGroup> it = r.values().iterator();
        ArtifactInfoGroup ig1 = it.next();
        assertEquals(r.toString(), "org.slf4j", ig1.getGroupKey());
        ArtifactInfoGroup ig2 = it.next();
        assertEquals(r.toString(), "org.testng", ig2.getGroupKey());
    }

    {
        // explicit class name wildcard with terminator
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "*.Logger ");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);
        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size());
        Iterator<ArtifactInfoGroup> it = r.values().iterator();
        ArtifactInfoGroup ig1 = it.next();
        assertEquals(r.toString(), "org.slf4j", ig1.getGroupKey());
        ArtifactInfoGroup ig2 = it.next();
        assertEquals(r.toString(), "org.testng", ig2.getGroupKey());
    }

    {
        // a class name wildcard
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "*Logger");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);
        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 3, r.size());

        Iterator<ArtifactInfoGroup> it = r.values().iterator();

        ArtifactInfoGroup ig1 = it.next();
        assertEquals(r.toString(), "commons-logging", ig1.getGroupKey()); // Jdk14Logger and LogKitLogger

        ArtifactInfoGroup ig2 = it.next();
        assertEquals(r.toString(), "org.slf4j", ig2.getGroupKey());

        ArtifactInfoGroup ig3 = it.next();
        assertEquals(r.toString(), "org.testng", ig3.getGroupKey());
    }

    {
        // exact class name
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES,
                "org/apache/commons/logging/LogConfigurationException");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GAGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);

        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size()); // jcl104-over-slf4j and commons-logging
    }

    {
        // implicit class name pattern
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES,
                "org.apache.commons.logging.LogConfigurationException");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GAGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);

        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size()); // jcl104-over-slf4j and commons-logging
    }

    {
        // exact class name
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES,
                "^org.apache.commons.logging.LogConfigurationException$");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GAGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);

        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size()); // jcl104-over-slf4j and commons-logging
    }

    {
        // package name prefix
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "^org.apache.commons.logging");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GAGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);

        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size()); // jcl104-over-slf4j and commons-logging
    }

    {
        Query q = nexusIndexer.constructQuery(ArtifactInfo.NAMES, "*slf4j*Logg*");
        GroupedSearchRequest request = new GroupedSearchRequest(q, new GAGrouping());
        GroupedSearchResponse response = nexusIndexer.searchGrouped(request);

        Map<String, ArtifactInfoGroup> r = response.getResults();
        assertEquals(r.toString(), 2, r.size());

        {
            ArtifactInfoGroup ig = r.values().iterator().next();
            ArrayList<ArtifactInfo> list1 = new ArrayList<ArtifactInfo>(ig.getArtifactInfos());
            assertEquals(r.toString(), 2, list1.size());

            ArtifactInfo ai1 = list1.get(0);
            assertEquals("org.slf4j", ai1.groupId);
            assertEquals("slf4j-api", ai1.artifactId);
            assertEquals("1.4.2", ai1.version);
            ArtifactInfo ai2 = list1.get(1);
            assertEquals("org.slf4j", ai2.groupId);
            assertEquals("slf4j-api", ai2.artifactId);
            assertEquals("1.4.1", ai2.version);
        }

        {
            // This was error, since slf4j-log4j12 DOES NOT HAVE any class for this search!
            ArtifactInfoGroup ig = r.get("org.slf4j : slf4j-log4j12");
            ArrayList<ArtifactInfo> list = new ArrayList<ArtifactInfo>(ig.getArtifactInfos());
            assertEquals(list.toString(), 1, list.size());

            ArtifactInfo ai = list.get(0);
            assertEquals("org.slf4j", ai.groupId);
            assertEquals("slf4j-log4j12", ai.artifactId);
            assertEquals("1.4.1", ai.version);
        }
    }
}

From source file:com.ericsson.eiffel.remrem.semantics.SemanticsService.java

private String createErrorResponse(final String message, final ArrayList<String> supportedEventTypes) {
    JsonObject errorResponse = new JsonObject();
    errorResponse.addProperty(RESULT, ERROR);
    errorResponse.addProperty(MESSAGE, UNKNOWN_EVENT_TYPE_REQUESTED + "  -  " + message);
    errorResponse.addProperty(SUPPORTED_EVENT_TYPES, supportedEventTypes.toString());
    return errorResponse.toString();
}

From source file:com.mikifus.padland.PadListActivity.java

/**
 * If there is an intent with "action", here it is processed
 * For now there is only the delete action.
 *//* w  w  w .j  a  v a  2 s .  com*/
private void _actionFromIntent() {
    String action = getIntent().getStringExtra("action");
    ArrayList<String> pad_id_list = getIntent().getStringArrayListExtra("pad_id");
    if (action != null && pad_id_list.size() > 0) {
        Log.d("DELETE_PAD_INTENT", "list: " + pad_id_list.toString());
        switch (action) {
        case "delete":
            for (int i = 0; i < pad_id_list.size(); i++) {
                Log.d("DELETE_PAD_INTENT", "action: " + action + " list_get: " + pad_id_list.get(i));
                // boolean result = padlandDb.deletePad(Long.parseLong(pad_id_list.get(i)));
                //                        if (result) {
                //                            Toast.makeText(this, getString(R.string.padlist_document_deleted), Toast.LENGTH_LONG).show();
                //                        }
            }
            break;
        }
    }
    //        if( adapter != null ) {
    //            adapter.notifyDataSetChanged();
    //        }
}

From source file:org.paxle.parser.msoffice.impl.AMsOfficeParser.java

protected void extractMetadata(POIFSFileSystem fs, IParserDocument parserDoc) throws ParserException {
    DocumentInputStream docIn = null;/*from  ww  w . j a  va2s .  c  om*/
    try {
        // read the summary info
        DirectoryEntry dir = fs.getRoot();
        DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
        docIn = new DocumentInputStream(siEntry);

        // get properties
        PropertySet props = new PropertySet(docIn);
        docIn.close();

        // extract info
        SummaryInformation summary = new SummaryInformation(props);

        // doc title
        String title = summary.getTitle();
        if (title != null && title.length() > 0) {
            parserDoc.setTitle(title);
            this.logger.debug(String.format("Document title is: %s", title));
        }

        // doc author
        String author = summary.getAuthor();
        if (author != null && author.length() > 0) {
            parserDoc.setAuthor(author);
            this.logger.debug(String.format("Document author is: %s", author));
        }

        // subject
        String subject = summary.getSubject();
        if (subject != null && subject.length() > 0) {
            parserDoc.setSummary(subject);
            this.logger.debug(String.format("Document summary is: %s", subject));
        }

        // doc keywords
        String keywords = summary.getKeywords();
        if (keywords != null && keywords.length() > 0) {
            String[] keywordArray = keywords.split("[,;\\s]");
            if (keywordArray != null && keywordArray.length > 0) {
                ArrayList<String> keywordsList = new ArrayList<String>(keywordArray.length);
                for (String keyword : keywordArray) {
                    keyword = keyword.trim();
                    if (keyword.length() > 0) {
                        keywordsList.add(keyword);
                    }
                }
                parserDoc.setKeywords(keywordsList);
                this.logger.debug(String.format("Document keywords are: %s", keywordsList.toString()));
            }
        }

        // last modification date
        if (summary.getEditTime() > 0) {
            Date editTime = new Date(summary.getEditTime());
            parserDoc.setLastChanged(editTime);
            this.logger.debug(String.format("Document last-changed-date is: %s", editTime.toString()));
        } else if (summary.getCreateDateTime() != null) {
            Date creationDate = summary.getCreateDateTime();
            parserDoc.setLastChanged(creationDate);
            this.logger.debug(String.format("Document creation-date is: %s", creationDate.toString()));
        } else if (summary.getLastSaveDateTime() != null) {
            Date lastSaveDate = summary.getLastSaveDateTime();
            parserDoc.setLastChanged(lastSaveDate);
            this.logger.debug(String.format("Document last-save-date is: %s", lastSaveDate.toString()));
        }

    } catch (Exception e) {
        String errorMsg = String.format("Unexpected '%s' while extracting metadata: %s", e.getClass().getName(),
                e.getMessage());
        logger.error(errorMsg, e);
        throw new ParserException(errorMsg);
    } finally {
        if (docIn != null)
            try {
                docIn.close();
            } catch (Exception e) {
                /* ignore this */}
    }
}

From source file:edu.isi.wings.portal.controllers.RunController.java

private String getStepIds(ArrayList<RuntimeStep> steps) {
    ArrayList<String> ids = new ArrayList<String>();
    for (RuntimeStep stepexe : steps) {
        ids.add(stepexe.getName());/*from   w  w w.j  a v  a 2  s .  c  o  m*/
    }
    return ids.toString();
}

From source file:com.twentyfourseven.zira.DriverProfileInformation.java

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
    case R.id.btnSeeDriverLocation:
        // Building Parameters tripId and DriverId
        if (Util.isNetworkAvailable(DriverProfileInformation.this)) {
            ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("DriverId", mTripDetailsModel.getGetTrip_DriverId()));
            params.add(new BasicNameValuePair("TripId", SingleTon.getInstance().getDriverTripId()));

            Log.d("tag", "GetDriver Location::" + params.toString());
            AsyncTaskForZira mWebPageTask1 = new AsyncTaskForZira(DriverProfileInformation.this,
                    "GetDriverLocation", params, false, "");
            mWebPageTask1.delegate = (AsyncResponseForZira) DriverProfileInformation.this;
            mWebPageTask1.execute();/*from www  . ja  v  a  2  s.co m*/
        } else {
            Util.alertMessage(DriverProfileInformation.this, "Please check your internet connection");
        }
        break;
    case R.id.imageView_Message:
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        layoutDialog.setVisibility(View.VISIBLE);
        break;
    case R.id.buttonSend:
        try {
            InputMethodManager imm1 = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            imm1.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
        } catch (Exception e) {
            // TODO: handle exception
        }
        if (edtMessage.getText().length() == 0) {
            Util.alertMessage(DriverProfileInformation.this, "Please Write Message");
        } else {

            String userid = mTripDetailsModel.getGetTrip_DriverId();
            String message = edtMessage.getText().toString();
            String trigger = "sms";
            Log.i("tag", "userid:" + userid);
            Log.i("tag", "message:" + message);
            Log.i("tag", "trigger:" + trigger);
            // Building Parameters
            if (Util.isNetworkAvailable(DriverProfileInformation.this)) {
                ArrayList<NameValuePair> params1 = new ArrayList<NameValuePair>();
                params1.add(new BasicNameValuePair("Id", userid));
                params1.add(new BasicNameValuePair("message", message));
                params1.add(new BasicNameValuePair("trigger", trigger));

                Log.d("tag", "SendRequest::" + params1.toString());
                AsyncTaskForZira mWebPageTask = new AsyncTaskForZira(DriverProfileInformation.this,
                        sendMessages, params1, true, "Sending message...");
                mWebPageTask.delegate = (AsyncResponseForZira) DriverProfileInformation.this;
                mWebPageTask.execute();
            } else {
                Util.alertMessage(DriverProfileInformation.this, "Please check your internet connection");
            }
            //            new SendMessageParsing().execute();
            edtMessage.setText("");
        }

        break;
    case R.id.imageViewDelete:
        try {
            InputMethodManager imm1 = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            imm1.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
        } catch (Exception e) {
            // TODO: handle exception
        }
        edtMessage.setText("");
        layoutDialog.setVisibility(View.GONE);
        break;

    /*case R.id.imageView_Phone:
               
       Intent callIntent = new Intent(Intent.ACTION_CALL);
       callIntent.setData(Uri.parse(jsonmobileno));
       startActivity(callIntent);
       System.err.println("callllllllll");
       break;*/
    }

}

From source file:org.apache.hupa.server.handler.TagMessagesHandler.java

protected GenericResult executeInternal(TagMessage action, ExecutionContext context) throws ActionException {
    User user = getUser();/*from   w  w w. j ava 2 s . c  om*/
    ArrayList<Long> uids = action.getMessageUids();
    Tag tag = action.getTag();
    IMAPFolder folder = null;
    try {
        IMAPStore store = cache.get(user);
        folder = (IMAPFolder) store.getFolder(action.getFolder().getFullName());
        if (folder.isOpen() == false) {
            folder.open(Folder.READ_WRITE);
        }
        for (Message m : folder.getMessagesByUID(copyUids(uids))) {
            m.getFlags().add(tag.toString());
        }
        return new GenericResult();
    } catch (MessagingException e) {
        logger.error("Error while tag messages " + uids.toString() + " for user " + user + " of folder"
                + action.getFolder(), e);
        throw new ActionException(e);
    } finally {
        try {
            folder.close(false);
        } catch (MessagingException e) {
            // ignore on close
        }
    }
}

From source file:com.hp.test.framework.Reporting.Utlis.java

public static Map<String, List<String>> GetCountsrunsWise(ArrayList runs, String path) {
    String string = "";

    Map<String, List<String>> Run_counts = new HashMap<String, List<String>>();
    for (int count = 0; count < runs.size(); count++) {
        Boolean runhasData = false;
        String file = path + "\\" + runs.get(count) + "\\pieChart.js";

        //reading   
        try {//from  ww w . jav  a2  s  . c  o m
            InputStream ips = new FileInputStream(file);
            InputStreamReader ipsr = new InputStreamReader(ips);
            BufferedReader br = new BufferedReader(ipsr);
            String line;
            ArrayList<String> ar = new ArrayList<String>();
            while ((line = br.readLine()) != null) {
                runhasData = true;
                if (line.contains("var data")) {
                    // log.info(line);
                    String tem_ar[] = line.split("=");
                    //log.info(tem_ar[1]);
                    String temp_ar1[] = tem_ar[1].split(",");
                    String counts = "";
                    for (int i = 0; i < temp_ar1.length; i++) {
                        temp_ar1[i] = temp_ar1[i].replace("[", "");
                        temp_ar1[i] = temp_ar1[i].replace("]", "");
                        temp_ar1[i] = temp_ar1[i].replace("'", "");
                        String temp = temp_ar1[i];
                        ar.add(temp);
                        counts = counts + temp;
                        // log.info(temp_ar1[i]);

                    }
                    string += line + "\n";
                    Run_counts.put(runs.get(count).toString(), ar);
                    log.info("counts run wise-->" + runs.get(count) + "***" + ar.toString());
                    break;
                }
            }
            br.close();
        } catch (Exception e) {
            log.info(e.toString());

        }
        if (!runhasData) {
            ArrayList<String> ar = new ArrayList<String>();
            ar.add("Passed");
            ar.add("0");
            ar.add("Failed");
            ar.add("0");
            ar.add("Skipped");
            ar.add("0;");

            Run_counts.put(runs.get(count).toString(), ar);
            log.info("has NO*******  data for " + runs.get(count));
        }
    }
    return Run_counts;

}

From source file:org.ensembl.healthcheck.testcase.funcgen.MetaCoord.java

/**
 * Run the test./*from w  w  w.  j  a v  a 2s  .co m*/
 * 
 * @param funcgenDbre
 *          The database to use.
 * @return true if the test passed.
 * 
 */
public boolean run(DatabaseRegistryEntry funcgenDbre) {

    boolean result = true;

    DatabaseRegistryEntry coreDbre;

    try {

        coreDbre = getCoreDb(funcgenDbre);

    } catch (MissingMetaKeyException e) {

        ReportManager.problem(this, funcgenDbre.getConnection(), e.getMessage());
        return false;

    } catch (CoreDbNotFoundException e) {

        ReportManager.problem(this, funcgenDbre.getConnection(), e.getMessage());
        return false;

    }

    Connection funcgenCon = funcgenDbre.getConnection();
    Connection coreCon = coreDbre.getConnection();

    // coordSystems is a hash of lists of coordinate systems that each feature
    // table contains
    Map coordSystems = new HashMap();

    try {

        Statement funcgenStatement = funcgenCon.createStatement();
        Statement coreStatement = coreCon.createStatement();

        // build up a list of all the coordinate systems that are in the various
        // feature tables
        for (int tableIndex = 0; tableIndex < featureTables.length; tableIndex++) {

            String tableName = featureTables[tableIndex];
            String funcgenSql = "SELECT DISTINCT(seq_region_id) FROM " + tableName;

            logger.finest("Getting seq_region_ids for " + tableName);
            ResultSet funcgenRs = funcgenStatement.executeQuery(funcgenSql);

            ArrayList<String> seqRegionIDs = new ArrayList<>();

            if (!funcgenRs.isBeforeFirst()) {
                logger.warning("No features found for " + tableName);
                continue;
            }

            if (funcgenRs.next())
                while (funcgenRs.next()) {
                    seqRegionIDs.add(funcgenRs.getString(1));
                }

            String seqRegionIDsString = seqRegionIDs.toString().replace("[", "").replace("]", "");
            String coreSql = "SELECT DISTINCT(coord_system_id) FROM seq_region WHERE seq_region_id IN ("
                    + seqRegionIDsString + ")";
            logger.finest("Getting coord_system_ids for " + tableName);
            ResultSet coreRs = coreStatement.executeQuery(coreSql);

            while (coreRs.next()) {
                String coordSystemID = coreRs.getString(1);
                logger.finest("Added feature coordinate system for " + tableName + ": " + coordSystemID);
                // check that the meta_coord table has an entry corresponding to this
                int mc = DBUtils.getRowCount(funcgenCon,
                        "SELECT COUNT(*) FROM meta_coord WHERE coord_system_id=" + coordSystemID
                                + " AND table_name='" + tableName + "'");
                if (mc == 0) {
                    ReportManager.problem(this, funcgenCon, "No entry for coordinate system with ID "
                            + coordSystemID + " for " + tableName + " in meta_coord");
                    result = false;
                } else if (mc > 1) {
                    ReportManager.problem(this, funcgenCon, "Coordinate system with ID " + coordSystemID
                            + " duplicated for " + tableName + " in meta_coord");
                    result = false;
                } else {
                    ReportManager.correct(this, funcgenCon, "Coordinate system with ID " + coordSystemID
                            + " for table " + tableName + " has an entry in meta_coord");
                }

                // store in coordSystems map - create List if necessary
                List csList = (ArrayList) coordSystems.get(tableName);
                if (csList == null) {
                    csList = new ArrayList();
                }
                csList.add(coordSystemID);
                coordSystems.put(tableName, csList);
            }

            funcgenRs.close();

        }

        // check that every meta_coord table entry refers to a coordinate system
        // that is used in a feature
        // if this isn't true it's not fatal but should be flagged
        String sql = "SELECT * FROM meta_coord";
        ResultSet rs = funcgenStatement.executeQuery(sql);
        while (rs.next()) {
            String tableName = rs.getString("table_name");
            String csID = rs.getString("coord_system_id");
            logger.finest("Checking for coord_system_id " + csID + " in " + tableName);
            List featureCSs = (ArrayList) coordSystems.get(tableName);
            if (featureCSs != null && !featureCSs.contains(csID)) {
                ReportManager.problem(this, funcgenCon,
                        "meta_coord has entry for coord_system ID " + csID + " in " + tableName
                                + " but this coordinate system is not actually used in " + tableName);
                result = false;
            }

        }

        rs.close();
        funcgenStatement.close();

        // check that there are no null max_length entries
        result &= checkNoNulls(funcgenCon, "meta_coord", "max_length");

    } catch (SQLException e) {
        e.printStackTrace();
    }

    return result;

}

From source file:com.hanuor.sapphire.utils.intentation.IntentationPrime.java

public String intentToJSON(Context con, Intent intent) throws JsonProcessingException {

    ObjectMapper mapper = new ObjectMapper();
    String getContextName = null;
    String getClassName = null;/*from www  . j av  a2  s .  c o m*/
    try {
        getClassName = intent.getComponent().getClassName();
        getContextName = con.getPackageName();
    } catch (Exception e) {
        e.printStackTrace();

    }
    HashMap<String, String> makeInsideJsonArray = new HashMap<String, String>();

    HashMap<String, String> hashMap = new HashMap<String, String>();
    hashMap.put("className", getClassName);
    hashMap.put("context", getContextName);
    Bundle bundle = intent.getExtras();
    if (bundle != null) {
        Set<String> keys = bundle.keySet();
        Iterator<String> it = keys.iterator();
        Log.d("SappsnoopDog", "" + keys.size());
        while (it.hasNext()) {
            String key = it.next();

            Log.d("Sapptagdog", "TYPE   " + bundle.get(key).toString());
            Log.d("NERVE", "" + bundle.get(key).getClass().getAnnotations());

            String type = bundle.get(key).getClass().getSimpleName();
            Log.d("SappDogTAG", key + " OF TYPE " + type);
            switch (type) {
            case "String":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());
                Log.d("SappDogTAG", "bool array");
                break;
            case "String[]":
                makeInsideJsonArray.put(key,
                        type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString().replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;
            case "Integer":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());

                Log.d("SappDogTAG", "bool array");
                break;
            case "Double":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());
                Log.d("SappDogTAG", "bool array");
                break;
            case "double[]":

                double[] newDouble = (double[]) bundle.get(key);
                String fromDouble = Arrays.toString(newDouble);
                makeInsideJsonArray.put(key,
                        type + LibraryDatabase.JSONSEPERATOR + fromDouble.replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;
            case "int[]":
                int[] newArray = (int[]) bundle.get(key);
                String fromArray = Arrays.toString(newArray);
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromArray.replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;
            case "Boolean":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());
                Log.d("SappDogTAG", "bool array");
                break;
            case "boolean[]":

                boolean[] newBool = (boolean[]) bundle.get(key);
                String fromBool = Arrays.toString(newBool);
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromBool.replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;
            case "Char":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());
                Log.d("SappDogTAG", "bool array");
                break;
            case "char[]":

                char[] newChar = (char[]) bundle.get(key);
                String fromChar = Arrays.toString(newChar);
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromChar.replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;
            case "CharSequence":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());
                Log.d("SappDogTAG", "bool array");
                break;
            case "charsequence[]":

                makeInsideJsonArray.put(key,
                        type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString().replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;
            case "Byte":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());
                Log.d("SappDogTAG", "bool array");
                break;
            case "byte[]":

                byte[] newByte = (byte[]) bundle.get(key);
                String fromByte = Arrays.toString(newByte);
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromByte.replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;
            case "Float":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());
                Log.d("SappDogTAG", "bool array");
                break;
            case "float[]":

                float[] newFloat = (float[]) bundle.get(key);
                String fromFloat = Arrays.toString(newFloat);
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromFloat.replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;
            case "Short":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());
                Log.d("SappDogTAG", "bool array");
                break;
            case "short[]":

                short[] newShort = (short[]) bundle.get(key);
                String fromShort = Arrays.toString(newShort);
                fromShort = fromShort.replace(" ", "");
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromShort.replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;
            case "Long":
                makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString());
                Log.d("SappDogTAG", "bool array");
                break;
            case "long[]":

                long[] newLong = (long[]) bundle.get(key);
                String fromLong = Arrays.toString(newLong);
                makeInsideJsonArray.put(key,
                        type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString().replace(" ", ""));
                Log.d("SappDogTAG", "bool array");
                break;

            case "ArrayList":
                ArrayList<Object> obj = (ArrayList<Object>) bundle.get(key);
                Object[] objArr = obj.toArray();
                if (objArr[0] instanceof Integer) {
                    ArrayList<Integer> newIntegerArray = bundle.getIntegerArrayList(key);
                    makeInsideJsonArray.put(key, type + "Integer" + LibraryDatabase.JSONSEPERATOR
                            + newIntegerArray.toString().replace(" ", ""));

                } else if (objArr[0] instanceof String) {
                    ArrayList<String> newStringArray = bundle.getStringArrayList(key);

                    makeInsideJsonArray.put(key, type + "String" + LibraryDatabase.JSONSEPERATOR
                            + newStringArray.toString().replace(" ", ""));

                }
                break;

            default:
                // whatever
            }

            hashMap.put(key, bundle.get(key).toString());
        }
    }
    String passArray = mapper.writeValueAsString(makeInsideJsonArray);
    hashMap.put("intentExtras", passArray);
    Log.d("GOGTAD", "" + passArray);

    String intentString = mapper.writeValueAsString(intent);
    Log.d("IntentString", "" + mapper.writeValueAsString(hashMap));
    StringBuilder a1S = new StringBuilder(mapper.writeValueAsString(hashMap));
    a1S.deleteCharAt(mapper.writeValueAsString(hashMap).length() - 1);
    a1S.append(",");
    String s1t = a1S.toString();

    StringBuilder sb = new StringBuilder(intentString);
    sb.deleteCharAt(0);
    String retrString = sb.toString();
    StringBuilder newS = new StringBuilder();
    newS.append(s1t);
    newS.append(retrString);
    Log.d("Insnsns", newS.toString());
    return newS.toString();
}