    1   /*
    2    * Copyright 1999-2004 The Apache Software Foundation
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *     http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  package org.apache.commons.jxpath.xml;
    17
    18  import java.io.InputStream;
    19
    20  /***
    21   * The abstract superclass of XML parsers that produce DOM Documents.
    22   * The features have the same defaults as DocumentBuilderFactory.
    23   *
    24   * @author Dmitri Plotnikov
    25   * @version $Revision: 1.3 $ $Date: 2004/02/29 14:17:37 $
    26   */
    27  public abstract class XMLParser2 implements XMLParser
    28  {
    29      private boolean validating = false;
    30      private boolean namespaceAware = true;
    31      private boolean whitespace = false;
    32      private boolean expandEntityRef = true;
    33      private boolean ignoreComments = false;
    34      private boolean coalescing = false;
    35
    36      /***
    37       * @see DocumentBuilderFactory#setValidating(boolean)
    38       */
    39      public void setValidating(boolean validating) {
    40          this.validating = validating;
    41      }
    42
    43      /***
    44       * @see DocumentBuilderFactory#isValidating()
    45       */
    46      public boolean isValidating() {
    47          return validating;
    48      }
    49
    50      /***
    51       * @see DocumentBuilderFactory#isNamespaceAware()
    52       */
    53      public boolean isNamespaceAware() {
    54          return namespaceAware;
    55      }
    56
    57      /***
    58       * @see DocumentBuilderFactory#setNamespaceAware(boolean)
    59       */
    60      public void setNamespaceAware(boolean namespaceAware) {
    61          this.namespaceAware = namespaceAware;
    62      }
    63
    64      /***
    65       * @see DocumentBuilderFactory#setIgnoringElementContentWhitespace(boolean)
    66       */
    67      public void setIgnoringElementContentWhitespace(boolean whitespace) {
    68          this.whitespace = whitespace;
    69      }
    70
    71      /***
    72       * @see DocumentBuilderFactory#isIgnoringElementContentWhitespace()
    73       */
    74      public boolean isIgnoringElementContentWhitespace() {
    75          return whitespace;
    76      }
    77
    78      /***
    79       * @see DocumentBuilderFactory#isExpandEntityReferences()
    80       */
    81      public boolean isExpandEntityReferences() {
    82          return expandEntityRef;
    83      }
    84
    85      /***
    86       * @see DocumentBuilderFactory#setExpandEntityReferences(boolean)
    87       */
    88      public void setExpandEntityReferences(boolean expandEntityRef) {
    89          this.expandEntityRef = expandEntityRef;
    90      }
    91
    92      /***
    93       * @see DocumentBuilderFactory#isIgnoringComments()
    94       */
    95      public boolean isIgnoringComments() {
    96          return ignoreComments;
    97      }
    98
    99      /***
    100      * @see DocumentBuilderFactory#setIgnoringComments(boolean)
    101      */
    102     public void setIgnoringComments(boolean ignoreComments) {
    103         this.ignoreComments = ignoreComments;
    104     }
    105
    106     /***
    107      * @see DocumentBuilderFactory#isCoalescing()
    108      */
    109     public boolean isCoalescing() {
    110         return coalescing;
    111     }
    112
    113     /***
    114      * @see DocumentBuilderFactory#setCoalescing(boolean)
    115      */
    116     public void setCoalescing(boolean coalescing) {
    117         this.coalescing = coalescing;
    118     }
    119
    120     public abstract Object parseXML(InputStream stream);
    121 }