[Ejtools-cvs] CVS: libraries/xmlweb/src/main/net/sourceforge/ejtools/xml XmlComponent.java,NONE,1.1
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-04-20 11:42:57
|
Update of /cvsroot/ejtools/libraries/xmlweb/src/main/net/sourceforge/ejtools/xml In directory usw-pr-cvs1:/tmp/cvs-serv28884 Added Files: XmlComponent.java XmlContainer.java XmlEditor.java XmlIconable.java XmlLink.java XmlPrintable.java XmlText.java XmlTreeNode.java Log Message: Initial Import --- NEW FILE: XmlComponent.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; import java.util.Vector; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Description of the Class * * @author letiembl * @created 26 février 2002 */ public class XmlComponent extends Vector implements XmlPrintable { /** Description of the Field */ protected String name = ""; /** Constructor for the XmlComponent object */ public XmlComponent() { this("component"); } /** * Constructor for the XmlText object * * @param name Description of Parameter */ public XmlComponent(String name) { this.name = name; } /** * Description of the Method * * @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; } /** * Description of the Method * * @return Description of the Returned Value */ public String toString() { return "Xml Component"; } } --- NEW FILE: XmlContainer.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Description of the Class * * @author letiembl * @created 26 février 2002 */ public class XmlContainer extends XmlComponent { /** Constructor for the XmlComponent object */ public XmlContainer() { super("container"); } /** * Constructor for the XmlText object * * @param name Description of Parameter */ public XmlContainer(String name) { super(name); } /** * 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); // Append the children for (int i = 0; i < this.size(); i++) { XmlPrintable object = (XmlPrintable) this.elementAt(i); element.appendChild(object.printXml(document)); } return element; } /** * Description of the Method * * @return Description of the Returned Value */ public String toString() { return "Xml Container"; } } --- NEW FILE: XmlEditor.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Description of the Class * * @author letiembl * @created 26 février 2002 */ public class XmlEditor extends XmlText { /** Description of the Field */ protected String type = ""; /** Constructor for the XmlText object */ public XmlEditor() { super("editor"); } /** * Setter for the target attribute * * @param type The new value */ public void setType(String type) { this.type = type; } /** * Getter for the target attribute * * @return The value of target attribute */ public String getType() { return type; } /** * Description of the Method * * @return Description of the Returned Value */ public String toString() { return "Xml Editor (text=" + text + ", type=" + type + ")"; } /** * 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 = super.printXml(document); element.setAttribute("type", this.type); return element; } } --- NEW FILE: XmlIconable.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; /** * Description of the Class * * @author letiembl * @created 26 février 2002 */ public interface XmlIconable { public String getSmallIcon(); public String getBigIcon(); } --- NEW FILE: XmlLink.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Description of the Class * * @author letiembl * @created 26 février 2002 */ public class XmlLink extends XmlText { /** Description of the Field */ protected String target = ""; /** Constructor for the XmlText object */ public XmlLink() { super("link"); } /** * Setter for the target attribute * * @param target The new value for target attribute */ public void setTarget(String target) { this.target = target; } /** * Getter for the target attribute * * @return The value of target attribute */ public String getTarget() { return target; } /** * Description of the Method * * @return Description of the Returned Value */ public String toString() { return "Xml Link (text=" + text + ", target=" + target + ")"; } /** * 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 = super.printXml(document); element.setAttribute("target", this.target); return element; } } --- NEW FILE: XmlPrintable.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Description of the Class * * @author letiembl * @created 26 février 2002 */ public interface XmlPrintable { /** * 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; /** * Description of the Method * * @param document Description of Parameter * @exception Exception Description of Exception */ public void appendTo(Document document) throws Exception; } --- NEW FILE: XmlText.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Description of the Class * * @author letiembl * @created 26 février 2002 */ public class XmlText extends XmlComponent { /** Description of the Field */ protected String text = ""; /** Constructor for the XmlText object */ public XmlText() { super("text"); } /** * Constructor for the XmlText object * * @param name Description of Parameter */ public XmlText(String name) { super(name); } /** * Setter for the text attribute * * @param text The new value for text attribute */ public void setText(String text) { this.text = "" + text; } /** * Getter for the text attribute * * @return The value of text attribute */ public String getText() { return text; } /** * Description of the Method * * @return Description of the Returned Value */ public String toString() { return "Xml Text (text=" + text + ")"; } /** * 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 = super.printXml(document); element.appendChild(document.createTextNode(this.text)); return element; } } --- NEW FILE: XmlTreeNode.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.xml; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Description of the Class * * @author letiembl * @created 26 février 2002 */ 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; /** Constructor for the XmlNode object */ public XmlTreeNode() { super("tree-node"); } 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 * * @param userObject The new value for userObject attribute */ public void setUserObject(Object userObject) { remove(this.object); this.userObject = userObject; if (XmlPrintable.class.isAssignableFrom(userObject.getClass())) { this.object = (XmlPrintable) userObject; } else { XmlText text = new XmlText(); text.setText(userObject.toString()); this.object = text; } if (XmlIconable.class.isAssignableFrom(userObject.getClass())) { this.smallIcon = ((XmlIconable) userObject).getSmallIcon(); this.bigIcon = ((XmlIconable) userObject).getBigIcon(); } add(this.object); } /** * Getter for the userObject attribute * * @return The value of userObject attribute */ public Object getUserObject() { return userObject; } /** * Description of the Method * * @return Description of the Returned Value */ public String toString() { return "Xml TreeNode (userObject=" + userObject + ")"; } } |