001: /*
002: * $Id: DocumentBuilderFactory.java,v 1.7 2001/12/05 22:49:25 db Exp $
003: * Copyright (C) 2001 Andrew Selkirk
004: * Copyright (C) 2001 David Brownell
005: *
006: * This file is part of GNU JAXP, a library.
007: *
008: * GNU JAXP is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License as published by
010: * the Free Software Foundation; either version 2 of the License, or
011: * (at your option) any later version.
012: *
013: * GNU JAXP is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021: *
022: * As a special exception, if you link this library with other files to
023: * produce an executable, this library does not by itself cause the
024: * resulting executable to be covered by the GNU General Public License.
025: * This exception does not however invalidate any other reasons why the
026: * executable file might be covered by the GNU General Public License.
027: */
028:
029: package javax.xml.parsers;
030:
031: // Imports
032: import java.io.IOException;
033: import java.io.InputStream;
034: import java.io.File;
035: import java.io.BufferedReader;
036: import java.io.InputStreamReader;
037: import java.util.Properties;
038: import org.w3c.dom.*;
039: import org.xml.sax.*;
040:
041: /**
042: * DocumentBuilderFactory is used to resolve the problem that the
043: * W3C DOM APIs don't include portable bootstrapping.
044: *
045: * @author Andrew Selkirk, David Brownell
046: * @version $Id: DocumentBuilderFactory.java,v 1.7 2001/12/05 22:49:25 db Exp $
047: */
048: public abstract class DocumentBuilderFactory {
049:
050: //-------------------------------------------------------------
051: // Variables --------------------------------------------------
052: //-------------------------------------------------------------
053:
054: private static final String defaultPropName = "javax.xml.parsers.DocumentBuilderFactory";
055:
056: private boolean validating = false;
057: private boolean namespaceAware = false;
058: private boolean whitespace = false;
059: private boolean expandEntityRef = false;
060: private boolean ignoreComments = false;
061: private boolean coalescing = false;
062:
063: //-------------------------------------------------------------
064: // Initialization ---------------------------------------------
065: //-------------------------------------------------------------
066:
067: protected DocumentBuilderFactory() {
068: } // DocumentBuilderFactory()
069:
070: //-------------------------------------------------------------
071: // Methods ----------------------------------------------------
072: //-------------------------------------------------------------
073:
074: public abstract Object getAttribute(String name)
075: throws IllegalArgumentException;
076:
077: public boolean isCoalescing() {
078: return coalescing;
079: } // isCoalescing()
080:
081: public boolean isExpandEntityReferences() {
082: return expandEntityRef;
083: } // isExpandEntityReferences()
084:
085: public boolean isIgnoringComments() {
086: return ignoreComments;
087: } // isIgnoringComments()
088:
089: public boolean isIgnoringElementContentWhitespace() {
090: return whitespace;
091: } // isIgnoringElementContentWhitespace()
092:
093: public boolean isNamespaceAware() {
094: return namespaceAware;
095: } // isNamespaceAware()
096:
097: public boolean isValidating() {
098: return validating;
099: } // isValidating()
100:
101: public abstract DocumentBuilder newDocumentBuilder()
102: throws ParserConfigurationException;
103:
104: public static DocumentBuilderFactory newInstance() {
105: try {
106: return (DocumentBuilderFactory) ClassStuff.createFactory(
107: defaultPropName, "gnu.xml.dom.JAXPFactory");
108: } catch (ClassCastException e) {
109: throw new FactoryConfigurationError(e,
110: "Factory class is the wrong type");
111: }
112: }
113:
114: public abstract void setAttribute(String name, Object value)
115: throws IllegalArgumentException;
116:
117: public void setCoalescing(boolean value) {
118: coalescing = value;
119: } // setCoalescing()
120:
121: public void setExpandEntityReferences(boolean value) {
122: expandEntityRef = value;
123: } // setExpandEntityReferences()
124:
125: public void setIgnoringComments(boolean value) {
126: ignoreComments = value;
127: } // setIgnoringComments()
128:
129: public void setIgnoringElementContentWhitespace(boolean value) {
130: whitespace = value;
131: } // setIgnoringElementContentWhitespace()
132:
133: public void setNamespaceAware(boolean value) {
134: namespaceAware = value;
135: } // setNamespaceAware()
136:
137: public void setValidating(boolean value) {
138: validating = value;
139: } // setValidating()
140: }
|