[jdom-interest] Internal DTD subset verification

Bradley S. Huffman hip at a.cs.okstate.edu
Wed May 1 12:03:14 PDT 2002


Throw this in your copy ./src/java/org/jdom dir and run some tests. I found
it helps a little but nothing earth shattering.

Brad

/*--

 $Id: FastFactory.java,v 1.6 2002/03/12 07:57:06 jhunter Exp $

 Copyright (C) 2000 Brett McLaughlin & Jason Hunter.
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:

 1. Redistributions of source code must retain the above copyright
    notice, this list of conditions, and the following disclaimer.

 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions, and the disclaimer that follows
    these conditions in the documentation and/or other materials
    provided with the distribution.

 3. The name "JDOM" must not be used to endorse or promote products
    derived from this software without prior written permission.  For
    written permission, please contact license at jdom.org.

 4. Products derived from this software may not be called "JDOM", nor
    may "JDOM" appear in their name, without prior written permission
    from the JDOM Project Management (pm at jdom.org).

 In addition, we request (but do not require) that you include in the
 end-user documentation provided with the redistribution and/or in the
 software itself an acknowledgement equivalent to the following:
     "This product includes software developed by the
      JDOM Project (http://www.jdom.org/)."
 Alternatively, the acknowledgment may be graphical using the logos
 available at http://www.jdom.org/images/logos.

 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED.  IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.

 This software consists of voluntary contributions made by many
 individuals on behalf of the JDOM Project and was originally
 created by Brett McLaughlin <brett at jdom.org> and
 Jason Hunter <jhunter at jdom.org>.  For more information on the
 JDOM Project, please see <http://www.jdom.org/>.

 */

package org.jdom;

import java.util.*;

/**
 * <p>
 * <code>FastFactory</code> creates the standard top-level JDOM classes
 * (Element, Document, Comment, etc) as fast as possible with no validity
 * checks.
 * </p>
 *
 * @author Ken Rune Holland
 * @author Phil Nelson
 * @author Bradley S. Huffman
 * @version $Revision: 1.6 $, $Date: 2002/03/12 07:57:06 $
 */
public class FastFactory implements JDOMFactory {

    private static final String CVS_ID =
    "@(#) $RCSfile: FastFactory.java,v $ $Revision: 1.6 $ $Date: 2002/03/12 07:57:06 $ $Name: jdom_1_0_b8 $";

    public FastFactory() { }

    public Attribute attribute(String name, String value, int type,
                               Namespace namespace) {
        Attribute attribute = new Attribute();
        attribute.name = name;
        attribute.value = value;
        attribute.type = type;
        attribute.namespace = namespace;
        return attribute;
    }

    public Attribute attribute(String name, String value, Namespace namespace) {
        Attribute attribute = new Attribute();
        attribute.name = name;
        attribute.value = value;
        attribute.type = Attribute.UNDECLARED_ATTRIBUTE;
        attribute.namespace = namespace;
        return attribute;
    }

    public Attribute attribute(String name, String value) {
        Attribute attribute = new Attribute();
        attribute.name = name;
        attribute.value = value;
        attribute.type = Attribute.UNDECLARED_ATTRIBUTE;
        attribute.namespace = Namespace.NO_NAMESPACE;
        return attribute;
    }

    public Attribute attribute(String name, String value, int type) {
        Attribute attribute = new Attribute();
        attribute.name = name;
        attribute.value = value;
        attribute.type = type;
        attribute.namespace = Namespace.NO_NAMESPACE;
        return attribute;
    }

    public CDATA cdata(String value) {
        CDATA cdata = new CDATA();
        cdata.value = value;
        return cdata;
    }

    public Text text(String value) {
        Text text = new Text();
        text.value = value;
        return text;
    }


    public Comment comment(String value) {
        Comment comment = new Comment();
        comment.value = value;
        return comment;
    }

    public DocType docType(String elementName, 
                           String publicID, String systemID) {
        DocType docType = new DocType();
        docType.elementName = elementName; 
        docType.publicID = publicID;
        docType.systemID = systemID;
        return docType;
    }

    public DocType docType(String elementName, String systemID) {
        DocType docType = new DocType();
        docType.elementName = elementName; 
        docType.systemID = systemID;
        return docType;
    }

    public DocType docType(String elementName) {
        DocType docType = new DocType();
        docType.elementName = elementName; 
        return docType;
    }

    public Document document(Element rootElement, DocType docType) {
        Document document = new Document(rootElement);
        document.docType = docType; 
        return document;
    }

    public Document document(Element rootElement) {
        Document document = new Document(rootElement);
        return document;
    }

    public Element element(String name, Namespace namespace) {
        Element element = new Element();
        element.name = name; 
        element.namespace = namespace; 
        return element;
    }

    public Element element(String name) {
        Element element = new Element();
        element.name = name; 
        element.namespace = Namespace.NO_NAMESPACE;
        return element;
    }

    public Element element(String name, String uri) {
        Element element = new Element();
        element.name = name; 
        element.namespace = Namespace.getNamespace("", uri); 
        return element;
    }

    public Element element(String name, String prefix, String uri) {
        Element element = new Element();
        element.name = name; 
        element.namespace = Namespace.getNamespace(prefix, uri); 
        return element;
    }

    public ProcessingInstruction processingInstruction(String target, 
                                                       Map data) {
        ProcessingInstruction pi = new ProcessingInstruction();
        pi.target = target; 
        pi.mapData = data; 
        return pi;
    }

    public ProcessingInstruction processingInstruction(String target, 
                                                       String data) {
        ProcessingInstruction pi = new ProcessingInstruction();
        pi.target = target; 
        pi.rawData = data; 
        return pi;
    }

    public EntityRef entityRef(String name) {
        EntityRef entity = new EntityRef();
        entity.name = name; 
        return entity;
    }

    public EntityRef entityRef(String name, String publicID, String systemID) {
        EntityRef entity = new EntityRef();
        entity.name = name; 
        entity.publicID = publicID; 
        entity.systemID = systemID; 
        return entity;
    }
}



More information about the jdom-interest mailing list