package org.jdom.input; import org.jdom.*; import java.util.Map; /** The default JDOM factory. all metods servs new created objects of the class named by the medots using the constructor with parameters matching the metotds parameters. */ public class DefaultJDOMFactory implements JDOMFactory { public DefaultJDOMFactory() { } // **** constructing Attributes **** /** *

* This will create a new Attribute with the * specified (local) name and value, and in the provided * {@link Namespace}. *

* * @param name String name of Attribute. * @param value String value for new attribute. */ public Attribute attribute(String name, String value, Namespace namespace) { return new Attribute(name, value, namespace); } /** *

* This will create a new Attribute with the * specified (local) name and value, and place it in * the specified namespace (with prefix). *

* * @param name String name of Attribute. * @param prefix String prefix for Attribute. * @param uri String URI for namespace this * Attribute is in. * @param value String value for new attribute. */ public Attribute attribute(String name, String prefix, String uri, String value){ return new Attribute(name, prefix, uri, value); } /** *

* This will create a new Attribute with the * specified (local) name and value, and does not place * the attribute in a {@link Namespace}. *

* Note: This actually explicitly puts the * Attribute in the "empty" Namespace * ({@link Namespace#NO_NAMESPACE}). *

* * @param name String name of Attribute. * @param value String value for new attribute. */ public Attribute attribute(String name, String value){ return new Attribute(name, value); } // **** constructing CDATA **** /** *

* This creates the CDATA with the supplied * text. *

* * @param text String content of CDATA. */ public CDATA cdata(String text){ return new CDATA(text); } // **** constructing Comment **** /** *

* This creates the comment with the supplied * text. *

* * @param text String content of comment. */ public Comment comment(String text){ return new Comment(text); } // **** constructing DocType /** *

* This will create the DocType with * the specified element name and a reference to an * external DTD. *

* * @param elementName String name of * element being constrained. * @param publicID String public ID of * referenced DTD * @param systemID String system ID of * referenced DTD */ public DocType docType(String elementName, String publicID, String systemID){ return new DocType(elementName, publicID, systemID); } /** *

* This will create the DocType with * the specified element name and reference to an * external DTD. *

* * @param elementName String name of * element being constrained. * @param systemID String system ID of * referenced DTD */ public DocType docType(String elementName, String systemID){ return new DocType(elementName,systemID); } /** *

* This will create the DocType with * the specified element name *

* * @param elementName String name of * element being constrained. */ public DocType docType(String elementName){ return new DocType(elementName); } // **** constructing Document /** *

* This will create a new Document, * with the supplied {@link Element} * as the root element and the supplied * {@link DocType} declaration. *

* * @param rootElement Element for document root. * @param docType DocType declaration. */ public Document document(Element rootElement, DocType docType){ return new Document(rootElement,docType); } /** *

* This will create a new Document, * with the supplied {@link Element} * as the root element, and no {@link DocType} * declaration. *

* * @param rootElement Element for document root */ public Document document(Element rootElement){ return new Document(rootElement); } // **** constructing Entity /** *

* This will create a new Entity * with the supplied name. *

* * @param name String name of element. */ public Entity entity(String name){ return new Entity(name); } // **** constructing Elements **** /** *

* This will create a new Element * with the supplied (local) name, and define * the {@link Namespace} to be used. *

* * @param name String name of element. * @namespace Namespace to put element in. */ public Element element(String name, Namespace namespace){ return new Element(name,namespace); } /** *

* This will create an Element in no * {@link Namespace}. *

* * @param name String name of element. */ public Element element(String name){ return new Element(name); } /** *

* This will create a new Element with * the supplied (local) name, and specifies the URI * of the {@link Namespace} the Element * should be in, resulting it being unprefixed (in the default * namespace). *

* * @param name String name of element. * @param uri String URI for Namespace element * should be in. */ public Element element(String name, String uri){ return new Element(name,uri); } /** *

* This will create a new Element with * the supplied (local) name, and specifies the prefix and URI * of the {@link Namespace} the Element * should be in. *

* * @param name String name of element. * @param uri String URI for Namespace element * should be in. */ public Element element(String name, String prefix, String uri){ return new Element(name,prefix,uri); } // **** constructing ProProcessingInstruction **** /** *

* This will create a new ProcessingInstruction * with the specified target and data. *

* * @param target String target of PI. * @param data Map data for PI, in * name/value pairs */ public ProcessingInstruction processingInstruction(String target, Map data){ return new ProcessingInstruction(target,data); } /** *

* This will create a new ProcessingInstruction * with the specified target and data. *

* * @param target String target of PI. * @param rawData String data for PI. */ public ProcessingInstruction processingInstruction(String target, String data){ return new ProcessingInstruction(target,data); } }