Android Open Source - Cardeto Json Renderer






From Project

Back to project page Cardeto.

License

The source code is released under:

Apache License

If you think the Android project Cardeto listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ggt.cardeto.embeddedwebserver.sqlitemodule.tableouputrenderers;
//from  w  w  w.  j  av  a  2s .  co  m
import java.util.List;

/**
 * Simple Json renderer.
 * 
 * Needs a lot improvements, tests and fixes.
 * 
 * @author idapps103
 * 
 */
public class JsonRenderer implements TableOutputRenderer {

  @Override
  public void renderHeader(StringBuilder output, List<String> tablesList) {
    output.append("{\n");
  }

  @Override
  public void renderTable(StringBuilder output, String tableName,
      List<String> columns, List<List<String>> rows) {
    output.append("\"" + tableName + "\":[\n");
    for (List<String> row : rows) {
      output.append("{");
      for (int i = 0; i < row.size(); i++) {
        output.append("\"" + columns.get(i) + "\":");
        output.append("\"" + row.get(i) + "\"");
        output.append(",");
      }
      if (row.size() > 0)
        output.deleteCharAt(output.length() - 1);
      output.append("},");
    }
    if (rows.size() > 0)
      output.deleteCharAt(output.length() - 1);
    output.append("]\n");
  }

  @Override
  public void renderFooter(StringBuilder output) {
    output.append("}\n");
  }

}




Java Source Code List

com.ggt.cardeto.CardetoService.java
com.ggt.cardeto.embeddedwebserver.CardetoWebServerModule.java
com.ggt.cardeto.embeddedwebserver.CardetoWebServer.java
com.ggt.cardeto.embeddedwebserver.appinfomodule.AppInfoModule.java
com.ggt.cardeto.embeddedwebserver.clipboardmodule.ClipboardModule.java
com.ggt.cardeto.embeddedwebserver.logcatmodule.LogcatModule.java
com.ggt.cardeto.embeddedwebserver.sqlitemodule.GenericSQLiteDatabaseHelper.java
com.ggt.cardeto.embeddedwebserver.sqlitemodule.SQLiteModule.java
com.ggt.cardeto.embeddedwebserver.sqlitemodule.tableouputrenderers.CSVRenderer.java
com.ggt.cardeto.embeddedwebserver.sqlitemodule.tableouputrenderers.HtmlRenderer.java
com.ggt.cardeto.embeddedwebserver.sqlitemodule.tableouputrenderers.JsonRenderer.java
com.ggt.cardeto.embeddedwebserver.sqlitemodule.tableouputrenderers.TableOutputRenderer.java
com.ggt.cardeto.embeddedwebserver.sqlitemodule.tableouputrenderers.XmlRenderer.java
com.ggt.cardeto.embeddedwebserver.staticvarsmodule.StaticVarsModule.java
com.ggt.cardeto.externallib.NanoHTTPD.java
com.ggt.cardeto.utils.CardetoConstants.java
com.ggt.cardeto.utils.NetworkUtilsOld.java
com.ggt.cardeto.utils.NetworkUtils.java
com.ggt.cardetosample.TestActivity.java
com.ggt.cardetosample.database.CardetoSampleDatabaseDataSource.java
com.ggt.cardetosample.database.CardetoSampleDatabaseHelper.java
com.ggt.cardetosample.database.Log.java