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. import java.io.InputStream;
  18. /**
  19. * The abstract superclass of XML parsers that produce DOM Documents.
  20. * The features have the same defaults as DocumentBuilderFactory.
  21. *
  22. * @author Dmitri Plotnikov
  23. * @version $Revision: 1.3 $ $Date: 2004/02/29 14:17:37 $
  24. */
  25. public abstract class XMLParser2 implements XMLParser
  26. {
  27. private boolean validating = false;
  28. private boolean namespaceAware = true;
  29. private boolean whitespace = false;
  30. private boolean expandEntityRef = true;
  31. private boolean ignoreComments = false;
  32. private boolean coalescing = false;
  33. /**
  34. * @see DocumentBuilderFactory#setValidating(boolean)
  35. */
  36. public void setValidating(boolean validating) {
  37. this.validating = validating;
  38. }
  39. /**
  40. * @see DocumentBuilderFactory#isValidating()
  41. */
  42. public boolean isValidating() {
  43. return validating;
  44. }
  45. /**
  46. * @see DocumentBuilderFactory#isNamespaceAware()
  47. */
  48. public boolean isNamespaceAware() {
  49. return namespaceAware;
  50. }
  51. /**
  52. * @see DocumentBuilderFactory#setNamespaceAware(boolean)
  53. */
  54. public void setNamespaceAware(boolean namespaceAware) {
  55. this.namespaceAware = namespaceAware;
  56. }
  57. /**
  58. * @see DocumentBuilderFactory#setIgnoringElementContentWhitespace(boolean)
  59. */
  60. public void setIgnoringElementContentWhitespace(boolean whitespace) {
  61. this.whitespace = whitespace;
  62. }
  63. /**
  64. * @see DocumentBuilderFactory#isIgnoringElementContentWhitespace()
  65. */
  66. public boolean isIgnoringElementContentWhitespace() {
  67. return whitespace;
  68. }
  69. /**
  70. * @see DocumentBuilderFactory#isExpandEntityReferences()
  71. */
  72. public boolean isExpandEntityReferences() {
  73. return expandEntityRef;
  74. }
  75. /**
  76. * @see DocumentBuilderFactory#setExpandEntityReferences(boolean)
  77. */
  78. public void setExpandEntityReferences(boolean expandEntityRef) {
  79. this.expandEntityRef = expandEntityRef;
  80. }
  81. /**
  82. * @see DocumentBuilderFactory#isIgnoringComments()
  83. */
  84. public boolean isIgnoringComments() {
  85. return ignoreComments;
  86. }
  87. /**
  88. * @see DocumentBuilderFactory#setIgnoringComments(boolean)
  89. */
  90. public void setIgnoringComments(boolean ignoreComments) {
  91. this.ignoreComments = ignoreComments;
  92. }
  93. /**
  94. * @see DocumentBuilderFactory#isCoalescing()
  95. */
  96. public boolean isCoalescing() {
  97. return coalescing;
  98. }
  99. /**
  100. * @see DocumentBuilderFactory#setCoalescing(boolean)
  101. */
  102. public void setCoalescing(boolean coalescing) {
  103. this.coalescing = coalescing;
  104. }
  105. public abstract Object parseXML(InputStream stream);
  106. }