Refactored code.
This commit is contained in:
parent
26e644b821
commit
11baf9644d
1 changed files with 112 additions and 114 deletions
|
@ -20,6 +20,7 @@ import org.apache.log4j.Level;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.util.strings.StringList;
|
||||
import fr.devinsy.xidyn.data.SimpleTagData;
|
||||
import fr.devinsy.xidyn.data.TagDataManager;
|
||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||
|
@ -50,70 +51,76 @@ class XidynDemo
|
|||
TagDataManager data;
|
||||
|
||||
// Step #01.
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("----------------------------");
|
||||
|
||||
// Populate attributes.
|
||||
String htmlSource = "<div id='pseudo'>a pseudo</div >";
|
||||
|
||||
data = new TagDataManager();
|
||||
data.setContent("name", "Superman");
|
||||
|
||||
String htmlSource = "<div id='name'>a name</div >";
|
||||
StringBuffer htmlTarget;
|
||||
try
|
||||
{
|
||||
htmlTarget = PresenterUtils.dynamize(htmlSource, data);
|
||||
String htmlTarget = PresenterUtils.dynamize(htmlSource, data).toString();
|
||||
|
||||
System.out.println("datas = new Data ();");
|
||||
System.out.println("datas.setContent (\"pseudo\", \"Superman\");");
|
||||
System.out.println("+");
|
||||
System.out.println("<div id='pseudo'>a pseudo</div >");
|
||||
System.out.println("=>");
|
||||
System.out.println(htmlTarget);
|
||||
System.out.println("[" + htmlSource.length() + "] => [" + htmlTarget.length() + "]");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
htmlTarget = null;
|
||||
}
|
||||
System.out.println("datas = new Data ();");
|
||||
System.out.println("datas.setContent (\"name\", \"Superman\");");
|
||||
System.out.println("+");
|
||||
System.out.println("<div id='name'>a name</div >");
|
||||
System.out.println("=>");
|
||||
System.out.println(htmlTarget);
|
||||
System.out.println("[" + htmlSource.length() + "] => [" + htmlTarget.length() + "]");
|
||||
}
|
||||
|
||||
// Step #02.
|
||||
{
|
||||
System.out.println("----------------------------");
|
||||
// Populate attributes.
|
||||
data = new TagDataManager();
|
||||
data.setContent("lastname", "Spiderman");
|
||||
data.appendAttribute("lastname", "style", "background: blue;");
|
||||
data.appendAttribute("lastname", "style", "foreground: red;");
|
||||
data.setAttribute("lastname", "class", "nameClass");
|
||||
|
||||
String htmlSource = "<div id='lastname'>a last name</div >";
|
||||
StringBuffer htmlTarget;
|
||||
try
|
||||
{
|
||||
htmlTarget = PresenterUtils.dynamize(htmlSource, data);
|
||||
System.out.println("----------------------------");
|
||||
|
||||
String htmlSource = "<div id='lastname'>a last name</div >";
|
||||
|
||||
data = new TagDataManager();
|
||||
data.setContent("pseudo", "Spiderman");
|
||||
data.appendAttribute("pseudo", "style", "background: blue;");
|
||||
data.appendAttribute("pseudo", "style", "foreground: red;");
|
||||
data.setAttribute("pseudo", "class", "nameClass");
|
||||
|
||||
String htmlTarget = PresenterUtils.dynamize(htmlSource, data).toString();
|
||||
|
||||
System.out.println("<div id='lastname'>a last name</div>");
|
||||
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("=>");
|
||||
System.out.println(htmlTarget);
|
||||
System.out.println("[" + htmlSource.length() + "] => [" + htmlTarget.length() + "]");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
htmlTarget = null;
|
||||
}
|
||||
|
||||
System.out.println("datas = new Data ();");
|
||||
System.out.println("datas.setContent (\"lastname\", \"Spiderman\");");
|
||||
System.out.println("datas.appendAttribute (\"lastname\", \"style\", \"background: blue;\");");
|
||||
System.out.println("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");");
|
||||
System.out.println("datas.setAttribute (\"lastname\", \"class\", \"nameClass\");");
|
||||
System.out.println("+");
|
||||
System.out.println("<div id='lastname'>a last name</div>");
|
||||
System.out.println("=>");
|
||||
System.out.println(htmlTarget);
|
||||
System.out.println("[" + htmlSource.length() + "] => [" + htmlTarget.length() + "]");
|
||||
}
|
||||
|
||||
// Step #03.
|
||||
{
|
||||
System.out.println("----------------------------");
|
||||
try
|
||||
{
|
||||
StringList source = new StringList();
|
||||
source.appendln("<ul>");
|
||||
source.appendln(" <li id='words'>a word</li>");
|
||||
source.appendln("</ul>");
|
||||
String htmlSource = source.toString();
|
||||
|
||||
// Populate attributes.
|
||||
data = new TagDataManager();
|
||||
data.setContent("words", 0, "alpha");
|
||||
|
@ -123,18 +130,10 @@ class XidynDemo
|
|||
data.setContent("words", 4, "echo");
|
||||
data.setContent("words", 5, "fox");
|
||||
|
||||
String htmlSource = "<ul>\n <li id='words'>a word</li>\n</ul>";
|
||||
StringBuffer htmlTarget;
|
||||
try
|
||||
{
|
||||
htmlTarget = PresenterUtils.dynamize(htmlSource, data);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
htmlTarget = null;
|
||||
}
|
||||
String htmlTarget = PresenterUtils.dynamize(htmlSource, data).toString();
|
||||
|
||||
System.out.println(htmlSource);
|
||||
System.out.println("+");
|
||||
System.out.println("datas = new Data ();");
|
||||
System.out.println("datas.setContent (\"words\", 0, \"alpha\");");
|
||||
System.out.println("datas.setContent (\"words\", 1, \"bravo\");");
|
||||
|
@ -142,18 +141,28 @@ class XidynDemo
|
|||
System.out.println("datas.setContent (\"words\", 3, \"delta\");");
|
||||
System.out.println("datas.setContent (\"words\", 4, \"echo\");");
|
||||
System.out.println("datas.setContent (\"words\", 5, \"fox\");");
|
||||
System.out.println("+");
|
||||
System.out.println("<ul>");
|
||||
System.out.println(" <li id='words'>a word</li>");
|
||||
System.out.println("</ul>");
|
||||
System.out.println("=>");
|
||||
System.out.println(htmlTarget);
|
||||
System.out.println("[" + htmlSource.length() + "] => [" + htmlTarget.length() + "]");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Step #04.
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("----------------------------");
|
||||
|
||||
StringBuffer source = new StringBuffer();
|
||||
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();
|
||||
data.setContent("identity", 0, "last_name", "Jemba");
|
||||
|
@ -163,23 +172,10 @@ class XidynDemo
|
|||
data.setContent("identity", 2, "last_name", "Tronche");
|
||||
data.setContent("identity", 2, "first_name", "Christophe");
|
||||
|
||||
StringBuffer source = new StringBuffer();
|
||||
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();
|
||||
StringBuffer htmlTarget;
|
||||
try
|
||||
{
|
||||
htmlTarget = PresenterUtils.dynamize(htmlSource, data);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
htmlTarget = null;
|
||||
}
|
||||
StringBuffer htmlTarget = PresenterUtils.dynamize(htmlSource, data);
|
||||
|
||||
System.out.println(htmlSource);
|
||||
System.out.println("+");
|
||||
System.out.println("datas = new Data ();");
|
||||
System.out.println("datas.setContent (\"identity\", 0, \"last_name\", \"Jemba\");");
|
||||
System.out.println("datas.setContent (\"identity\", 0, \"first_name\", \"Epo\");");
|
||||
|
@ -187,17 +183,30 @@ class XidynDemo
|
|||
System.out.println("datas.setContent (\"identity\", 1, \"first_name\", \"Christian\");");
|
||||
System.out.println("datas.setContent (\"identity\", 2, \"last_name\", \"Tronche\");");
|
||||
System.out.println("datas.setContent (\"identity\", 2, \"first_name\", \"Christophe\");");
|
||||
|
||||
System.out.println("+");
|
||||
System.out.println(htmlSource);
|
||||
System.out.println("=>");
|
||||
System.out.println(htmlTarget);
|
||||
System.out.println("[" + htmlSource.length() + "] => [" + htmlTarget.length() + "]");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Step #05.
|
||||
{
|
||||
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");
|
||||
String htmlSource = source.toString();
|
||||
|
||||
// Populate attributes.
|
||||
data = new TagDataManager();
|
||||
data.setContent("identity", 0, "last_name", "Jemba");
|
||||
|
@ -213,16 +222,8 @@ class XidynDemo
|
|||
// datas.setIterationStrategy ("identity",
|
||||
// IdsDataByIndex.IterationStrategy.ALL_ROWS);
|
||||
|
||||
//
|
||||
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");
|
||||
String htmlSource = source.toString();
|
||||
|
||||
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\");");
|
||||
|
@ -230,9 +231,6 @@ class XidynDemo
|
|||
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("+");
|
||||
System.out.println(htmlSource);
|
||||
System.out.println("=>");
|
||||
|
||||
// #05.1
|
||||
|
|
Loading…
Reference in a new issue