diff --git a/build/classes/xid/Presenter.class b/build/classes/xid/Presenter.class index 6b26d0c..04637d2 100644 Binary files a/build/classes/xid/Presenter.class and b/build/classes/xid/Presenter.class differ diff --git a/build_test/classes/xid/test/Test.class b/build_test/classes/xid/test/Test.class deleted file mode 100644 index a1ac41d..0000000 Binary files a/build_test/classes/xid/test/Test.class and /dev/null differ diff --git a/demo/Demo.java b/demo/Demo.java index 2af81b3..de01306 100644 --- a/demo/Demo.java +++ b/demo/Demo.java @@ -45,7 +45,7 @@ class Demo //test (); // - IdsData datas; + Data datas; IdData tag; @@ -56,33 +56,13 @@ class Demo // Populate attributes of Test 03. System.out.println ("----------------------------"); - datas = new IdsData (); - tag = new IdData (); - tag.setContent ("Superman"); - datas.put ("name", tag); - - errorMessage = new StringBuffer (); - html = Presenter.doXid ("
a name
", 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 ("
a name
"); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new IdsData (); + datas = new Data (); datas.setContent ("name", "Superman"); errorMessage = new StringBuffer (); html = Presenter.doXid ("
a name
", datas, "", errorMessage); - System.out.println ("datas = new IdsData ();"); + System.out.println ("datas = new Data ();"); System.out.println ("datas.setContent (\"name\", \"Superman\");"); System.out.println ("+"); System.out.println ("
a name
"); @@ -92,34 +72,7 @@ class Demo // Populate attributes of Test 03. System.out.println ("----------------------------"); - datas = new IdsData (); - 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 ("
a last name
", 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 ("
a last name
"); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new IdsData (); + datas = new Data (); datas.setContent ("lastname", "Spiderman"); datas.appendAttribute ("lastname", "style", "background: blue;"); datas.appendAttribute ("lastname", "style", "foreground: red;"); @@ -129,7 +82,7 @@ class Demo errorMessage = new StringBuffer (); html = Presenter.doXid ("
a last name
", 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.appendAttribute (\"lastname\", \"style\", \"background: blue;\");"); System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");"); @@ -142,7 +95,7 @@ class Demo // Populate attributes of Test 03. System.out.println ("----------------------------"); - datas = new IdsData (); + datas = new Data (); datas.setContent ("words", 0, "alpha"); datas.setContent ("words", 1, "bravo"); datas.setContent ("words", 2, "charlie"); @@ -154,7 +107,7 @@ class Demo errorMessage = new StringBuffer (); html = Presenter.doXid ("", 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\", 1, \"bravo\");"); System.out.println ("datas.setContent (\"words\", 2, \"charlie\");"); @@ -171,7 +124,7 @@ class Demo // Populate attributes of Test 03. System.out.println ("----------------------------"); - datas = new IdsData (); + datas = new Data (); datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 1, "nom", "Momon"); @@ -188,7 +141,7 @@ class Demo htmlSource = source.toString (); 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, \"prenom\", \"Epo\");"); System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");"); @@ -204,7 +157,7 @@ class Demo // Populate attributes of Test 03. System.out.println ("----------------------------"); - datas = new IdsData (); + datas = new Data (); datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 1, "nom", "Momon"); @@ -226,7 +179,7 @@ class Demo source.append (""); 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, \"prenom\", \"Epo\");"); System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");"); @@ -262,14 +215,12 @@ class Demo // Populate attributes of Test 03. - /* System.out.println ("----------------------------"); - datas = new IdsData (); + datas = new Data (); datas.setAttribute ("
", "class", "aDivClass"); datas.setAttribute ("
", "style", "background-color: #000000;"); datas.setAttribute ("number", "style", "background-color: #0000FF;"); - errorMessage = new StringBuffer (); source = new StringBuffer (); source.append ("
\n"); @@ -283,13 +234,12 @@ class Demo System.out.println (htmlSource); System.out.println ("+"); - System.out.println ("datas = new IdsData ();"); + System.out.println ("datas = new Data ();"); System.out.println ("datas.setAttribute (\"
\", \"class\", \"aDivClass\");"); System.out.println ("datas.setAttribute (\"
\", \"style\", \"background-color: #000000;\");"); System.out.println ("datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");"); System.out.println ("=>"); System.out.println (html); - */ } } diff --git a/dist/xid.jar b/dist/xid.jar deleted file mode 100644 index 31716c8..0000000 Binary files a/dist/xid.jar and /dev/null differ diff --git a/src/xid/IdsData.java b/src/xid/Data.java similarity index 59% rename from src/xid/IdsData.java rename to src/xid/Data.java index 503ec5b..991953b 100644 --- a/src/xid/IdsData.java +++ b/src/xid/Data.java @@ -6,14 +6,47 @@ import java.io.*; /* * */ -public class IdsData extends IdsDataById +public class Data { + protected IdsDataById idsDataById; + protected TagsDataById tagsDataById; + + /** * */ - public IdsData () + public Data () { - super (); + this.idsDataById = new IdsDataById (); + this.tagsDataById = new TagsDataById (); + } + + + /** + * + */ + public IdsDataById getIdsDataById () + { + IdsDataById result; + + result = this.idsDataById; + + // + return (result); + } + + + /** + * + */ + public TagsDataById getTagsDataById () + { + TagsDataById result; + + result = this.tagsDataById; + + // + return (result); } @@ -25,13 +58,13 @@ public class IdsData extends IdsDataById IdData result; // Be sure that IdData is existing and get item. - result = (IdData) this.get (id); + result = (IdData) this.idsDataById.getId (id); if (result == null) { - this.put (id, new IdData ()); + this.idsDataById.setId (id, new IdData ()); - result = (IdData) this.get (id); + result = (IdData) this.idsDataById.getId (id); } @@ -48,12 +81,12 @@ public class IdsData extends IdsDataById IdData result; // Be sure that IdsData are existing. - IdsDataByIndex tags = (IdsDataByIndex) this.get (id); + IdsDataByIndex tags = (IdsDataByIndex) this.idsDataById.getId (id); if (tags == null) { - this.put (id, new IdsDataByIndex ()); + this.idsDataById.setId (id, new IdsDataByIndex ()); - tags = (IdsDataByIndex) this.get (id); + tags = (IdsDataByIndex) this.idsDataById.getId (id); } // Be sure that lines are existing. @@ -79,12 +112,12 @@ public class IdsData extends IdsDataById IdData result; // Be sure that IdsData are existing. - IdsDataByIndex tags = (IdsDataByIndex) this.get (id); + IdsDataByIndex tags = (IdsDataByIndex) this.idsDataById.getId (id); if (tags == null) { - this.put (id, new IdsDataByIndex ()); + this.idsDataById.setId (id, new IdsDataByIndex ()); - tags = (IdsDataByIndex) this.get (id); + tags = (IdsDataByIndex) this.idsDataById.getId (id); } // Be sure that lines are existing. @@ -116,7 +149,7 @@ public class IdsData extends IdsDataById */ public void setIterationStrategy (String id, IdsDataByIndex.IterationStrategy strategy) { - IdsDataByIndex tags = (IdsDataByIndex) this.get (id); + IdsDataByIndex tags = (IdsDataByIndex) this.idsDataById.getId (id); tags.setIterationStrategy (strategy); } @@ -128,9 +161,25 @@ public class IdsData extends IdsDataById */ public void setContent (String id, String content) { - IdData tag = this.getIdData (id); + if (id.startsWith ("<")) + { + String tagName = id.substring (1, id.length () - 1); + + TagData tag = this.tagsDataById.getId (tagName); + if (tag == null) + { + tag = new TagData (); + this.tagsDataById.setId (tagName, tag); + } - tag.setContent (content); + tag.setContent (content); + } + else + { + IdData idData = this.getIdData (id); + + idData.setContent (content); + } } @@ -161,9 +210,25 @@ public class IdsData extends IdsDataById */ public void setAttribute (String id, String label, String value) { - IdData tag = this.getIdData (id); + if (id.startsWith ("<")) + { + String tagName = id.substring (1, id.length () - 1); + + TagData tag = this.tagsDataById.getId (tagName); + if (tag == null) + { + tag = new TagData (); + this.tagsDataById.setId (tagName, tag); + } - tag.getAttributes ().setAttribute (label, value); + tag.getAttributes ().setAttribute (label, value); + } + else + { + IdData tag = this.getIdData (id); + + tag.getAttributes ().setAttribute (label, value); + } } diff --git a/src/xid/Presenter.java b/src/xid/Presenter.java index 0f3ce99..941fcae 100644 --- a/src/xid/Presenter.java +++ b/src/xid/Presenter.java @@ -167,6 +167,17 @@ public class Presenter } + + /* + * + */ + static public StringBuffer doXid (String html, Data datas, String webappPath, StringBuffer errorOutput) + { + return (doXid (html, datas.getIdsDataById (), datas.getTagsDataById (), webappPath, errorOutput)); + } + + + /* * Xid a string with html in. */ diff --git a/src/xid/TagsData.java b/src/xid/TagsData.java deleted file mode 100644 index 9cbc888..0000000 --- a/src/xid/TagsData.java +++ /dev/null @@ -1,74 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; - -/* - * - */ -public class TagsData extends TagsDataById -{ - /** - * - */ - public TagsData () - { - super (); - } - - - /** - * - */ - public TagData getTagData (String id) - { - TagData result; - - // Be sure that data is existing and get item. - result = (TagData) this.get (id); - - if (result == null) - { - this.put (id, new TagData ()); - - result = (TagData) this.get (id); - } - - - // - return (result); - } - - - /** - * - */ - public void setContent (String id, String content) - { - TagData tag = this.getTagData (id); - - tag.setContent (content); - } - - - /** - * - */ - public void setAttribute (String id, String label, String value) - { - TagData tag = this.getTagData (id); - - tag.getAttributes ().setAttribute (label, value); - } - - - /** - * - */ - public void appendAttribute (String id, String label, String value) - { - TagData tag = this.getTagData (id); - - tag.getAttributes ().appendAttribute (label, value); - } -}