diff --git a/build.xml b/build.xml index a03ea2e..4c8c533 100644 --- a/build.xml +++ b/build.xml @@ -11,7 +11,7 @@ - + @@ -24,7 +24,7 @@ - + @@ -33,8 +33,8 @@ - - + + @@ -43,27 +43,31 @@ - + + - - + + + + - + + @@ -72,7 +76,7 @@ - + @@ -95,7 +99,7 @@ - + diff --git a/build.xml~ b/build.xml~ index 783c08a..fd7ab0f 100644 --- a/build.xml~ +++ b/build.xml~ @@ -11,18 +11,20 @@ - + + - - + + + @@ -30,17 +32,51 @@ - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -63,7 +99,7 @@ - + @@ -75,6 +111,7 @@ + diff --git a/build/classes/xid/Presenter.class b/build/classes/xid/Presenter.class index 98297a0..29d02fa 100644 Binary files a/build/classes/xid/Presenter.class and b/build/classes/xid/Presenter.class differ diff --git a/build/classes/xid/TagData.class b/build/classes/xid/TagData.class index 5fcb308..02372ee 100644 Binary files a/build/classes/xid/TagData.class and b/build/classes/xid/TagData.class differ diff --git a/build/classes/xid/TagsData.class b/build/classes/xid/TagsData.class index ce5975b..16fcd7f 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.class b/build_test/classes/xid/Test.class deleted file mode 100644 index 85e2637..0000000 Binary files a/build_test/classes/xid/Test.class and /dev/null differ diff --git a/build_test/classes/xid/test/Test.class b/build_test/classes/xid/test/Test.class index b451845..dac4c87 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 57e9a7e..4b04cf1 100644 Binary files a/dist/test.jar and b/dist/test.jar differ diff --git a/dist/xid.jar b/dist/xid.jar index 90ada0b..b50ff03 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 db7a98b..f4bfb9e 100644 --- a/src/xid/Presenter.java +++ b/src/xid/Presenter.java @@ -1,10 +1,9 @@ -/* - * - */ package xid; + import java.util.*; import java.io.*; import javax.xml.parsers.*; +import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import org.xml.sax.*; import org.w3c.dom.*; @@ -91,7 +90,7 @@ public class Presenter /* * */ - public StringBuffer doXid (TagsData datas, StringBuffer errorOutput) + public StringBuffer doXid (TagsDataById datas, StringBuffer errorOutput) { StringBuffer result; @@ -135,7 +134,7 @@ public class Presenter /* - * + * Xid a file without data. */ static public StringBuffer doXid (String fileName, String webappPath, StringBuffer errorOutput) { @@ -160,28 +159,71 @@ public class Presenter /* - * + * Xid a string with html in. */ - static public StringBuffer doXid (Document doc, TagsData datas, String webappPath, StringBuffer errorOutput) + static public StringBuffer doXid (String html, TagsDataById datas, String webappPath, StringBuffer errorOutput) { StringBuffer result; - result = Presenter.process (doc, datas, webappPath, errorOutput); + String htmlSource; + if ((html.startsWith ("")) || + (html.startsWith (""))) + { + htmlSource = html; + } + else + { + htmlSource = "\n" + html + ""; + } + + Document doc = null; + + // StringBufferInputStream is deprecated so we use another solution. + // (see http://www.developpez.net/forums/archive/index.php/t-14101.html). + doc = buildTree (new ByteArrayInputStream (htmlSource.getBytes ()), errorOutput); + + StringBuffer htmlTarget; + htmlTarget = Presenter.process (doc, datas, webappPath, errorOutput); + + if (htmlTarget == null) + { + result = null; + } + else if ((html.startsWith ("")) || + (html.startsWith (""))) + { + result = htmlTarget; + } + else + { + String bodyContent = extractBodyContent (htmlTarget); + + if (bodyContent == null) + { + result = null; + } + else + { + result = new StringBuffer (bodyContent); + } + } // return (result); } + /* - * + * Xid a file with data. */ - static public StringBuffer doXid (String html, TagsData datas, String webappPath, StringBuffer errorOutput) + static public StringBuffer doXid (Document doc, TagsDataById datas, String webappPath, StringBuffer errorOutput) { StringBuffer result; - Document doc = null; - - result = Presenter.process (doc, datas, webappPath, errorOutput); // @@ -223,7 +265,7 @@ public class Presenter /* * */ - static protected StringBuffer processChildren (Node node, TagsData datas, String webappPath, StringBuffer errorOutput) + static protected StringBuffer processChildren (Node node, TagsDataById datas, String webappPath, StringBuffer errorOutput) { StringBuffer result; @@ -258,7 +300,7 @@ public class Presenter * @param attrMap * @param idAttr */ - static protected StringBuffer processObjectTag (Node node, NamedNodeMap attrMap, Node idAttr, TagsData datas, String webappPath, StringBuffer errorOutput) + static protected StringBuffer processObjectTag (Node node, NamedNodeMap attrMap, Node idAttr, TagsDataById datas, String webappPath, StringBuffer errorOutput) { StringBuffer result; @@ -291,7 +333,7 @@ public class Presenter } else { - log.info ("object action"); + log.debug ("object action"); result.append (""); // Build the file name. @@ -307,7 +349,7 @@ public class Presenter catch (Exception ex) { result.append ("unable to build the file tree"); - log.info ("unable to build the file tree"); + log.debug ("unable to build the file tree"); } // Extract the 'body' section. @@ -319,7 +361,7 @@ public class Presenter if (nodes.getLength () == 0) { result.append ("no body tag in include html"); - log.info ("no body tag in include html"); + log.debug ("no body tag in include html"); } else { @@ -329,7 +371,7 @@ public class Presenter catch (Exception e) { result.append ("error getting child"); - log.info ("error getting child"); + log.debug ("error getting child"); } // Process the body child as part of the primary tree. @@ -347,7 +389,7 @@ public class Presenter // result.append (""); } - log.info ("end of object action"); + log.debug ("end of object action"); // return (result); } @@ -368,7 +410,7 @@ public class Presenter static protected StringBuffer processElementWithId (Node node, NamedNodeMap attrs, Node idAttr, - TagsData datas, + TagsDataById datas, String webappPath, StringBuffer errorOutput) { @@ -378,104 +420,82 @@ public class Presenter String tag = node.getNodeName(); String idValue = idAttr.getNodeValue(); - log.info ("tag=" + tag); + log.debug ("tag=" + tag); // Get data of this id. - TagData data = datas.get (idAttr.getNodeValue ()); - String theClass; - if (data == null) - { - theClass = null; - } - else - { - theClass = data.getAttributes ().getAttribute ("class"); - } + TagDataCore dataCore = datas.get (idAttr.getNodeValue ()); - if ((theClass == null) || - (!theClass.equals ("xid:nodisplay"))) + if (dataCore == null) { - if ((tag.equals ("a")) || - (tag.equals ("b")) || - (tag.equals ("div")) || - (tag.equals ("em")) || - (tag.equals ("p")) || - (tag.equals ("span"))) + result.append (Presenter.processElementBasically (node, datas, webappPath, errorOutput)); + } + else if (dataCore instanceof TagData) + { + TagData data = (TagData) dataCore; + + String theClass; + if (data == null) { - // Open the tag. - result.append ('<'); - result.append (node.getNodeName()); - - // Build the tag attributes. - result.append (processAttributes (attrs, data)); - //result.append (attributesFromNode (attrs)); - //result.append (attributesFromTagData (data)); - - result.append ('>'); - - // Insert data. - if ((data == null) || - (data.display ().equals (""))) - { - result.append (processChildren (node, datas, webappPath, errorOutput)); - } - else - { - result.append (data.display ()); - } - - // Close the tag. - result.append (""); - result.append (node.getNodeName()); - result.append ('>'); + theClass = null; } - else if (tag.equals("img")) + else + { + theClass = data.getAttributes ().getAttribute ("class"); + } + + if ((theClass == null) || + (!theClass.equals ("xid:nodisplay"))) { - // Possibility to merge with previous case if is a correct tag. - // Open the tag. result.append ("<"); result.append (node.getNodeName()); - // Build the tag attributes. + // Build attributes. result.append (processAttributes (attrs, data)); - //result.append (attributesFromNode (attrs)); - //result.append (attributesFromTagData (data)); - result.append ("/>"); - } - else if (tag.equals("textarea")) - { - result.append ("[textarea]"); - } - else if (tag.equals("select")) - { - result.append ("[select]"); - } - else if (tag.equals("input")) - { - result.append ("[input]"); - } - else if (tag.equals("table")) - { - result.append ("[table]"); - } - else if (tag.equals("tbody")) - { - result.append ("[tbody]"); - } - else if (tag.equals("object")) - { - result.append (processObjectTag (node, attrs, idAttr, datas, webappPath, errorOutput)); - } - else - { - log.info ("Id on <" + tag + "> not supported."); + if ((node.getChildNodes () == null) && + ((data == null) || data.display ().equals (""))) + { + // Close the tag. + result.append (" />"); + } + else + { + result.append ('>'); + + // Insert data. + if ((data == null) || + (data.display ().equals (""))) + { + result.append (processChildren (node, datas, webappPath, errorOutput)); + } + else + { + result.append (data.display ()); + } + + // Close the tag. + result.append (""); + result.append (node.getNodeName()); + result.append ('>'); + } } } + else if (dataCore instanceof TagsData) + { + TagsData data = (TagsData) dataCore; + } + else if (dataCore instanceof TagsDataById) + { + TagsDataById data = (TagsDataById) dataCore; + } + else + { + log.warn ("Unknow type of TagDataId"); + } // - log.info ("Exit"); + log.debug ("Exit"); return (result); } @@ -485,9 +505,9 @@ public class Presenter * Recursive method that processes a node and any child nodes. * */ - static protected StringBuffer process (Node node, TagsData datas, String webappPath, StringBuffer errorOutput) + static protected StringBuffer process (Node node, TagsDataById datas, String webappPath, StringBuffer errorOutput) { - log.info ("Enter"); + log.debug ("Enter"); String TRANSITIONAL_DTD = "xhtml1-transitional.dtd"; String TRANSITIONAL_DOCTYPE = "\n"; @@ -498,7 +518,7 @@ public class Presenter // Is there anything to do? if (node != null) { - log.info ("nodeName=" + node.getNodeName ()); + log.debug ("nodeName=" + node.getNodeName ()); // Find the name attribute value. String name; @@ -513,27 +533,31 @@ public class Presenter { case Node.DOCUMENT_NODE: { - log.info ("case Node.DOCUMENT_NODE"); + log.debug ("case Node.DOCUMENT_NODE"); DocumentType dt = ((Document) node).getDoctype(); - String publicId = dt.getPublicId(); - String systemId = dt.getSystemId(); - - if (systemId.equals(TRANSITIONAL_DTD)) + + if (dt != null) { - result.append(TRANSITIONAL_DOCTYPE); + String publicId = dt.getPublicId(); + String systemId = dt.getSystemId(); + + if (systemId.equals(TRANSITIONAL_DTD)) + { + result.append(TRANSITIONAL_DOCTYPE); + } + + // Log.write(Log.TRACE,"publicId = " + publicId); + // Log.write(Log.TRACE,"systemId = " + systemId); } - - // Log.write(Log.TRACE,"publicId = " + publicId); - // Log.write(Log.TRACE,"systemId = " + systemId); - + result.append (Presenter.process (((Document) node).getDocumentElement(), datas, webappPath, errorOutput)); - + break; } case Node.ELEMENT_NODE: { - log.info ("case Node.ELEMENT_NODE"); + log.debug ("case Node.ELEMENT_NODE"); NamedNodeMap attrs = node.getAttributes (); Node idAttr = attrs.getNamedItem ("id"); @@ -553,7 +577,7 @@ public class Presenter // handle entity reference nodes case Node.ENTITY_REFERENCE_NODE: { - log.info ("case Node.ENTITY_REFERENCE_NODE"); + log.debug ("case Node.ENTITY_REFERENCE_NODE"); result.append ('&'); result.append (node.getNodeName()); @@ -564,7 +588,7 @@ public class Presenter // print cdata sections case Node.CDATA_SECTION_NODE: { - log.info ("case Node.CDATA_SECTION_NODE"); + log.debug ("case Node.CDATA_SECTION_NODE"); result.append (""); + int endBody = dataLowerCase.indexOf (""); + + // Note: as failed search is improbable, no care about complexity + // in failed search case. + if ((startBody == -1) || (endBody == -1)) + { + result = null; + } + else + { + result = data.substring (startBody + 6, endBody).trim (); + } + + // + return (result); + } } diff --git a/src/xid/TagData.java b/src/xid/TagData.java index 8e85d37..8bdd109 100644 --- a/src/xid/TagData.java +++ b/src/xid/TagData.java @@ -15,7 +15,7 @@ import java.io.*; * application may also implement it's own TagData classes. * */ -public abstract class TagData implements Serializable +public class TagData implements Serializable, TagDataCore { public enum MODE {REPLACE, APPEND, IGNORE}; @@ -23,22 +23,60 @@ public abstract class TagData implements Serializable protected boolean excludeSection; protected MODE displayMode = MODE.REPLACE; + String content; /* * */ public TagData () { - attributes = null; - excludeSection = false; - displayMode = MODE.REPLACE; + this.attributes = null; + this.excludeSection = false; + this.displayMode = MODE.REPLACE; + this.content = ""; } /* * */ - public abstract String display(); + public TagData (String text) + { + this.attributes = null; + this.excludeSection = false; + this.displayMode = MODE.REPLACE; + this.content = text; + } + + + /* + * + */ + public String display () + { + String result; + + if (this.content == null) + { + result = ""; + } + else + { + result = this.content; + } + + // + return (result); + } + + + /* + * + */ + public void setContent (String text) + { + this.content = text; + } /* @@ -62,14 +100,6 @@ public abstract class TagData implements Serializable return (result); } - /* - * ?? - */ - public String getValue() - { - return display(); - } - /* * diff --git a/src/xid/TagsData.java b/src/xid/TagsData.java index 5cb5ee7..1191821 100644 --- a/src/xid/TagsData.java +++ b/src/xid/TagsData.java @@ -6,7 +6,7 @@ import java.io.*; /* * */ -public class TagsData extends HashMap +public class TagsData extends Vector implements TagDataCore { /** * @@ -15,33 +15,4 @@ public class TagsData extends HashMap { super (); } - - - /* - * - */ - public void setId (String id, TagData data) - { - this.put (id, data); - } - - /* - * - */ - public TagData getId (String id) - { - TagData result; - - if (this.containsKey (id)) - { - result = this.get (id); - } - else - { - result = null; - } - - // - return (result); - } } diff --git a/src/xid/TextTagData.java b/src/xid/TextTagData.java deleted file mode 100644 index 3bc920a..0000000 --- a/src/xid/TextTagData.java +++ /dev/null @@ -1,91 +0,0 @@ -package xid; - -import java.io.*; - -/** - * This class can be used to set up text for display. - * - */ -public class TextTagData extends TagData implements Serializable -{ - private static final long serialVersionUID = -4117726979708043231L; - - protected String text; - - /** - * Constructs a TextTagData with the text supplied. - * - * @param text The text to be displayed. - */ - public TextTagData (String text) - { - super (); - this.text = text; - } - - - /* - * - */ - public TextTagData() - { - super(); - this.text = ""; - this.displayMode = MODE.IGNORE; - } - - - /** - * This method will be called by the View when it encounters - * an id for a TextTagData object. - */ - public String display () - { - String result; - - if (text == null) - { - result = ""; - } - else - { - result = this.text; - } - - // - return (result); - } - - - /** - * Allows the text content to be changed. - * @param text - */ - public void setText (String text) - { - this.text = text; - } - - - /** - * Returns the value as an int. - * - * @return The users input as an int or -1 if not a valid number. - */ - public int getValueAsInt() - { - int result; - - try - { - result = Integer.parseInt(text); - } - catch (NumberFormatException e) - { - result = -1; - } - - // - return (result); - } -} diff --git a/test/xid/test/Test.java b/test/xid/test/Test.java index d0e792c..86d1cef 100644 --- a/test/xid/test/Test.java +++ b/test/xid/test/Test.java @@ -1,73 +1,227 @@ -package xid; +package xid.test; 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 + { + // Initialize log. + org.apache.log4j.Logger log = null; + + org.apache.log4j.BasicConfigurator.configure (); + + + log = org.apache.log4j.Logger.getRootLogger (); + //log.setLevel (org.apache.log4j.Level.INFO); + log.setLevel (org.apache.log4j.Level.INFO); + + log.info ("Enter"); + + // + log.info ("Set the log file format..."); + + + // log = org.apache.log4j.Category.getInstance(Application.class.getName()); + log.info ("... done."); + + log.debug ("Exit"); + log = org.apache.log4j.Logger.getLogger (Test.class.getName ()); + } + + + /** + * + */ public static void main(String[] args) { System.out.println("Hello World!"); - Presenter xid = new Presenter (getServletContext ().getRealPath ("/"), "testXid.html"); + //test (); // - TagsData datas = new TagsData (); - TextTagData text; + TagsDataById datas; + TagData tag; + - // Populate attributes of Test 03. - text = new TextTagData (); - datas.put ("test03", text); - text.setText ("mummy"); - text.getAttributes ().appendAttribute ("style", "background: blue;"); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "totoClass"); StringBuffer html; StringBuffer errorMessage; + // Populate attributes of Test 03. + datas = new TagsDataById (); + tag = new TagData (); + tag.setContent ("Superman"); + datas.put ("name", tag); + errorMessage = new StringBuffer (); - html = xid.doXid (datas, errorMessage); + html = Presenter.doXid ("a name", datas, "", errorMessage); + System.out.println ("----------------------------"); + System.out.println ("datas = new TagsDataId ();"); + System.out.println ("tag = new TagData ();"); + 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); - // Display page. - response.setContentType ("text/html"); - PrintWriter out = response.getWriter(); - out.println (""); - out.println (""); - out.println ("XID TEST"); - out.println (""); - out.println (""); + // Populate attributes of Test 03. + datas = new TagsDataById (); + datas.setContent ("name", "Superman"); - out.println (""); - out.println ("XID TEST"); - - if (errorMessage.length () != 0) - { - out.println ("An error occured in Xid treatment."); - out.println (""); - out.println (errorMessage); - out.println (""); - out.println (""); - out.println ("" + Presenter.restoreEntities (html) + ""); - out.println (""); - } - else - { - out.println ("" + Presenter.restoreEntities (html) + ""); - } + errorMessage = new StringBuffer (); + html = Presenter.doXid ("a name", datas, "", errorMessage); - out.println (""); - out.println (""); - - log.info ("Exit"); + System.out.println ("----------------------------"); + System.out.println ("datas = new TagsDataId ();"); + System.out.println ("datas.setContent (\"name\", \"Superman\");"); + System.out.println ("+"); + System.out.println ("a name"); + System.out.println ("=>"); + System.out.println (html); + + // Populate attributes of Test 03. + datas = new TagsDataById (); + tag = new TagData (); + 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 ("----------------------------"); + System.out.println ("datas = new TagsDataId ();"); + System.out.println ("tag = new TagData ();"); + 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. + datas = new TagsDataById (); + datas.setContent ("lastname", "Spiderman"); + datas.appendAttribute ("lastname", "style", "background: blue;"); + datas.appendAttribute ("lastname", "style", "foreground: red;"); + datas.setAttribute ("lastname", "class", "nameClass"); + + + errorMessage = new StringBuffer (); + html = Presenter.doXid ("a last name", datas, "", errorMessage); + + System.out.println ("----------------------------"); + System.out.println ("datas = new TagsDataId ();"); + System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); + System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");"); + System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\""); + System.out.println ("datas.setAttribute (\"lastname\", \"class\", \"nameClass\");"); + System.out.println ("+"); + System.out.println ("a last name"); + System.out.println ("=>"); + System.out.println (html); + System.out.println ("----------------------------"); } } diff --git a/test/xid/test/Test.java~ b/test/xid/test/Test.java~ index a55f3fe..8d5d95c 100644 --- a/test/xid/test/Test.java~ +++ b/test/xid/test/Test.java~ @@ -1,16 +1,132 @@ -package xid; +package xid.test; 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 + { + log = org.apache.log4j.Logger.getLogger (Test.class.getName ()); + } + + + /** + * + */ public static void main(String[] args) { System.out.println("Hello World!"); + + //test (); + + // + TagsDataById datas = new TagsDataById (); + TagData tag; + + // Populate attributes of Test 03. + tag = new TagData (); + tag.setContent ("hello"); + tag.getAttributes ().appendAttribute ("style", "background: blue;"); + tag.getAttributes ().appendAttribute ("style", "foreground: red;"); + tag.getAttributes ().setAttribute ("class", "totoClass"); + datas.put ("test03", tag); + + StringBuffer html; + StringBuffer errorMessage; + + errorMessage = new StringBuffer (); + html = Presenter.doXid ("bla", datas, "", errorMessage); + + System.out.println ("----------------------------"); + System.out.println (html); + System.out.println ("----------------------------"); } } diff --git a/webapp-examples/WEB-INF/classes/xid/Test.java b/webapp-examples/WEB-INF/classes/xid/Test.java index b9818ee..20c2945 100644 --- a/webapp-examples/WEB-INF/classes/xid/Test.java +++ b/webapp-examples/WEB-INF/classes/xid/Test.java @@ -131,35 +131,6 @@ public class Test extends HttpServlet log.info ("Exit"); } - - - /* - * - */ - static public String extractBody (StringBuffer data) - { - String result = null; - - // Extraire le contenu du body. - String dataLowerCase = data.toString ().toLowerCase (); - - int startBody = dataLowerCase.indexOf ("") + 6; - int endBody = dataLowerCase.indexOf (""); - - // Note: as failed search is improbable, no care about complexity - // in failed search case. - if ((startBody == -1) || (endBody == -1)) - { - result = null; - } - else - { - result = data.substring (startBody, endBody).trim (); - } - - // - return (result); - } } // //////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/webapp-examples/WEB-INF/lib/xid.jar b/webapp-examples/WEB-INF/lib/xid.jar index 9fb73b7..0235c43 100644 Binary files a/webapp-examples/WEB-INF/lib/xid.jar and b/webapp-examples/WEB-INF/lib/xid.jar differ
"); - out.println (errorMessage); - out.println ("
" + Presenter.restoreEntities (html) + "