Menu

Home

Sean McEligot

HTML

Put the compiler to work as much possible in verifity your HTML is correct.

Node body =  body();
  html( 
      head( n("title", t("Bookmarks")),
      body));

  body.add(n("div",a("id","urls"),
          n("h3", t("by hostname")), 
          byHostTable,
          n("br")));
  body.add(n("div",
      n("form", a("action", "/hweb/bm"), a("method","post"), 
          t("name"), n("input", a("name","name")),
          n("br"),
          t("url"), n("input", a("name","url")),
          n("input", a("type","submit"))
          )));

NoSQL

Dbm dbm = new Dbm();
dbm.open();
long rowid = -1L;
try {
  Schema schema = createSchema("secondary");
  DbIndex bySubject = new DbIndex("subject", ColType.STRING);
  schema.addIndex(bySubject);

  DbTable table = dbm.getTable(schema);
  {
    {
    DbRow row = table.newRow();
    row.setString("subject", "first");
    row.setString("text", "first text");
    table.saveRow(row);
    }
    {
  DbRow row = table.newRow();
  row.setString("subject", "Hello");
  row.setString("text", "Hello World!");
    table.saveRow(row);
    rowid = row.getRowId();
    }
    {
  DbRow row = table.newRow();
  row.setString("subject", "last");
  row.setString("text", "last text");
      table.saveRow(row);
    }
  }
  {
  DbRow row = table.getRow(bySubject, new DatabaseColumn("Hello"));
  String subject = row.getString("subject");
  String text = row.getString("text");
  System.out.println("get row by subject: "+row.getRowId()+":"+row.getString("subject"));
  assertEquals(rowid, row.getRowId());
  assertEquals("Hello", subject);
  assertEquals("Hello World!", text);
  }
} finally {
  dbm.close();
}

Functional Programming

String[][] strings = new String[][]{
    {"A", "B", "C", "D"},
    {"1","2", "3","4"},
    {"5","6", "7","8"},
    };
F2<Table, String[], Table> fun = new NodeOperators.StringGridToTable();
Table table = Functions.reduce(fun, table(), strings);
// write html to a tmp file and render in firefox for testing
Render.browse("firefox", table);
// print html source
System.out.println(table.writeString());

Output:

A B C D
1 2 3 4
5 6 7 8