2010-02-23 15:03:14 +01:00
|
|
|
/**
|
|
|
|
* XidDemo
|
|
|
|
*/
|
|
|
|
|
2010-02-23 15:02:33 +01:00
|
|
|
import fr.devinsy.xid.*;
|
2007-02-05 06:10:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2010-02-23 15:03:14 +01:00
|
|
|
class XidDemo
|
2007-02-05 06:10:27 +01:00
|
|
|
{
|
2010-02-23 15:03:14 +01:00
|
|
|
static private org.apache.log4j.Logger logger;
|
2007-02-05 06:10:27 +01:00
|
|
|
|
|
|
|
static
|
|
|
|
{
|
2010-02-23 15:03:14 +01:00
|
|
|
// Initialize logger.
|
2007-02-05 06:10:27 +01:00
|
|
|
org.apache.log4j.Logger log = null;
|
|
|
|
|
|
|
|
org.apache.log4j.BasicConfigurator.configure ();
|
|
|
|
|
|
|
|
|
|
|
|
log = org.apache.log4j.Logger.getRootLogger ();
|
2010-02-23 15:03:14 +01:00
|
|
|
//logger.setLevel (org.apache.log4j.Level.INFO);
|
|
|
|
logger.setLevel (org.apache.log4j.Level.INFO);
|
2007-02-05 06:10:27 +01:00
|
|
|
|
2010-02-23 15:03:14 +01:00
|
|
|
logger.info ("Enter");
|
2007-02-05 06:10:27 +01:00
|
|
|
|
|
|
|
//
|
2010-02-23 15:03:14 +01:00
|
|
|
logger.info ("Set the log file format...");
|
2007-02-05 06:10:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
// log = org.apache.log4j.Category.getInstance(Application.class.getName());
|
2010-02-23 15:03:14 +01:00
|
|
|
logger.info ("... done.");
|
2007-02-05 06:10:27 +01:00
|
|
|
|
2010-02-23 15:03:14 +01:00
|
|
|
logger.debug ("Exit");
|
|
|
|
log = org.apache.log4j.Logger.getLogger (XidDemo.class);
|
2007-02-05 06:10:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static void main (String[] args)
|
|
|
|
{
|
|
|
|
System.out.println("Hello World!");
|
|
|
|
|
|
|
|
//test ();
|
|
|
|
|
|
|
|
//
|
2007-02-05 07:20:08 +01:00
|
|
|
Data datas;
|
2007-02-05 06:10:27 +01:00
|
|
|
IdData tag;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String htmlSource;
|
|
|
|
StringBuffer html;
|
|
|
|
StringBuffer errorMessage;
|
|
|
|
|
|
|
|
// Populate attributes of Test 03.
|
|
|
|
System.out.println ("----------------------------");
|
2007-02-05 07:20:08 +01:00
|
|
|
datas = new Data ();
|
2007-02-05 06:10:27 +01:00
|
|
|
datas.setContent ("name", "Superman");
|
|
|
|
|
|
|
|
errorMessage = new StringBuffer ();
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid ("<div id='name'>a name</div >", datas, errorMessage);
|
2007-02-05 06:10:27 +01:00
|
|
|
|
2007-02-05 07:20:08 +01:00
|
|
|
System.out.println ("datas = new Data ();");
|
2007-02-05 06:10:27 +01:00
|
|
|
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 (html);
|
|
|
|
|
|
|
|
|
|
|
|
// Populate attributes of Test 03.
|
|
|
|
System.out.println ("----------------------------");
|
2007-02-05 07:20:08 +01:00
|
|
|
datas = new Data ();
|
2007-02-05 06:10:27 +01:00
|
|
|
datas.setContent ("lastname", "Spiderman");
|
|
|
|
datas.appendAttribute ("lastname", "style", "background: blue;");
|
|
|
|
datas.appendAttribute ("lastname", "style", "foreground: red;");
|
|
|
|
datas.setAttribute ("lastname", "class", "nameClass");
|
|
|
|
|
|
|
|
|
|
|
|
errorMessage = new StringBuffer ();
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid ("<div id='lastname'>a last name</div >", datas, errorMessage);
|
2007-02-05 06:10:27 +01:00
|
|
|
|
2007-02-05 07:20:08 +01:00
|
|
|
System.out.println ("datas = new Data ();");
|
2007-02-05 06:10:27 +01:00
|
|
|
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 (html);
|
|
|
|
|
|
|
|
|
|
|
|
// Populate attributes of Test 03.
|
|
|
|
System.out.println ("----------------------------");
|
2007-02-05 07:20:08 +01:00
|
|
|
datas = new Data ();
|
2007-02-05 06:10:27 +01:00
|
|
|
datas.setContent ("words", 0, "alpha");
|
|
|
|
datas.setContent ("words", 1, "bravo");
|
|
|
|
datas.setContent ("words", 2, "charlie");
|
|
|
|
datas.setContent ("words", 3, "delta");
|
|
|
|
datas.setContent ("words", 4, "echo");
|
|
|
|
datas.setContent ("words", 5, "fox");
|
|
|
|
|
|
|
|
|
|
|
|
errorMessage = new StringBuffer ();
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, errorMessage);
|
2007-02-05 06:10:27 +01:00
|
|
|
|
2007-02-05 07:20:08 +01:00
|
|
|
System.out.println ("datas = new Data ();");
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println ("datas.setContent (\"words\", 0, \"alpha\");");
|
|
|
|
System.out.println ("datas.setContent (\"words\", 1, \"bravo\");");
|
|
|
|
System.out.println ("datas.setContent (\"words\", 2, \"charlie\");");
|
|
|
|
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 (html);
|
|
|
|
|
|
|
|
|
|
|
|
// Populate attributes of Test 03.
|
|
|
|
System.out.println ("----------------------------");
|
2007-02-05 07:20:08 +01:00
|
|
|
datas = new Data ();
|
2007-02-08 03:29:52 +01:00
|
|
|
datas.setContent ("identity", 0, "last_name", "Jemba");
|
|
|
|
datas.setContent ("identity", 0, "first_name", "Epo");
|
|
|
|
datas.setContent ("identity", 1, "last_name", "Momon");
|
|
|
|
datas.setContent ("identity", 1, "first_name", "Christian");
|
|
|
|
datas.setContent ("identity", 2, "last_name", "Tronche");
|
|
|
|
datas.setContent ("identity", 2, "first_name", "Christophe");
|
2007-02-05 06:10:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
errorMessage = new StringBuffer ();
|
|
|
|
StringBuffer source = new StringBuffer ();
|
|
|
|
source.append ("<table>\n");
|
2007-02-08 03:29:52 +01:00
|
|
|
source.append (" <tr id='identity'><td>noid</td><td id='first_name'>Jean</td><td id='last_name'>Reve</td></tr>\n");
|
2007-02-05 06:10:27 +01:00
|
|
|
source.append ("</table>");
|
|
|
|
htmlSource = source.toString ();
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid (htmlSource, datas, errorMessage);
|
2007-02-05 06:10:27 +01:00
|
|
|
|
2007-02-05 07:20:08 +01:00
|
|
|
System.out.println ("datas = new Data ();");
|
2007-02-08 03:29:52 +01:00
|
|
|
System.out.println ("datas.setContent (\"identity\", 0, \"last_name\", \"Jemba\");");
|
|
|
|
System.out.println ("datas.setContent (\"identity\", 0, \"first_name\", \"Epo\");");
|
|
|
|
System.out.println ("datas.setContent (\"identity\", 1, \"last_name\", \"Momon\");");
|
|
|
|
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\");");
|
2007-02-05 06:10:27 +01:00
|
|
|
|
|
|
|
System.out.println ("+");
|
|
|
|
System.out.println (htmlSource);
|
|
|
|
System.out.println ("=>");
|
|
|
|
System.out.println (html);
|
|
|
|
|
|
|
|
|
|
|
|
// Populate attributes of Test 03.
|
|
|
|
System.out.println ("----------------------------");
|
2007-02-05 07:20:08 +01:00
|
|
|
datas = new Data ();
|
2007-02-08 03:29:52 +01:00
|
|
|
datas.setContent ("identity", 0, "last_name", "Jemba");
|
|
|
|
datas.setContent ("identity", 0, "first_name", "Epo");
|
|
|
|
datas.setContent ("identity", 1, "last_name", "Momon");
|
|
|
|
datas.setContent ("identity", 1, "first_name", "Christian");
|
|
|
|
datas.setContent ("identity", 2, "last_name", "Tronche");
|
|
|
|
datas.setContent ("identity", 2, "first_name", "Christophe");
|
2007-02-05 06:10:27 +01:00
|
|
|
//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);
|
|
|
|
|
|
|
|
|
|
|
|
errorMessage = new StringBuffer ();
|
|
|
|
source = new StringBuffer ();
|
2007-02-08 03:29:52 +01:00
|
|
|
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");
|
2007-02-05 06:10:27 +01:00
|
|
|
htmlSource = source.toString ();
|
|
|
|
|
2007-02-05 07:20:08 +01:00
|
|
|
System.out.println ("datas = new Data ();");
|
2007-02-08 03:29:52 +01:00
|
|
|
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\");");
|
2007-02-05 06:10:27 +01:00
|
|
|
|
|
|
|
System.out.println ("+");
|
|
|
|
System.out.println (htmlSource);
|
|
|
|
System.out.println ("=>");
|
|
|
|
|
|
|
|
|
2007-02-08 03:29:52 +01:00
|
|
|
datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_FIRST_ROW);
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println ("ONLY_FIRST_ROW:");
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid (htmlSource, datas, errorMessage);
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println (html);
|
|
|
|
|
2007-02-08 03:29:52 +01:00
|
|
|
System.out.println ("");
|
|
|
|
datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_FIRST_TWO_ROWS);
|
|
|
|
System.out.println ("ONLY_FIRST_TWO_ROWS:");
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid (htmlSource, datas, errorMessage);
|
2007-02-08 03:29:52 +01:00
|
|
|
System.out.println (html);
|
|
|
|
|
|
|
|
System.out.println ("");
|
|
|
|
datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_ROWS_WITH_ID);
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println ("ONLY_ROWS_WITH_ID:");
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid (htmlSource, datas, errorMessage);
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println (html);
|
|
|
|
|
2007-02-08 03:29:52 +01:00
|
|
|
System.out.println ("");
|
|
|
|
datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_ROWS_WITHOUT_ID);
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println ("ONLY_ROWS_WITHOUT_ID:");
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid (htmlSource, datas, errorMessage);
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println (html);
|
|
|
|
|
2007-02-08 03:29:52 +01:00
|
|
|
System.out.println ("");
|
|
|
|
datas.setIterationStrategy ("identities", IdData.IterationStrategy.ALL_ROWS);
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println ("ALL_ROWS:");
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid (htmlSource, datas, errorMessage);
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println (html);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Populate attributes of Test 03.
|
|
|
|
System.out.println ("----------------------------");
|
2007-02-05 07:20:08 +01:00
|
|
|
datas = new Data ();
|
2007-02-05 06:10:27 +01:00
|
|
|
datas.setAttribute ("<div>", "class", "aDivClass");
|
|
|
|
datas.setAttribute ("<div>", "style", "background-color: #000000;");
|
|
|
|
datas.setAttribute ("number", "style", "background-color: #0000FF;");
|
|
|
|
|
|
|
|
errorMessage = new StringBuffer ();
|
|
|
|
source = new StringBuffer ();
|
|
|
|
source.append ("<div>\n");
|
|
|
|
source.append (" <h1>one</h1>\n");
|
|
|
|
source.append ("</div>\n");
|
|
|
|
source.append ("<div id=\"number\">\n");
|
|
|
|
source.append (" <h1>three</h1>\n");
|
|
|
|
source.append ("</div>");
|
|
|
|
htmlSource = source.toString ();
|
2007-02-16 18:46:28 +01:00
|
|
|
html = StringPresenter.doXid (htmlSource, datas, errorMessage);
|
2007-02-05 06:10:27 +01:00
|
|
|
|
|
|
|
System.out.println (htmlSource);
|
|
|
|
System.out.println ("+");
|
2007-02-05 07:20:08 +01:00
|
|
|
System.out.println ("datas = new Data ();");
|
2007-02-05 06:10:27 +01:00
|
|
|
System.out.println ("datas.setAttribute (\"<div>\", \"class\", \"aDivClass\");");
|
|
|
|
System.out.println ("datas.setAttribute (\"<div>\", \"style\", \"background-color: #000000;\");");
|
|
|
|
System.out.println ("datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");");
|
|
|
|
|
|
|
|
System.out.println ("=>");
|
|
|
|
System.out.println (html);
|
|
|
|
}
|
|
|
|
}
|