diff --git a/build/classes/xid/Presenter.class b/build/classes/xid/Presenter.class index dfcf48f..5eff7e2 100644 Binary files a/build/classes/xid/Presenter.class and b/build/classes/xid/Presenter.class differ diff --git a/build/classes/xid/TagsData.class b/build/classes/xid/TagsData.class index 16fcd7f..d065714 100644 Binary files a/build/classes/xid/TagsData.class and b/build/classes/xid/TagsData.class differ diff --git a/build_test/classes/xid/test/Test.class b/build_test/classes/xid/test/Test.class index 36e80ef..1da341f 100644 Binary files a/build_test/classes/xid/test/Test.class and b/build_test/classes/xid/test/Test.class differ diff --git a/dist/test.jar b/dist/test.jar index 9a8e9db..54295a7 100644 Binary files a/dist/test.jar and b/dist/test.jar differ diff --git a/dist/xid.jar b/dist/xid.jar index 873386b..c759277 100644 Binary files a/dist/xid.jar and b/dist/xid.jar differ diff --git a/src/xid/Presenter.java b/src/xid/Presenter.java index b260daf..f3c0f22 100644 --- a/src/xid/Presenter.java +++ b/src/xid/Presenter.java @@ -296,6 +296,8 @@ public class Presenter { int childrenCount = children.getLength (); + // TODO Analyze IterationStragy if datas is a TagsData. + for (int i = 0; i < childrenCount; i++) { result.append (process (children.item(i), datas, webappPath, prefix, errorOutput)); @@ -525,9 +527,9 @@ public class Presenter } } } - else if (dataCore instanceof TagsData) + else if (dataCore instanceof TagsDataByIndex) { - TagsData tags = (TagsData) dataCore; + TagsDataByIndex tags = (TagsDataByIndex) dataCore; int nbLines = tags.size (); for (int nLine = 0; nLine < nbLines; nLine++) diff --git a/src/xid/TagsData.java b/src/xid/TagsData.java index 1191821..458523a 100644 --- a/src/xid/TagsData.java +++ b/src/xid/TagsData.java @@ -6,7 +6,7 @@ import java.io.*; /* * */ -public class TagsData extends Vector implements TagDataCore +public class TagsData extends TagsDataById { /** * @@ -15,4 +15,209 @@ public class TagsData extends Vector implements TagDataCore { super (); } + + + /** + * + */ + public TagData getTagData (String id) + { + TagData result; + + // Be sure that TagData 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 TagData getTagData (String id, int line) + { + TagData result; + + // Be sure that TagsData are existing. + TagsDataByIndex tags = (TagsDataByIndex) this.get (id); + if (tags == null) + { + this.put (id, new TagsDataByIndex ()); + + tags = (TagsDataByIndex) this.get (id); + } + + // Be sure that lines are existing. + int nbLines = tags.size (); + for (int nLine = nbLines; nLine < line + 1; nLine++) + { + tags.add (nLine, new TagData ()); + } + + // Get item. + result = (TagData) tags.elementAt (line); + + // + return (result); + } + + + /** + * + */ + public TagData getTagData (String id, int line, String column) + { + TagData result; + + // Be sure that TagsData are existing. + TagsDataByIndex tags = (TagsDataByIndex) this.get (id); + if (tags == null) + { + this.put (id, new TagsDataByIndex ()); + + tags = (TagsDataByIndex) this.get (id); + } + + // Be sure that lines are existing. + int nbLines = tags.size (); + for (int nLine = nbLines; nLine < line + 1; nLine++) + { + tags.add (nLine, new TagsDataById ()); + } + + // Get item. + TagsDataById lineData = (TagsDataById) tags.elementAt (line); + + result = (TagData) lineData.get (column); + + if (result == null) + { + lineData.put (column, new TagData ()); + + result = (TagData) lineData.get (column); + } + + // + return (result); + } + + + /** + * + */ + public void setIterationStragey (String id, TagsDataByIndex.IterationStrategy strategy) + { + TagsDataByIndex tags = (TagsDataByIndex) this.get (id); + + tags.setIterationStrategy (strategy); + } + + + + /** + * + */ + public void setContent (String id, String content) + { + TagData tag = this.getTagData (id); + + tag.setContent (content); + } + + + /** + * + */ + public void setContent (String id, int line, String content) + { + TagData tag = this.getTagData (id, line); + + tag.setContent (content); + } + + + /** + * + */ + public void setContent (String id, int line, String column, String content) + { + TagData tag = this.getTagData (id, line, column); + + tag.setContent (content); + } + + + /** + * + */ + public void setAttribute (String id, String label, String value) + { + TagData tag = this.getTagData (id); + + tag.getAttributes ().setAttribute (label, value); + } + + + /** + * + */ + public void setAttribute (String id, int line, String label, String value) + { + TagData tag = this.getTagData (id, line); + + tag.getAttributes ().setAttribute (label, value); + } + + + /** + * + */ + public void setAttribute (String id, int line, String column, String label, String value) + { + TagData tag = this.getTagData (id, line, column); + + tag.getAttributes ().setAttribute (label, value); + } + + + /** + * + */ + public void appendAttribute (String id, String label, String value) + { + TagData tag = this.getTagData (id); + + tag.getAttributes ().appendAttribute (label, value); + } + + + /** + * + */ + public void appendContent (String id, int line, String label, String value) + { + TagData tag = this.getTagData (id, line); + + tag.getAttributes ().appendAttribute (label, value); + } + + + /** + * + */ + public void appendContent (String id, int line, String column, String label, String value) + { + TagData tag = this.getTagData (id, line, column); + + tag.getAttributes ().appendAttribute (label, value); + } } diff --git a/src/xid/TagsDataById.java b/src/xid/TagsDataById.java index a763259..4af3708 100644 --- a/src/xid/TagsDataById.java +++ b/src/xid/TagsDataById.java @@ -8,7 +8,7 @@ import java.io.*; */ public class TagsDataById extends HashMap implements TagDataCore { - /** + /* * */ public TagsDataById () @@ -36,197 +36,4 @@ public class TagsDataById extends HashMap implements TagDat // return (result); } - - /* ------------------- Helpers ------------ */ - /** - * - */ - public TagData getTagData (String id) - { - TagData result; - - // Be sure that TagData 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 TagData getTagData (String id, int line) - { - TagData result; - - // Be sure that TagsData are existing. - TagsData tags = (TagsData) this.get (id); - if (tags == null) - { - this.put (id, new TagsData ()); - - tags = (TagsData) this.get (id); - } - - // Be sure that lines are existing. - int nbLines = tags.size (); - for (int nLine = nbLines; nLine < line + 1; nLine++) - { - tags.add (nLine, new TagData ()); - } - - // Get item. - result = (TagData) tags.elementAt (line); - - // - return (result); - } - - - /** - * - */ - public TagData getTagData (String id, int line, String column) - { - TagData result; - - // Be sure that TagsData are existing. - TagsData tags = (TagsData) this.get (id); - if (tags == null) - { - this.put (id, new TagsData ()); - - tags = (TagsData) this.get (id); - } - - // Be sure that lines are existing. - int nbLines = tags.size (); - for (int nLine = nbLines; nLine < line + 1; nLine++) - { - tags.add (nLine, new TagsDataById ()); - } - - // Get item. - TagsDataById lineData = (TagsDataById) tags.elementAt (line); - - result = (TagData) lineData.get (column); - - if (result == null) - { - lineData.put (column, new TagData ()); - - result = (TagData) lineData.get (column); - } - - // - return (result); - } - - - /** - * - */ - public void setContent (String id, String content) - { - TagData tag = this.getTagData (id); - - tag.setContent (content); - } - - - /** - * - */ - public void setContent (String id, int line, String content) - { - TagData tag = this.getTagData (id, line); - - tag.setContent (content); - } - - - /** - * - */ - public void setContent (String id, int line, String column, String content) - { - TagData tag = this.getTagData (id, line, column); - - tag.setContent (content); - } - - - /** - * - */ - public void setAttribute (String id, String label, String value) - { - TagData tag = this.getTagData (id); - - tag.getAttributes ().setAttribute (label, value); - } - - - /** - * - */ - public void setAttribute (String id, int line, String label, String value) - { - TagData tag = this.getTagData (id, line); - - tag.getAttributes ().setAttribute (label, value); - } - - - /** - * - */ - public void setAttribute (String id, int line, String column, String label, String value) - { - TagData tag = this.getTagData (id, line, column); - - tag.getAttributes ().setAttribute (label, value); - } - - - /** - * - */ - public void appendAttribute (String id, String label, String value) - { - TagData tag = this.getTagData (id); - - tag.getAttributes ().appendAttribute (label, value); - } - - - /** - * - */ - public void appendContent (String id, int line, String label, String value) - { - TagData tag = this.getTagData (id, line); - - tag.getAttributes ().appendAttribute (label, value); - } - - - /** - * - */ - public void appendContent (String id, int line, String column, String label, String value) - { - TagData tag = this.getTagData (id, line, column); - - tag.getAttributes ().appendAttribute (label, value); - } } diff --git a/test/xid/test/Test.java b/test/xid/test/Test.java index 16aba38..00fa03d 100644 --- a/test/xid/test/Test.java +++ b/test/xid/test/Test.java @@ -47,7 +47,7 @@ class Test //test (); // - TagsDataById datas; + TagsData datas; TagData tag; @@ -57,7 +57,7 @@ class Test StringBuffer errorMessage; // Populate attributes of Test 03. - datas = new TagsDataById (); + datas = new TagsData (); tag = new TagData (); tag.setContent ("Superman"); datas.put ("name", tag); @@ -66,7 +66,7 @@ class Test html = Presenter.doXid ("
a name
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataById ();"); + System.out.println ("datas = new TagsData ();"); System.out.println ("tag = new TagData ();"); System.out.println ("tag.setContent (\"Superman\");"); System.out.println ("datas.put (\"name\", tag););"); @@ -77,14 +77,14 @@ class Test // Populate attributes of Test 03. - datas = new TagsDataById (); + datas = new TagsData (); datas.setContent ("name", "Superman"); errorMessage = new StringBuffer (); html = Presenter.doXid ("
a name
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataById ();"); + System.out.println ("datas = new TagsData ();"); System.out.println ("datas.setContent (\"name\", \"Superman\");"); System.out.println ("+"); System.out.println ("
a name
"); @@ -93,7 +93,7 @@ class Test // Populate attributes of Test 03. - datas = new TagsDataById (); + datas = new TagsData (); tag = new TagData (); tag.setContent ("Spiderman"); tag.getAttributes ().appendAttribute ("style", "background: blue;"); @@ -106,7 +106,7 @@ class Test html = Presenter.doXid ("
a last name
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataById ();"); + System.out.println ("datas = new TagsData ();"); System.out.println ("tag = new TagData ();"); System.out.println ("tag.getAttributes ().setAttribute (\"class\", \"lastnameClass\");"); System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"background: blue;\");"); @@ -120,7 +120,7 @@ class Test // Populate attributes of Test 03. - datas = new TagsDataById (); + datas = new TagsData (); datas.setContent ("lastname", "Spiderman"); datas.appendAttribute ("lastname", "style", "background: blue;"); datas.appendAttribute ("lastname", "style", "foreground: red;"); @@ -131,7 +131,7 @@ class Test html = Presenter.doXid ("
a last name
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataById ();"); + System.out.println ("datas = new TagsData ();"); 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;\""); @@ -143,7 +143,7 @@ class Test // Populate attributes of Test 03. - datas = new TagsDataById (); + datas = new TagsData (); datas.setContent ("words", 0, "alpha"); datas.setContent ("words", 1, "bravo"); datas.setContent ("words", 2, "charlie"); @@ -156,7 +156,7 @@ class Test html = Presenter.doXid ("
    \n
  • a word
  • \n
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataById ();"); + System.out.println ("datas = new TagsData ();"); System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); System.out.println ("datas.setContent (\"words\", 1, \"bravo\");"); System.out.println ("datas.setContent (\"words\", 2, \"charlie\");"); @@ -172,7 +172,7 @@ class Test // Populate attributes of Test 03. - datas = new TagsDataById (); + datas = new TagsData (); datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 1, "nom", "Momon"); @@ -185,7 +185,7 @@ class Test html = Presenter.doXid ("\n \n
noidun nomun prenom
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataById ();"); + System.out.println ("datas = new TagsData ();"); 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\");"); diff --git a/test/xid/test/Test.java~ b/test/xid/test/Test.java~ index 2d03921..16aba38 100644 --- a/test/xid/test/Test.java~ +++ b/test/xid/test/Test.java~ @@ -4,93 +4,11 @@ import java.util.*; import java.io.*; import xid.*; -interface TTagDataCore -{ -} - -class TTagData implements TTagDataCore -{ - public String a; -} - -class TTagsDataById extends HashMap implements TTagDataCore -{ -} - -class TTagsData extends Vector implements TTagDataCore -{ -} - -class TTagsMatrix extends TTagsDataById -{ -} - /** * */ class Test { - - public static void test () - { - System.out.println ("doing a test"); - - - TTagsDataById tags = new TTagsDataById (); - - TTagData tag = new TTagData (); - tag.a = "label a1"; - tags.put ("id1", tag); - - tag = new TTagData (); - tag.a = "label a2"; - tags.put ("id2", tag); - - TTagsData tag2 = new TTagsData (); - tags.put ("id3", tag2); - - TTagsDataById tag3 = new TTagsDataById (); - tags.put ("id4", tag3); - - TTagsMatrix tag4 = new TTagsMatrix (); - tags.put ("id5", tag4); - - System.out.println ("tags=" + tags); - - Set keys = tags.keySet (); - Iterator it = keys.iterator (); - while (it.hasNext ()) - { - String key = (String) it.next (); - Object obj = tags.get (key); - - StringBuffer comment = new StringBuffer (); - comment.append ("(" + key + "=> " + obj + "-> "); - - if (obj instanceof TTagData) - { - comment.append ("class TTagData"); - } - else if (obj instanceof TTagsData) - { - comment.append ("class TTagsData"); - } - else if (obj instanceof TTagsDataById) - { - comment.append ("class TTagsDataById"); - } - - if (obj instanceof TTagDataCore) - { - comment.append (" TTagDataCore"); - } - - comment.append (")"); - System.out.println (comment); - } - } - - static private org.apache.log4j.Logger log; static @@ -148,7 +66,7 @@ class Test html = Presenter.doXid ("
a name
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataId ();"); + System.out.println ("datas = new TagsDataById ();"); System.out.println ("tag = new TagData ();"); System.out.println ("tag.setContent (\"Superman\");"); System.out.println ("datas.put (\"name\", tag););"); @@ -166,7 +84,7 @@ class Test html = Presenter.doXid ("
a name
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataId ();"); + System.out.println ("datas = new TagsDataById ();"); System.out.println ("datas.setContent (\"name\", \"Superman\");"); System.out.println ("+"); System.out.println ("
a name
"); @@ -188,7 +106,7 @@ class Test html = Presenter.doXid ("
a last name
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataId ();"); + System.out.println ("datas = new TagsDataById ();"); System.out.println ("tag = new TagData ();"); System.out.println ("tag.getAttributes ().setAttribute (\"class\", \"lastnameClass\");"); System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"background: blue;\");"); @@ -213,9 +131,9 @@ class Test html = Presenter.doXid ("
a last name
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataId ();"); + System.out.println ("datas = new TagsDataById ();"); System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); - System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");"); + 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 ("+"); @@ -238,7 +156,7 @@ class Test html = Presenter.doXid ("
    \n
  • a word
  • \n
", datas, "", errorMessage); System.out.println ("----------------------------"); - System.out.println ("datas = new TagsDataId ();"); + System.out.println ("datas = new TagsDataById ();"); System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); System.out.println ("datas.setContent (\"words\", 1, \"bravo\");"); System.out.println ("datas.setContent (\"words\", 2, \"charlie\");"); @@ -251,6 +169,34 @@ class Test System.out.println (""); System.out.println ("=>"); System.out.println (html); + + + // Populate attributes of Test 03. + datas = new TagsDataById (); + datas.setContent ("identity", 0, "nom", "Jemba"); + datas.setContent ("identity", 0, "prenom", "Epo"); + datas.setContent ("identity", 1, "nom", "Momon"); + datas.setContent ("identity", 1, "prenom", "Christian"); + datas.setContent ("identity", 2, "nom", "Tronche"); + datas.setContent ("identity", 2, "prenom", "Christophe"); + + + errorMessage = new StringBuffer (); + html = Presenter.doXid ("\n \n
noidun nomun prenom
", datas, "", errorMessage); + System.out.println ("----------------------------"); + System.out.println ("datas = new TagsDataById ();"); + 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\");"); + System.out.println ("datas.setContent (\"identity\", 1, \"prenom\", \"Christian\");"); + System.out.println ("datas.setContent (\"identity\", 2, \"nom\", \"Tronche\");"); + System.out.println ("datas.setContent (\"identity\", 2, \"prenom\", \"Christophe\");"); + System.out.println ("+"); + System.out.println (""); + System.out.println (" "); + System.out.println ("
un nomun prenom
"); + System.out.println ("=>"); + System.out.println (html); } }