Android Open Source - Cardeto Html 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  a va  2 s .c o m*/
import android.content.Context;
import android.text.TextUtils;

import com.ggt.cardeto.R;
import com.ggt.cardeto.utils.CardetoConstants;

import java.util.List;

/**
 * Simple HTML renderer.
 * <p/>
 * Needs a lot improvements, tests and fixes.
 *
 * @author idapps103
 */
public class HtmlRenderer implements TableOutputRenderer {

    private Context mContext;

    public HtmlRenderer(Context context) {
        mContext = context;
    }

    @Override
    public void renderHeader(StringBuilder output, List<String> tablesList) {
        output.append(mContext.getString(R.string.html_header));
        output.append(CardetoConstants.HTML_RETURN + "\n");

        if (tablesList != null) {
            for (String tableName : tablesList) {
                output.append("<B><a href=\"#" + tableName + "\">" + tableName
                        + "</a></B>" + CardetoConstants.HTML_RETURN + "\n");
            }
        }
        output.append(CardetoConstants.HTML_RETURN + "\n");
    }

    @Override
    public void renderTable(StringBuilder output, String tableName,
                            List<String> columns, List<List<String>> rows) {
        output.append("<B><a name=\"" + tableName + "\">" + tableName
                + "</a></B>" + CardetoConstants.HTML_RETURN + "\n");
        // display columns
        output.append("<table>\n<tbody>\n");
        if (columns != null && columns.size() > 0) {
            output.append("<tr>\n");
            for (String column : columns) {
                output.append("<td>\n");
                output.append("<B>" + column + "</B>\n");
                output.append("</td>\n");
            }
            output.append("</tr>\n");
        }
        // display rows
        for (List<String> row : rows) {
            output.append("<tr>\n");
            for (String data : row) {
                output.append("<td>\n");
                if (data != null) {
                    output.append(TextUtils.htmlEncode(data) + "\n");
                }
                output.append("</td>\n");
            }
            output.append("</tr>\n");
        }
        output.append("</tbody>\n</table>\n");
        output.append(CardetoConstants.HTML_RETURN + "\n");
    }

    @Override
    public void renderFooter(StringBuilder output) {
        output.append(CardetoConstants.HTML_RETURN + "\n");
        output.append(mContext.getString(R.string.html_footer));
    }

}




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