Thread: [Ejtools-cvs] CVS: libraries/xmlweb/src/main/net/sourceforge/ejtools/xml XmlComponent.java,1.1,1.2 X
Brought to you by:
letiemble
Update of /cvsroot/ejtools/libraries/xmlweb/src/main/net/sourceforge/ejtools/xml In directory usw-pr-cvs1:/tmp/cvs-serv24669/xmlweb/src/main/net/sourceforge/ejtools/xml Modified Files: XmlComponent.java XmlContainer.java XmlEditor.java XmlLink.java XmlPrintable.java XmlText.java XmlTreeNode.java Log Message: Change XML generation from DOM Element to toXml method Index: XmlComponent.java =================================================================== RCS file: /cvsroot/ejtools/libraries/xmlweb/src/main/net/sourceforge/ejtools/xml/XmlComponent.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlComponent.java 20 Apr 2002 11:42:51 -0000 1.1 --- XmlComponent.java 25 Apr 2002 20:15:25 -0000 1.2 *************** *** 45,69 **** * * @param document Description of Parameter - * @exception Exception Description of Exception - */ - public void appendTo(Document document) throws Exception - { - document.appendChild(this.printXml(document)); - } - - - - /** - * Description of the Method - * - * @param document Description of Parameter * @return Description of the Returned Value * @exception Exception Description of Exception */ ! public Element printXml(Document document) throws Exception { ! Element element = document.createElement(this.name); ! return element; } --- 45,58 ---- * * @param document Description of Parameter * @return Description of the Returned Value * @exception Exception Description of Exception */ ! public String toXml() { ! String result = ""; ! result= result+ "<"+this.name+"/>\n"; ! ! return result; } Index: XmlContainer.java =================================================================== RCS file: /cvsroot/ejtools/libraries/xmlweb/src/main/net/sourceforge/ejtools/xml/XmlContainer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlContainer.java 20 Apr 2002 11:42:51 -0000 1.1 --- XmlContainer.java 25 Apr 2002 20:15:25 -0000 1.2 *************** *** 43,49 **** * @exception Exception Description of Exception */ ! public Element printXml(Document document) throws Exception { ! Element element = document.createElement(this.name); // Append the children --- 43,51 ---- * @exception Exception Description of Exception */ ! public String toXml() { ! String result = ""; ! ! result= result+ "<"+this.name+">\n"; // Append the children *************** *** 51,58 **** { XmlPrintable object = (XmlPrintable) this.elementAt(i); ! element.appendChild(object.printXml(document)); } ! return element; } --- 53,62 ---- { XmlPrintable object = (XmlPrintable) this.elementAt(i); ! result = result + object.toXml(); } ! result= result+ "</"+this.name+">\n"; ! ! return result; } Index: XmlEditor.java =================================================================== RCS file: /cvsroot/ejtools/libraries/xmlweb/src/main/net/sourceforge/ejtools/xml/XmlEditor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlEditor.java 20 Apr 2002 11:42:51 -0000 1.1 --- XmlEditor.java 25 Apr 2002 20:15:25 -0000 1.2 *************** *** 69,79 **** * @exception Exception Description of Exception */ ! public Element printXml(Document document) throws Exception { ! Element element = super.printXml(document); ! element.setAttribute("type", this.type); ! return element; } } --- 69,81 ---- * @exception Exception Description of Exception */ ! public String toXml() { ! String result = ""; ! result= result+ "<"+this.name+" type=\""+this.type+"\">"; ! result= result + this.text; ! result= result+ "</"+this.name+">\n"; ! return result; } } Index: XmlLink.java =================================================================== RCS file: /cvsroot/ejtools/libraries/xmlweb/src/main/net/sourceforge/ejtools/xml/XmlLink.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlLink.java 20 Apr 2002 11:42:51 -0000 1.1 --- XmlLink.java 25 Apr 2002 20:15:25 -0000 1.2 *************** *** 69,79 **** * @exception Exception Description of Exception */ ! public Element printXml(Document document) throws Exception { ! Element element = super.printXml(document); ! element.setAttribute("target", this.target); ! return element; } } --- 69,81 ---- * @exception Exception Description of Exception */ ! public String toXml() { ! String result = ""; ! result= result+ "<"+this.name+" target=\""+this.target +"\">"; ! result= result + this.text; ! result= result+ "</"+this.name+">\n"; ! return result; } } Index: XmlPrintable.java =================================================================== RCS file: /cvsroot/ejtools/libraries/xmlweb/src/main/net/sourceforge/ejtools/xml/XmlPrintable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlPrintable.java 20 Apr 2002 11:42:51 -0000 1.1 --- XmlPrintable.java 25 Apr 2002 20:15:25 -0000 1.2 *************** *** 25,38 **** * @exception Exception Description of Exception */ ! public Element printXml(Document document) throws Exception; ! ! ! /** ! * Description of the Method ! * ! * @param document Description of Parameter ! * @exception Exception Description of Exception ! */ ! public void appendTo(Document document) throws Exception; } --- 25,29 ---- * @exception Exception Description of Exception */ ! public String toXml(); } Index: XmlText.java =================================================================== RCS file: /cvsroot/ejtools/libraries/xmlweb/src/main/net/sourceforge/ejtools/xml/XmlText.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlText.java 20 Apr 2002 11:42:51 -0000 1.1 --- XmlText.java 25 Apr 2002 20:15:25 -0000 1.2 *************** *** 80,91 **** * @exception Exception Description of Exception */ ! public Element printXml(Document document) throws Exception { ! Element element = super.printXml(document); ! element.appendChild(document.createTextNode(this.text)); ! return element; } } - --- 80,92 ---- * @exception Exception Description of Exception */ ! public String toXml() { ! String result = ""; ! result= result+ "<"+this.name+">"; ! result= result + this.text; ! result= result+ "</"+this.name+">\n"; ! return result; } } Index: XmlTreeNode.java =================================================================== RCS file: /cvsroot/ejtools/libraries/xmlweb/src/main/net/sourceforge/ejtools/xml/XmlTreeNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlTreeNode.java 20 Apr 2002 11:42:51 -0000 1.1 --- XmlTreeNode.java 25 Apr 2002 20:15:25 -0000 1.2 *************** *** 1,7 **** /* ! * EJTools, the Enterprise Java Tools * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; --- 1,7 ---- /* ! * EJTools, the Enterprise Java Tools * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; *************** *** 18,27 **** public class XmlTreeNode extends XmlContainer { - protected String smallIcon = null; - protected String bigIcon = null; /** Description of the Field */ ! protected Object userObject = null; /** Description of the Field */ protected XmlPrintable object = null; --- 18,29 ---- public class XmlTreeNode extends XmlContainer { /** Description of the Field */ ! protected String bigIcon = null; /** Description of the Field */ protected XmlPrintable object = null; + /** Description of the Field */ + protected String smallIcon = null; + /** Description of the Field */ + protected Object userObject = null; *************** *** 32,49 **** } - public Element printXml(Document document) throws Exception - { - Element element = super.printXml(document); - - if (smallIcon != null) { - element.setAttribute("small-icon", this.smallIcon); - } - if (bigIcon != null) { - element.setAttribute("big-icon", this.bigIcon); - } ! return element; } /** * Setter for the userObject attribute --- 34,49 ---- } ! /** ! * Getter for the userObject attribute ! * ! * @return The value of userObject attribute ! */ ! public Object getUserObject() ! { ! return userObject; } + /** * Setter for the userObject attribute *************** *** 79,89 **** /** ! * Getter for the userObject attribute * ! * @return The value of userObject attribute */ ! public Object getUserObject() { ! return userObject; } --- 79,89 ---- /** ! * Description of the Method * ! * @return Description of the Returned Value */ ! public String toString() { ! return "Xml TreeNode (userObject=" + userObject + ")"; } *************** *** 92,100 **** * Description of the Method * ! * @return Description of the Returned Value */ ! public String toString() { ! return "Xml TreeNode (userObject=" + userObject + ")"; } } --- 92,123 ---- * Description of the Method * ! * @return Description of the Return Value */ ! public String toXml() { ! String result = ""; ! ! result = result + "<" + this.name; ! if (smallIcon != null) ! { ! result = result + " small-icon=\"" + this.smallIcon + "\""; ! } ! if (bigIcon != null) ! { ! result = result + " big-icon=\"" + this.bigIcon + "\""; ! } ! result = result + " objref=\"" + this.userObject.getClass().getName() + "@" + this.userObject.hashCode() + "\""; ! result = result + ">\n"; ! ! // Append the children ! for (int i = 0; i < this.size(); i++) ! { ! XmlPrintable object = (XmlPrintable) this.elementAt(i); ! result = result + object.toXml(); ! } ! ! result = result + "</" + this.name + ">\n"; ! ! return result; } } |