small fix.

This commit is contained in:
administrateur 2007-02-07 07:30:24 +01:00
parent faf7fd7fb0
commit 5bc5964bd6
5 changed files with 173 additions and 186 deletions

Binary file not shown.

View file

@ -60,7 +60,7 @@ class Demo
datas.setContent ("name", "Superman"); datas.setContent ("name", "Superman");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='name'>a name</div >", datas, errorMessage);
System.out.println ("datas = new Data ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"name\", \"Superman\");"); System.out.println ("datas.setContent (\"name\", \"Superman\");");
@ -80,7 +80,7 @@ class Demo
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, errorMessage);
System.out.println ("datas = new Data ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");");
@ -105,7 +105,7 @@ class Demo
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, "", errorMessage); html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, errorMessage);
System.out.println ("datas = new Data ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); System.out.println ("datas.setContent (\"words\", 0, \"alpha\");");
@ -139,7 +139,7 @@ class Demo
source.append (" <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n"); source.append (" <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n");
source.append ("</table>"); source.append ("</table>");
htmlSource = source.toString (); htmlSource = source.toString ();
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println ("datas = new Data ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");"); System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");");
@ -194,22 +194,22 @@ class Demo
datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW);
System.out.println ("ONLY_FIRST_ROW:"); System.out.println ("ONLY_FIRST_ROW:");
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html); System.out.println (html);
datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID);
System.out.println ("ONLY_ROWS_WITH_ID:"); System.out.println ("ONLY_ROWS_WITH_ID:");
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html); System.out.println (html);
datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID);
System.out.println ("ONLY_ROWS_WITHOUT_ID:"); System.out.println ("ONLY_ROWS_WITHOUT_ID:");
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html); System.out.println (html);
datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS); datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS);
System.out.println ("ALL_ROWS:"); System.out.println ("ALL_ROWS:");
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html); System.out.println (html);
@ -230,7 +230,7 @@ class Demo
source.append (" <h1>three</h1>\n"); source.append (" <h1>three</h1>\n");
source.append ("</div>"); source.append ("</div>");
htmlSource = source.toString (); htmlSource = source.toString ();
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (htmlSource); System.out.println (htmlSource);
System.out.println ("+"); System.out.println ("+");

View file

@ -1,5 +1,3 @@
package xid.test;
import java.util.*; import java.util.*;
import java.io.*; import java.io.*;
import xid.*; import xid.*;
@ -7,7 +5,7 @@ import xid.*;
/** /**
* *
*/ */
class Test class Demo
{ {
static private org.apache.log4j.Logger log; static private org.apache.log4j.Logger log;
@ -33,7 +31,7 @@ class Test
log.info ("... done."); log.info ("... done.");
log.debug ("Exit"); log.debug ("Exit");
log = org.apache.log4j.Logger.getLogger (Test.class.getName ()); log = org.apache.log4j.Logger.getLogger (Demo.class.getName ());
} }
@ -47,7 +45,7 @@ class Test
//test (); //test ();
// //
IdsData datas; Data datas;
IdData tag; IdData tag;
@ -58,33 +56,13 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
tag = new IdData ();
tag.setContent ("Superman");
datas.put ("name", tag);
errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();");
System.out.println ("tag = new IdData ();");
System.out.println ("tag.setContent (\"Superman\");");
System.out.println ("datas.put (\"name\", tag););");
System.out.println ("+");
System.out.println ("<div id='name'>a name</div >");
System.out.println ("=>");
System.out.println (html);
// Populate attributes of Test 03.
System.out.println ("----------------------------");
datas = new IdsData ();
datas.setContent ("name", "Superman"); datas.setContent ("name", "Superman");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"name\", \"Superman\");"); System.out.println ("datas.setContent (\"name\", \"Superman\");");
System.out.println ("+"); System.out.println ("+");
System.out.println ("<div id='name'>a name</div >"); System.out.println ("<div id='name'>a name</div >");
@ -94,34 +72,7 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
tag = new IdData ();
tag.setContent ("Spiderman");
tag.getAttributes ().appendAttribute ("style", "background: blue;");
tag.getAttributes ().appendAttribute ("style", "foreground: red;");
tag.getAttributes ().setAttribute ("class", "nameClass");
datas.put ("lastname", tag);
errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();");
System.out.println ("tag = new IdData ();");
System.out.println ("tag.getAttributes ().setAttribute (\"class\", \"lastnameClass\");");
System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"background: blue;\");");
System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"foreground: red;\");");
System.out.println ("tag.setContent (\"Spiderman\");");
System.out.println ("datas.put (\"lastname\", tag););");
System.out.println ("+");
System.out.println ("<div id='lastname'>a last name</div>");
System.out.println ("=>");
System.out.println (html);
// Populate attributes of Test 03.
System.out.println ("----------------------------");
datas = new IdsData ();
datas.setContent ("lastname", "Spiderman"); datas.setContent ("lastname", "Spiderman");
datas.appendAttribute ("lastname", "style", "background: blue;"); datas.appendAttribute ("lastname", "style", "background: blue;");
datas.appendAttribute ("lastname", "style", "foreground: red;"); datas.appendAttribute ("lastname", "style", "foreground: red;");
@ -131,7 +82,7 @@ class Test
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");");
System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"background: blue;\");"); System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"background: blue;\");");
System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");"); System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");");
@ -144,7 +95,7 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
datas.setContent ("words", 0, "alpha"); datas.setContent ("words", 0, "alpha");
datas.setContent ("words", 1, "bravo"); datas.setContent ("words", 1, "bravo");
datas.setContent ("words", 2, "charlie"); datas.setContent ("words", 2, "charlie");
@ -156,7 +107,7 @@ class Test
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, "", errorMessage); html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); System.out.println ("datas.setContent (\"words\", 0, \"alpha\");");
System.out.println ("datas.setContent (\"words\", 1, \"bravo\");"); System.out.println ("datas.setContent (\"words\", 1, \"bravo\");");
System.out.println ("datas.setContent (\"words\", 2, \"charlie\");"); System.out.println ("datas.setContent (\"words\", 2, \"charlie\");");
@ -173,7 +124,7 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent ("identity", 0, "nom", "Jemba");
datas.setContent ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 0, "prenom", "Epo");
datas.setContent ("identity", 1, "nom", "Momon"); datas.setContent ("identity", 1, "nom", "Momon");
@ -190,7 +141,7 @@ class Test
htmlSource = source.toString (); htmlSource = source.toString ();
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, "", errorMessage);
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");"); System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");");
System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");"); System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");");
System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");"); System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");");
@ -206,7 +157,7 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent ("identity", 0, "nom", "Jemba");
datas.setContent ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 0, "prenom", "Epo");
datas.setContent ("identity", 1, "nom", "Momon"); datas.setContent ("identity", 1, "nom", "Momon");
@ -228,7 +179,7 @@ class Test
source.append ("</table>"); source.append ("</table>");
htmlSource = source.toString (); htmlSource = source.toString ();
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");"); System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");");
System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");"); System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");");
System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");"); System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");");
@ -264,14 +215,12 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
/*
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
datas.setAttribute ("<div>", "class", "aDivClass"); datas.setAttribute ("<div>", "class", "aDivClass");
datas.setAttribute ("<div>", "style", "background-color: #000000;"); datas.setAttribute ("<div>", "style", "background-color: #000000;");
datas.setAttribute ("number", "style", "background-color: #0000FF;"); datas.setAttribute ("number", "style", "background-color: #0000FF;");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
source = new StringBuffer (); source = new StringBuffer ();
source.append ("<div>\n"); source.append ("<div>\n");
@ -285,13 +234,12 @@ class Test
System.out.println (htmlSource); System.out.println (htmlSource);
System.out.println ("+"); System.out.println ("+");
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setAttribute (\"<div>\", \"class\", \"aDivClass\");"); System.out.println ("datas.setAttribute (\"<div>\", \"class\", \"aDivClass\");");
System.out.println ("datas.setAttribute (\"<div>\", \"style\", \"background-color: #000000;\");"); System.out.println ("datas.setAttribute (\"<div>\", \"style\", \"background-color: #000000;\");");
System.out.println ("datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");"); System.out.println ("datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");");
System.out.println ("=>"); System.out.println ("=>");
System.out.println (html); System.out.println (html);
*/
} }
} }

View file

@ -91,9 +91,9 @@ public class Presenter
/* /*
* *
*/ */
public StringBuffer doXid (IdsDataById datas, StringBuffer errorOutput) public StringBuffer doXid (Data datas, StringBuffer errorOutput)
{ {
return (doXid (datas, null, errorOutput)); return (doXid (datas.getIdsDataById (), datas.getTagsDataById (), errorOutput));
} }
/* /*
@ -168,6 +168,15 @@ public class Presenter
/*
*
*/
static public StringBuffer doXid (String html, Data datas, StringBuffer errorOutput)
{
return (doXid (html, datas.getIdsDataById (), datas.getTagsDataById (), "", errorOutput));
}
/* /*
* *
*/ */
@ -529,7 +538,13 @@ public class Presenter
* @param attrMap * @param attrMap
* @param idAttr * @param idAttr
*/ */
static protected StringBuffer processObjectTag (Node node, NamedNodeMap attrMap, Node idAttr, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) static protected StringBuffer processObjectTag (Node node,
NamedNodeMap attrMap,
Node idAttr,
IdsDataById datas,
TagsDataById tagsData,
String webappPath,
StringBuffer errorOutput)
{ {
StringBuffer result; StringBuffer result;
@ -550,7 +565,6 @@ public class Presenter
codetype = attrMap.getNamedItem ("codetype").getNodeValue (); codetype = attrMap.getNamedItem ("codetype").getNodeValue ();
} }
// Check tag requirements. // Check tag requirements.
if ((attrMap == null) || if ((attrMap == null) ||
(codetype == null) || (codetype == null) ||
@ -577,7 +591,7 @@ public class Presenter
} }
catch (Exception ex) catch (Exception ex)
{ {
result.append ("unable to build the file tree"); errorOutput.append ("unable to build the file tree");
log.debug ("unable to build the file tree"); log.debug ("unable to build the file tree");
} }
@ -589,7 +603,7 @@ public class Presenter
if (nodes.getLength () == 0) if (nodes.getLength () == 0)
{ {
result.append ("no body tag in include html"); errorOutput.append ("no body tag in include html");
log.debug ("no body tag in include html"); log.debug ("no body tag in include html");
} }
else else
@ -599,11 +613,17 @@ public class Presenter
} }
catch (Exception e) catch (Exception e)
{ {
result.append ("error getting child"); errorOutput.append ("error getting child");
log.debug ("error getting child"); log.debug ("error getting child");
} }
// Process the body child as part of the primary tree. // Process the body child as part of the primary tree.
if (body == null)
{
errorOutput.append ("xid object body empty.");
}
else
{
NodeList bodyChildren = body.getChildNodes (); NodeList bodyChildren = body.getChildNodes ();
if (bodyChildren != null) if (bodyChildren != null)
@ -614,6 +634,7 @@ public class Presenter
result.append (process (bodyChildren.item (childCounter), datas, tagsData, webappPath, errorOutput)); result.append (process (bodyChildren.item (childCounter), datas, tagsData, webappPath, errorOutput));
} }
} }
}
// //
result.append ("<!-- ENDING INCLUDE XID FILE " + attrMap.getNamedItem ("data") + " -->"); result.append ("<!-- ENDING INCLUDE XID FILE " + attrMap.getNamedItem ("data") + " -->");
@ -677,6 +698,13 @@ public class Presenter
result = new StringBuffer (); result = new StringBuffer ();
String tag = node.getNodeName(); String tag = node.getNodeName();
if (tag.equals ("object"))
{
result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput));
}
else
{
String idValue = idAttr.getNodeValue(); String idValue = idAttr.getNodeValue();
log.debug ("tag=" + tag); log.debug ("tag=" + tag);
@ -835,6 +863,7 @@ public class Presenter
{ {
log.warn ("Unknow type of IdDataId"); log.warn ("Unknow type of IdDataId");
} }
}
// //
log.debug ("Exit"); log.debug ("Exit");
@ -930,8 +959,18 @@ public class Presenter
} }
else else
{ {
String tag = node.getNodeName();
if (tag.equals ("object"))
{
result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput));
}
else
{
result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput)); result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput));
} }
}
break; break;
} }

View file

@ -83,7 +83,7 @@ class Test
datas.setContent ("name", "Superman"); datas.setContent ("name", "Superman");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='name'>a name</div >", datas, errorMessage);
System.out.println (check ("only content change", html, "<div id=\"name\">Superman</div>")); System.out.println (check ("only content change", html, "<div id=\"name\">Superman</div>"));
@ -97,7 +97,7 @@ class Test
datas.setAttribute ("lastname", "class", "nameClass"); datas.setAttribute ("lastname", "class", "nameClass");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, errorMessage);
System.out.println (check ("content and attributes", html, "<div class=\"nameClass\" style=\"background: blue;foreground: red;\" id=\"lastname\">Spiderman</div>")); System.out.println (check ("content and attributes", html, "<div class=\"nameClass\" style=\"background: blue;foreground: red;\" id=\"lastname\">Spiderman</div>"));
// Populate attributes of Test 03. // Populate attributes of Test 03.
@ -112,7 +112,7 @@ class Test
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, "", errorMessage); html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, errorMessage);
System.out.println (check ("list assertion 1", html, "<li id=\"words_0\">alpha</li>")); System.out.println (check ("list assertion 1", html, "<li id=\"words_0\">alpha</li>"));
System.out.println (check ("list assertion 2", html, "<li id=\"words_1\">bravo</li>")); System.out.println (check ("list assertion 2", html, "<li id=\"words_1\">bravo</li>"));
@ -138,7 +138,7 @@ class Test
source.append (" <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n"); source.append (" <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n");
source.append ("</table>"); source.append ("</table>");
htmlSource = source.toString (); htmlSource = source.toString ();
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (check ("table 1 assertion 1", html, "<tr id=\"identity_0\"><td>noid</td><td id=\"nom_0\">Jemba</td><td id=\"prenom_0\">Epo</td></tr>")); System.out.println (check ("table 1 assertion 1", html, "<tr id=\"identity_0\"><td>noid</td><td id=\"nom_0\">Jemba</td><td id=\"prenom_0\">Epo</td></tr>"));
System.out.println (check ("table 1 assertion 2", html, "<tr id=\"identity_1\"><td>noid</td><td id=\"nom_1\">Momon</td><td id=\"prenom_1\">Christian</td></tr>")); System.out.println (check ("table 1 assertion 2", html, "<tr id=\"identity_1\"><td>noid</td><td id=\"nom_1\">Momon</td><td id=\"prenom_1\">Christian</td></tr>"));