Move of TagsData in TagsDataByIndex and Split of TagsDataById in TagsData and TagsDataById.

This commit is contained in:
administrateur 2007-01-25 23:53:43 +01:00
parent 70e73822cb
commit ff46c66f50
10 changed files with 258 additions and 298 deletions

Binary file not shown.

Binary file not shown.

BIN
dist/test.jar vendored

Binary file not shown.

BIN
dist/xid.jar vendored

Binary file not shown.

View file

@ -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++)

View file

@ -6,7 +6,7 @@ import java.io.*;
/*
*
*/
public class TagsData extends Vector<TagDataCore> implements TagDataCore
public class TagsData extends TagsDataById
{
/**
*
@ -15,4 +15,209 @@ public class TagsData extends Vector<TagDataCore> 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);
}
}

View file

@ -8,7 +8,7 @@ import java.io.*;
*/
public class TagsDataById extends HashMap<String, TagDataCore> implements TagDataCore
{
/**
/*
*
*/
public TagsDataById ()
@ -36,197 +36,4 @@ public class TagsDataById extends HashMap<String, TagDataCore> 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);
}
}

View file

@ -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 ("<div id='name'>a name</div >", 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 ("<div id='name'>a name</div >", 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 ("<div id='name'>a name</div >");
@ -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 ("<div id='lastname'>a last name</div >", 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 ("<div id='lastname'>a last name</div >", 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 ("<ul>\n <li id='words'>a word</li>\n</ul>", 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 ("<table>\n <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n</table>", 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\");");

View file

@ -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<String, Object> implements TTagDataCore
{
}
class TTagsData extends Vector<Object> 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 ("<div id='name'>a name</div >", 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 ("<div id='name'>a name</div >", 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 ("<div id='name'>a name</div >");
@ -188,7 +106,7 @@ class Test
html = Presenter.doXid ("<div id='lastname'>a last name</div >", 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 ("<div id='lastname'>a last name</div >", 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 ("<ul>\n <li id='words'>a word</li>\n</ul>", 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 ("</ul>");
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 ("<table>\n <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n</table>", 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 ("<table>");
System.out.println (" <tr id='identity'><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>");
System.out.println ("</table>");
System.out.println ("=>");
System.out.println (html);
}
}