00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 package org.w3c.domts;
00015 import java.lang.reflect.*;
00016 import javax.xml.parsers.*;
00017 import java.text.*;
00018 import java.util.*;
00019
00020
00029 public abstract class DocumentBuilderSettingStrategy {
00030 protected DocumentBuilderSettingStrategy() {}
00031
00032 public boolean hasConflict(DocumentBuilderSettingStrategy other) {
00033 return (other == this);
00034 }
00035
00036 public abstract void applySetting(DocumentBuilderFactory factory,boolean value)
00037 throws DOMTestIncompatibleException;
00038
00039 public abstract boolean hasSetting(DOMTestDocumentBuilderFactory factory);
00040
00041 public static final DocumentBuilderSettingStrategy coalescing =
00042 new DocumentBuilderSettingStrategy() {
00043 public void applySetting(DocumentBuilderFactory factory, boolean value)
00044 throws DOMTestIncompatibleException {
00045 factory.setCoalescing(value);
00046 }
00047 public boolean hasSetting(DOMTestDocumentBuilderFactory factory) {
00048 return factory.isCoalescing();
00049 }
00050
00051 };
00052
00053 public static final DocumentBuilderSettingStrategy expandEntityReferences =
00054 new DocumentBuilderSettingStrategy() {
00055 public void applySetting(DocumentBuilderFactory factory, boolean value)
00056 throws DOMTestIncompatibleException {
00057 factory.setExpandEntityReferences(value);
00058 }
00059 public boolean hasSetting(DOMTestDocumentBuilderFactory factory) {
00060 return factory.isExpandEntityReferences();
00061 }
00062 };
00063
00064 public static final DocumentBuilderSettingStrategy ignoringElementContentWhitespace =
00065 new DocumentBuilderSettingStrategy() {
00066 public void applySetting(DocumentBuilderFactory factory, boolean value)
00067 throws DOMTestIncompatibleException {
00068 factory.setIgnoringElementContentWhitespace(value);
00069 }
00070 public boolean hasSetting(DOMTestDocumentBuilderFactory factory) {
00071 return factory.isIgnoringElementContentWhitespace();
00072 }
00073 };
00074
00075
00076 public static final DocumentBuilderSettingStrategy namespaceAware =
00077 new DocumentBuilderSettingStrategy() {
00078 public void applySetting(DocumentBuilderFactory factory, boolean value)
00079 throws DOMTestIncompatibleException {
00080 factory.setNamespaceAware(value);
00081 }
00082 public boolean hasSetting(DOMTestDocumentBuilderFactory factory) {
00083 return factory.isNamespaceAware();
00084 }
00085 };
00086
00087
00088 public static final DocumentBuilderSettingStrategy validating =
00089 new DocumentBuilderSettingStrategy() {
00090 public void applySetting(DocumentBuilderFactory factory, boolean value)
00091 throws DOMTestIncompatibleException {
00092 factory.setValidating(value);
00093 }
00094 public boolean hasSetting(DOMTestDocumentBuilderFactory factory) {
00095 return factory.isValidating();
00096 }
00097 };
00098
00099
00100 public static final DocumentBuilderSettingStrategy signed =
00101 new DocumentBuilderSettingStrategy() {
00102 public void applySetting(DocumentBuilderFactory factory, boolean value)
00103 throws DOMTestIncompatibleException {
00104 if(!value) {
00105 throw new DOMTestIncompatibleException(null,DocumentBuilderSetting.notSigned);
00106 }
00107 }
00108 public boolean hasSetting(DOMTestDocumentBuilderFactory factory) {
00109 return true;
00110 }
00111 };
00112
00113 public static final DocumentBuilderSettingStrategy hasNullString =
00114 new DocumentBuilderSettingStrategy() {
00115 public void applySetting(DocumentBuilderFactory factory, boolean value)
00116 throws DOMTestIncompatibleException {
00117 if(!value) {
00118 throw new DOMTestIncompatibleException(null,DocumentBuilderSetting.notHasNullString);
00119 }
00120 }
00121 public boolean hasSetting(DOMTestDocumentBuilderFactory factory) {
00122 return true;
00123 }
00124 };
00125 }