[jdom-interest] Factories for builders.

Ken Rune Helland kenh at csc.no
Tue Mar 13 04:39:03 PST 2001


Here is an attemt to implement factories for builders.

I have kept it simple.

D:\JDOM\factorySAXBuilder.diff a diff for SAXBuilder based on
fridays source drop.

JDOMFactory.java is the java interface defining the factory.
DefaultJDOMFactory.java is the default implementtation used by
saxbuilder when nothing is set with the SAXBuilder.setFactory
metod.


Best Regards
KenR
  
-------------- next part --------------
2001-03-13 13:17 *jdom\src\java\org\jdom\input\SAXBuilder.java Page    1


131a132,134
> 		/** The factory for creating new JDOM objects */
> 		private JDOMFactory factory = new DefaultJDOMFactory();
> 
245a249,262
> 		 * This sets a custom JDOMFactory for the <code>Builder</code>.
> 		 * Use this to build the tree with you own subclasses of the
> 		 * JDOM classes.
> 		 * </p>
> 		 *
> 		 * @param factory <code>JDOMFactory</code>
> 		 */
> 		public void setFactory(JDOMFactory factory) {
> 				this.factory = factory;
> 		}
> 
> 
> 		/**
> 		 * <p>
257c274
<         Document doc = new Document((Element)null);
---
> 				Document doc = factory.document((Element)null);
329c346
<                 new SAXHandler(doc);
---
> 								new SAXHandler(doc,factory);
586a604,606
> 		/** The JDOMFactory used for JDOM object creation */
> 		private JDOMFactory factory;
> 
589c609,610
<      * This will set the <code>Document</code> to use.
---
> 		 * This will set the <code>Document</code> to use
> 		 * and the factory for JDOM object creations
592a614
> 		 * @param factory a <code>JDOMFactory</code> implementation
595c617
<     public SAXHandler(Document document) throws IOException {
---
> 		public SAXHandler(Document document,JDOMFactory factory) throws IOException {
604a627
> 				this.factory = factory;
623c646
<             document.addContent(new ProcessingInstruction(target, data));
---
> 						document.addContent(factory.processingInstruction(target, data));
626c649
<                 new ProcessingInstruction(target, data));
---
> 								factory.processingInstruction(target, data));
707c730
<             element = new Element(localName, elementNamespace);
---
> 						element = factory.element(localName, elementNamespace);
715c738
<             element = new Element(localName);
---
> 						element = factory.element(localName);
731c754
<                 attribute = new Attribute(attLocalName, atts.getValue(i),
---
2001-03-13 13:17 *jdom\src\java\org\jdom\input\SAXBuilder.java Page    2


> 								attribute = factory.attribute(attLocalName, atts.getValue(i),
734c757
<                 attribute = new Attribute(attLocalName, atts.getValue(i));
---
> 								attribute = factory.attribute(attLocalName, atts.getValue(i));
787c810
<             ((Element)stack.peek()).addContent(new CDATA(data));
---
> 						((Element)stack.peek()).addContent(factory.cdata(data));
851c874
<             new DocType(name, publicId, systemId));
---
> 						factory.docType(name, publicId, systemId));
875c898
<             Entity entity = new Entity(name);
---
> 						Entity entity = factory.entity(name);
926c949
<                    new Comment(commentText));
---
> 									 factory.comment(commentText));
929c952
<                     new Comment(commentText));
---
> 										factory.comment(commentText));

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DefaultJDOMFactory.java
Type: application/octet-stream
Size: 7511 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010313/6a69f9a3/DefaultJDOMFactory.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JDOMFactory.java
Type: application/octet-stream
Size: 6665 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010313/6a69f9a3/JDOMFactory.obj


More information about the jdom-interest mailing list