Refactored demo.

This commit is contained in:
Christian P. MOMON 2016-09-19 03:48:36 +02:00
parent 11baf9644d
commit 1d574e700f
2 changed files with 24 additions and 50 deletions

View file

@ -45,11 +45,6 @@ class XidynDemo
{
System.out.println("Hello World!");
// test ();
//
TagDataManager data;
// Step #01.
{
try
@ -58,7 +53,7 @@ class XidynDemo
String htmlSource = "<div id='pseudo'>a pseudo</div >";
data = new TagDataManager();
TagDataManager data = new TagDataManager();
data.setContent("name", "Superman");
String htmlTarget = PresenterUtils.dynamize(htmlSource, data).toString();
@ -83,23 +78,23 @@ class XidynDemo
{
System.out.println("----------------------------");
String htmlSource = "<div id='lastname'>a last name</div >";
String htmlSource = "<div id=\"pseudo\">a pseudo</div >";
data = new TagDataManager();
TagDataManager data = new TagDataManager();
data.setContent("pseudo", "Spiderman");
data.appendAttribute("pseudo", "style", "background: blue;");
data.appendAttribute("pseudo", "style", "foreground: red;");
data.setAttribute("pseudo", "class", "nameClass");
data.setAttribute("pseudo", "class", "superhero");
String htmlTarget = PresenterUtils.dynamize(htmlSource, data).toString();
System.out.println("<div id='lastname'>a last name</div>");
System.out.println(htmlSource);
System.out.println("+");
System.out.println("datas = new Data ();");
System.out.println("datas.setContent (\"pseudo\", \"Spiderman\");");
System.out.println("datas.appendAttribute (\"pseudo\", \"style\", \"background: blue;\");");
System.out.println("datas.appendAttribute (\"pseudo\", \"style\", \"foreground: red;\");");
System.out.println("datas.setAttribute (\"pseudo\", \"class\", \"nameClass\");");
System.out.println("datas.setAttribute (\"pseudo\", \"class\", \"superhero\");");
System.out.println("=>");
System.out.println(htmlTarget);
System.out.println("[" + htmlSource.length() + "] => [" + htmlTarget.length() + "]");
@ -122,7 +117,7 @@ class XidynDemo
String htmlSource = source.toString();
// Populate attributes.
data = new TagDataManager();
TagDataManager data = new TagDataManager();
data.setContent("words", 0, "alpha");
data.setContent("words", 1, "bravo");
data.setContent("words", 2, "charlie");
@ -157,14 +152,14 @@ class XidynDemo
{
System.out.println("----------------------------");
StringBuffer source = new StringBuffer();
StringList source = new StringList();
source.append("<table>\n");
source.append(" <tr id='identity'><td>noid</td><td id='first_name'>Jean</td><td id='last_name'>Reve</td></tr>\n");
source.append("</table>");
String htmlSource = source.toString();
// Populate attributes.
data = new TagDataManager();
TagDataManager data = new TagDataManager();
data.setContent("identity", 0, "last_name", "Jemba");
data.setContent("identity", 0, "first_name", "Epo");
data.setContent("identity", 1, "last_name", "Momon");
@ -198,43 +193,23 @@ class XidynDemo
System.out.println("----------------------------");
//
StringBuffer source = new StringBuffer();
source.append("<table id=\"identities\">\n");
source.append(" <tr id='the_head'><th>noid</th><th>First Name</th><th>Last Name</th></tr>\n");
source.append(" <tr id='identity'><td>noid</td><td id='first_name'>Jean</td><td id='last_name'>Reve</td></tr>\n");
source.append(" <tr id='identity_bis'><td>noid</td><td id='first_name_bis'>a first name</td><td id='last_name_bis'>a last name</td></tr>\n");
source.append(" <tr><td>noid</td><td id='first_name_ter'>a first name more</td><td id='last_name_ter'>a last name more</td></tr>\n");
source.append("</table>\n");
StringList source = new StringList();
source.appendln("<ul id=\"words\">");
source.appendln(" <li id=\"first\">alpha</li>");
source.appendln(" <li id=\"second\">bravo</li>");
source.appendln(" <li id=\"third\">charlie</li>");
source.appendln(" <li>delta</li>");
source.appendln("</ul>");
String htmlSource = source.toString();
// Populate attributes.
data = new TagDataManager();
data.setContent("identity", 0, "last_name", "Jemba");
data.setContent("identity", 0, "first_name", "Epo");
data.setContent("identity", 1, "last_name", "Momon");
data.setContent("identity", 1, "first_name", "Christian");
data.setContent("identity", 2, "last_name", "Tronche");
data.setContent("identity", 2, "first_name", "Christophe");
// datas.setIterationStrategy ("identity",
// IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID);
// datas.setIterationStrategy ("identity",
// IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID);
// datas.setIterationStrategy ("identity",
// IdsDataByIndex.IterationStrategy.ALL_ROWS);
TagDataManager data = new TagDataManager();
System.out.println(htmlSource);
System.out.println("+");
System.out.println("datas = new Data ();");
System.out.println("datas.setContent (\"identity\", 0, \"first_name\", \"Epo\");");
System.out.println("datas.setContent (\"identity\", 0, \"last_name\", \"Jemba\");");
System.out.println("datas.setContent (\"identity\", 1, \"first_name\", \"Christian\");");
System.out.println("datas.setContent (\"identity\", 1, \"last_name\", \"Momon\");");
System.out.println("datas.setContent (\"identity\", 2, \"first_name\", \"Christophe\");");
System.out.println("datas.setContent (\"identity\", 2, \"last_name\", \"Tronche\");");
System.out.println("=>");
// #05.1
data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ONLY_FIRST_ROW);
data.setIterationStrategy("words", SimpleTagData.IterationStrategy.ONLY_FIRST_ROW);
System.out.println("ONLY_FIRST_ROW:");
StringBuffer html;
try
@ -250,7 +225,7 @@ class XidynDemo
System.out.println("");
// #05.2
data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ONLY_FIRST_TWO_ROWS);
data.setIterationStrategy("words", SimpleTagData.IterationStrategy.ONLY_FIRST_TWO_ROWS);
System.out.println("ONLY_FIRST_TWO_ROWS:");
try
{
@ -265,7 +240,7 @@ class XidynDemo
System.out.println("");
// #05.3
data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ONLY_ROWS_WITH_ID);
data.setIterationStrategy("words", SimpleTagData.IterationStrategy.ONLY_ROWS_WITH_ID);
System.out.println("ONLY_ROWS_WITH_ID:");
try
{
@ -280,7 +255,7 @@ class XidynDemo
System.out.println("");
// #05.4
data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ONLY_ROWS_WITHOUT_ID);
data.setIterationStrategy("words", SimpleTagData.IterationStrategy.ONLY_ROWS_WITHOUT_ID);
System.out.println("ONLY_ROWS_WITHOUT_ID:");
try
{
@ -295,7 +270,7 @@ class XidynDemo
System.out.println("");
// #05.5
data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ALL_ROWS);
data.setIterationStrategy("words", SimpleTagData.IterationStrategy.ALL_ROWS);
System.out.println("ALL_ROWS:");
try
{

View file

@ -51,9 +51,8 @@ public class TagDataManager
if (tags == null)
{
this.idsDataById.setId(id, new TagDataListByIndex());
tags = (TagDataListByIndex) this.idsDataById.getId(id);
tags = new TagDataListByIndex();
this.idsDataById.setId(id, tags);
}
// Be sure that lines are existing.