diff --git a/build/classes/fr/devinsy/xid/Data.class b/build/classes/fr/devinsy/xid/Data.class index 2d7c4a6..c1b230c 100644 Binary files a/build/classes/fr/devinsy/xid/Data.class and b/build/classes/fr/devinsy/xid/Data.class differ diff --git a/build/classes/fr/devinsy/xid/DomPresenter.class b/build/classes/fr/devinsy/xid/DomPresenter.class index 6020949..cab7669 100644 Binary files a/build/classes/fr/devinsy/xid/DomPresenter.class and b/build/classes/fr/devinsy/xid/DomPresenter.class differ diff --git a/build/classes/fr/devinsy/xid/FilePresenter.class b/build/classes/fr/devinsy/xid/FilePresenter.class index 0799322..45e5f1f 100644 Binary files a/build/classes/fr/devinsy/xid/FilePresenter.class and b/build/classes/fr/devinsy/xid/FilePresenter.class differ diff --git a/build/classes/fr/devinsy/xid/Presenter.class b/build/classes/fr/devinsy/xid/Presenter.class index f9e70fb..caeba96 100644 Binary files a/build/classes/fr/devinsy/xid/Presenter.class and b/build/classes/fr/devinsy/xid/Presenter.class differ diff --git a/build/classes/fr/devinsy/xid/StringPresenter.class b/build/classes/fr/devinsy/xid/StringPresenter.class index c16fc92..fae023a 100644 Binary files a/build/classes/fr/devinsy/xid/StringPresenter.class and b/build/classes/fr/devinsy/xid/StringPresenter.class differ diff --git a/build/classes/fr/devinsy/xid/TagsDataById.class b/build/classes/fr/devinsy/xid/TagsDataById.class deleted file mode 100644 index 444d7df..0000000 Binary files a/build/classes/fr/devinsy/xid/TagsDataById.class and /dev/null differ diff --git a/demo/XidDemo.java b/demo/XidDemo.java index c6cbec9..8a35774 100644 --- a/demo/XidDemo.java +++ b/demo/XidDemo.java @@ -207,33 +207,5 @@ class XidDemo System.out.println (html); - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - 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"); - source.append ("

one

\n"); - source.append ("
\n"); - source.append ("
\n"); - source.append ("

three

\n"); - source.append ("
"); - htmlSource = source.toString (); - html = StringPresenter.doXid (htmlSource, datas, errorMessage); - - System.out.println (htmlSource); - System.out.println ("+"); - 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/src/fr/devinsy/xid/Data.java b/src/fr/devinsy/xid/Data.java index e20a4ba..24ab8ee 100644 --- a/src/fr/devinsy/xid/Data.java +++ b/src/fr/devinsy/xid/Data.java @@ -8,7 +8,6 @@ package fr.devinsy.xid; public class Data { protected IdsDataById idsDataById; - protected TagsDataById tagsDataById; /** @@ -17,7 +16,6 @@ public class Data public Data () { this.idsDataById = new IdsDataById (); - this.tagsDataById = new TagsDataById (); } @@ -35,20 +33,6 @@ public class Data } - /** - * - */ - public TagsDataById getTagsDataById () - { - TagsDataById result; - - result = this.tagsDataById; - - // - return (result); - } - - /** * */ @@ -160,25 +144,9 @@ public class Data */ public void setContent (String id, String content) { - if (id.startsWith ("<")) - { - String tagName = id.substring (1, id.length () - 1); + IdData idData = this.getIdData (id); - TagData tag = this.tagsDataById.getId (tagName); - if (tag == null) - { - tag = new TagData (); - this.tagsDataById.setId (tagName, tag); - } - - tag.setContent (content); - } - else - { - IdData idData = this.getIdData (id); - - idData.setContent (content); - } + idData.setContent (content); } @@ -247,25 +215,9 @@ public class Data */ public void setAttribute (String id, String label, String value) { - if (id.startsWith ("<")) - { - String tagName = id.substring (1, id.length () - 1); + IdData tag = this.getIdData (id); - TagData tag = this.tagsDataById.getId (tagName); - if (tag == null) - { - tag = new TagData (); - this.tagsDataById.setId (tagName, tag); - } - - tag.getAttributes ().setAttribute (label, value); - } - else - { - IdData tag = this.getIdData (id); - - tag.getAttributes ().setAttribute (label, value); - } + tag.getAttributes ().setAttribute (label, value); } diff --git a/src/fr/devinsy/xid/DomPresenter.java b/src/fr/devinsy/xid/DomPresenter.java index e0f5e0c..ddf84e9 100644 --- a/src/fr/devinsy/xid/DomPresenter.java +++ b/src/fr/devinsy/xid/DomPresenter.java @@ -140,13 +140,13 @@ public class DomPresenter extends Presenter */ public StringBuffer doXid (Data datas, StringBuffer errorOutput) { - return (doXid (datas.getIdsDataById (), datas.getTagsDataById (), errorOutput)); + return (doXid (datas.getIdsDataById (), errorOutput)); } /* * */ - public StringBuffer doXid (IdsDataById datas, TagsDataById tagsData, StringBuffer errorOutput) + public StringBuffer doXid (IdsDataById datas, StringBuffer errorOutput) { StringBuffer result; @@ -160,7 +160,7 @@ public class DomPresenter extends Presenter else { // Build the web page. - result = Presenter.doXid (this.doc, datas, tagsData, this.webappPath, errorOutput); + result = Presenter.doXid (this.doc, datas, this.webappPath, errorOutput); } // @@ -172,18 +172,10 @@ public class DomPresenter extends Presenter * Xid a file with data. */ static public StringBuffer doXid (Document doc, IdsDataById datas, String webappPath, StringBuffer errorOutput) - { - return (doXid (doc, datas, null, webappPath, errorOutput)); - } - - /* - * Xid a file with data. - */ - static public StringBuffer doXid (Document doc, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) { StringBuffer result; - result = Presenter.process (doc, datas, tagsData, webappPath, errorOutput); + result = Presenter.process (doc, datas, webappPath, errorOutput); // return (result); diff --git a/src/fr/devinsy/xid/FilePresenter.java b/src/fr/devinsy/xid/FilePresenter.java index bfbb82a..21120f8 100644 --- a/src/fr/devinsy/xid/FilePresenter.java +++ b/src/fr/devinsy/xid/FilePresenter.java @@ -91,14 +91,14 @@ public class FilePresenter extends DomPresenter */ public StringBuffer doXid (Data datas, StringBuffer errorOutput) { - return (doXid (datas.getIdsDataById (), datas.getTagsDataById (), errorOutput)); + return (doXid (datas.getIdsDataById (), errorOutput)); } /* * */ - public StringBuffer doXid (IdsDataById datas, TagsDataById tagsData, StringBuffer errorOutput) + public StringBuffer doXid (IdsDataById datas, StringBuffer errorOutput) { StringBuffer result; @@ -134,7 +134,7 @@ public class FilePresenter extends DomPresenter } // Build the web page. - result = Presenter.doXid (doc, datas, tagsData, this.webappPath, errorOutput); + result = Presenter.doXid (doc, datas, this.webappPath, errorOutput); // return (result); @@ -158,7 +158,7 @@ public class FilePresenter extends DomPresenter { Presenter.addMetaTag (doc, "generator", "XID 0.0"); - result = Presenter.doXid (doc, null, null, webappPath, errorOutput); + result = Presenter.doXid (doc, null, webappPath, errorOutput); } // diff --git a/src/fr/devinsy/xid/Presenter.java b/src/fr/devinsy/xid/Presenter.java index ec828b0..6f8b5c6 100644 --- a/src/fr/devinsy/xid/Presenter.java +++ b/src/fr/devinsy/xid/Presenter.java @@ -54,18 +54,10 @@ public class Presenter * Xid a file with data. */ static public StringBuffer doXid (Document doc, IdsDataById datas, String webappPath, StringBuffer errorOutput) - { - return (doXid (doc, datas, null, webappPath, errorOutput)); - } - - /* - * Xid a file with data. - */ - static public StringBuffer doXid (Document doc, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) { StringBuffer result; - result = Presenter.process (doc, datas, tagsData, webappPath, errorOutput); + result = Presenter.process (doc, datas, webappPath, errorOutput); // return (result); @@ -153,11 +145,11 @@ public class Presenter /* * */ - static protected StringBuffer processChildren (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) + static protected StringBuffer processChildren (Node node, IdsDataById datas, String webappPath, StringBuffer errorOutput) { StringBuffer result; - result = processChildren (node, datas, tagsData, webappPath, "", errorOutput); + result = processChildren (node, datas, webappPath, "", errorOutput); // return (result); @@ -169,7 +161,6 @@ public class Presenter */ static protected StringBuffer processChildren (Node node, IdsDataById datas, - TagsDataById tagsData, String webappPath, String suffix, StringBuffer errorOutput) @@ -228,12 +219,12 @@ public class Presenter lineCounter += 1; if (lineCounter == 1) { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, webappPath, suffix, errorOutput)); } } else { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, webappPath, suffix, errorOutput)); } } break; @@ -248,12 +239,12 @@ public class Presenter if ((lineCounter == 1) || (lineCounter == 2)) { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, webappPath, suffix, errorOutput)); } } else { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, webappPath, suffix, errorOutput)); } } break; @@ -268,12 +259,12 @@ public class Presenter if ((attrs2 != null) && (attrs2.getNamedItem ("id") != null)) { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, webappPath, suffix, errorOutput)); } } else { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, webappPath, suffix, errorOutput)); } } break; @@ -287,12 +278,12 @@ public class Presenter if ((attrs2 == null) || (attrs2.getNamedItem ("id") == null)) { - result.append (process (children.item(childIndex), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (process (children.item(childIndex), datas, webappPath, suffix, errorOutput)); } } else { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, webappPath, suffix, errorOutput)); } } break; @@ -300,7 +291,7 @@ public class Presenter case ALL_ROWS: for (int childIndex = 0; childIndex < childrenCount; childIndex++) { - result.append (process (children.item(childIndex), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (process (children.item(childIndex), datas, webappPath, suffix, errorOutput)); } break; } @@ -322,7 +313,6 @@ public class Presenter NamedNodeMap attrMap, Node idAttr, IdsDataById datas, - TagsDataById tagsData, String webappPath, StringBuffer errorOutput) { @@ -352,7 +342,7 @@ public class Presenter (attrMap.getNamedItem ("data") == null)) { // STU: do default action. - Presenter.processElementBasically (node, datas, tagsData, webappPath, errorOutput); + Presenter.processElementBasically (node, datas, webappPath, errorOutput); } else { @@ -411,7 +401,7 @@ public class Presenter int childCount = bodyChildren.getLength (); for (int childCounter = 0; childCounter < childCount; childCounter++) { - result.append (process (bodyChildren.item (childCounter), datas, tagsData, webappPath, errorOutput)); + result.append (process (bodyChildren.item (childCounter), datas, webappPath, errorOutput)); } } } @@ -447,7 +437,7 @@ public class Presenter { StringBuffer result; - result = processElementWithId (node, attrs, idAttr, datas, null, "", webappPath, errorOutput); + result = processElementWithId (node, attrs, idAttr, datas, "", webappPath, errorOutput); // return (result); @@ -469,7 +459,6 @@ public class Presenter NamedNodeMap attrs, Node idAttr, IdsDataById datas, - TagsDataById tagsData, String webappPath, String suffix, StringBuffer errorOutput) @@ -481,7 +470,7 @@ public class Presenter if (tag.equals ("object")) { - result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput)); + result.append (processObjectTag (node, attrs, idAttr, datas, webappPath, errorOutput)); } else { @@ -494,7 +483,7 @@ public class Presenter if (dataCore == null) { - result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput)); + result.append (Presenter.processElementBasically (node, datas, webappPath, suffix, errorOutput)); } else if (dataCore instanceof IdData) { @@ -518,25 +507,7 @@ public class Presenter result.append (node.getNodeName()); // Build attributes. - Attributes tagAttributes; - if (tagsData == null) - { - tagAttributes = null; - } - else - { - TagData tagData = tagsData.getId (node.getNodeName ()); - if (tagData == null) - { - tagAttributes = null; - } - else - { - tagAttributes = tagData.getAttributes (); - } - } - - result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, suffix)); + result.append (processAttributes (attrs, data.getAttributes (), suffix)); if ((node.getChildNodes () == null) && ((data == null) || (data.display () == null))) @@ -554,7 +525,7 @@ public class Presenter if ((data == null) || (data.display () == null)) { - result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput)); + result.append (processChildren (node, datas, webappPath, suffix, errorOutput)); } else { @@ -583,26 +554,7 @@ public class Presenter result.append ("<"); result.append (node.getNodeName()); - // Build attributes. - Attributes tagAttributes; - if (tagsData == null) - { - tagAttributes = null; - } - else - { - TagData tagData = tagsData.getId (node.getNodeName ()); - if (tagData == null) - { - tagAttributes = null; - } - else - { - tagAttributes = tagData.getAttributes (); - } - } - - result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, Integer.toString (nLine))); + result.append (processAttributes (attrs, data.getAttributes (), Integer.toString (nLine))); if ((node.getChildNodes () == null) && ((data == null) || (data.display () == null))) @@ -620,7 +572,7 @@ public class Presenter // Insert data. if ((data == null) || (data.display () == null)) { - result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput)); + result.append (processChildren (node, datas, webappPath, suffix, errorOutput)); } else { @@ -638,7 +590,7 @@ public class Presenter // Manage a Hashmap. IdsDataById data = (IdsDataById) tags.elementAt (nLine); - result.append (Presenter.processElementWithId (node, attrs, idAttr, data, tagsData, webappPath, Integer.toString (nLine), errorOutput)); + result.append (Presenter.processElementWithId (node, attrs, idAttr, data, webappPath, Integer.toString (nLine), errorOutput)); result.append ('\n'); } } @@ -659,11 +611,11 @@ public class Presenter /** * */ - static protected StringBuffer process (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) + static protected StringBuffer process (Node node, IdsDataById datas, String webappPath, StringBuffer errorOutput) { StringBuffer result; - result = Presenter.process (node, datas, tagsData, webappPath, "", errorOutput); + result = Presenter.process (node, datas, webappPath, "", errorOutput); // return (result); @@ -674,7 +626,7 @@ public class Presenter * Recursive method that processes a node and any child nodes. * */ - static protected StringBuffer process (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, String suffix, StringBuffer errorOutput) + static protected StringBuffer process (Node node, IdsDataById datas, String webappPath, String suffix, StringBuffer errorOutput) { logger.debug ("Enter"); String TRANSITIONAL_DTD = "xhtml1-transitional.dtd"; @@ -718,7 +670,7 @@ public class Presenter // Log.write(Log.TRACE,"systemId = " + systemId); } - result.append (Presenter.process (((Document) node).getDocumentElement(), datas, tagsData, webappPath, suffix, errorOutput)); + result.append (Presenter.process (((Document) node).getDocumentElement(), datas, webappPath, suffix, errorOutput)); break; } @@ -736,7 +688,6 @@ public class Presenter attrs, idAttr, datas, - tagsData, webappPath, suffix, errorOutput)); @@ -748,11 +699,11 @@ public class Presenter if (tag.equals ("object")) { - result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput)); + result.append (processObjectTag (node, attrs, idAttr, datas, webappPath, errorOutput)); } else { - result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput)); + result.append (Presenter.processElementBasically (node, datas, webappPath, suffix, errorOutput)); } } @@ -820,11 +771,11 @@ public class Presenter /* * */ - static StringBuffer processElementBasically (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) + static StringBuffer processElementBasically (Node node, IdsDataById datas, String webappPath, StringBuffer errorOutput) { StringBuffer result; - result = processElementBasically (node, datas, tagsData, webappPath, "", errorOutput); + result = processElementBasically (node, datas, webappPath, "", errorOutput); // return (result); @@ -834,7 +785,7 @@ public class Presenter /* * */ - static StringBuffer processElementBasically (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, String suffix, StringBuffer errorOutput) + static StringBuffer processElementBasically (Node node, IdsDataById datas, String webappPath, String suffix, StringBuffer errorOutput) { StringBuffer result; result = new StringBuffer (); @@ -843,30 +794,6 @@ public class Presenter result.append ('<'); result.append (node.getNodeName()); - // Build the tag attributes. - Attributes tagAttributes; - if (tagsData == null) - { - tagAttributes = null; - } - else - { - TagData tagData = tagsData.getId (node.getNodeName ()); - if (tagData == null) - { - tagAttributes = null; - } - else - { - tagAttributes = tagData.getAttributes (); - } - } - - result.append (processAttributes (node.getAttributes (), - tagAttributes, - null, - suffix)); - // if (node.getChildNodes () == null) { @@ -876,7 +803,7 @@ public class Presenter { result.append('>'); - result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput)); + result.append (processChildren (node, datas, webappPath, suffix, errorOutput)); result.append(" -{ - - private static final long serialVersionUID = 7818145931750600119L; - - /* - * - */ - public TagsDataById () - { - super (); - } - - /* - * - */ - public void setId (String id, TagData data) - { - this.put (id, data); - } - - /* - * - */ - public TagData getId (String id) - { - TagData result; - - result = this.get (id); - - // - return (result); - } - -}