TagsData becomes Data.
This commit is contained in:
parent
c686420613
commit
ace3aefa48
7 changed files with 106 additions and 154 deletions
Binary file not shown.
Binary file not shown.
|
@ -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 ("<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 = new Data ();
|
||||
datas.setContent ("name", "Superman");
|
||||
|
||||
errorMessage = new StringBuffer ();
|
||||
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 ("+");
|
||||
System.out.println ("<div id='name'>a name</div >");
|
||||
|
@ -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 ("<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 = 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 ("<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.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 ("<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\", 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 ("</table>");
|
||||
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 ("<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");
|
||||
|
@ -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 (\"<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);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
BIN
dist/xid.jar
vendored
BIN
dist/xid.jar
vendored
Binary file not shown.
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue