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 import javax.xml.parsers.*;
00020
00021
00029 public final class DocumentBuilderSetting {
00030 private final String property;
00031 private final boolean value;
00032 private final DocumentBuilderSettingStrategy strategy;
00033
00034 public final static DocumentBuilderSetting coalescing =
00035 new DocumentBuilderSetting("coalescing",true,
00036 DocumentBuilderSettingStrategy.coalescing);
00037
00038 public final static DocumentBuilderSetting notCoalescing =
00039 new DocumentBuilderSetting("coalescing",false,
00040 DocumentBuilderSettingStrategy.coalescing);
00041
00042
00043 public final static DocumentBuilderSetting expandEntityReferences =
00044 new DocumentBuilderSetting("expandEntityReferences",true,
00045 DocumentBuilderSettingStrategy.expandEntityReferences);
00046
00047
00048 public final static DocumentBuilderSetting notExpandEntityReferences =
00049 new DocumentBuilderSetting("expandEntityReferences",false,
00050 DocumentBuilderSettingStrategy.expandEntityReferences);
00051
00052 public final static DocumentBuilderSetting ignoringElementContentWhitespace =
00053 new DocumentBuilderSetting("ignoringElementContentWhitespace",true,
00054 DocumentBuilderSettingStrategy.ignoringElementContentWhitespace);
00055
00056
00057 public final static DocumentBuilderSetting notIgnoringElementContentWhitespace =
00058 new DocumentBuilderSetting("ignoringElementContentWhitespace",false,
00059 DocumentBuilderSettingStrategy.ignoringElementContentWhitespace);
00060
00061
00062 public final static DocumentBuilderSetting namespaceAware =
00063 new DocumentBuilderSetting("namespaceAware",true,
00064 DocumentBuilderSettingStrategy.namespaceAware);
00065
00066
00067 public final static DocumentBuilderSetting notNamespaceAware =
00068 new DocumentBuilderSetting("namespaceAware",false,
00069 DocumentBuilderSettingStrategy.namespaceAware);
00070
00071
00072
00073 public final static DocumentBuilderSetting validating =
00074 new DocumentBuilderSetting("validating",true,
00075 DocumentBuilderSettingStrategy.validating);
00076
00077 public final static DocumentBuilderSetting notValidating =
00078 new DocumentBuilderSetting("validating",false,
00079 DocumentBuilderSettingStrategy.validating);
00080
00081 public final static DocumentBuilderSetting signed =
00082 new DocumentBuilderSetting("signed",true,
00083 DocumentBuilderSettingStrategy.signed);
00084
00085
00086 public final static DocumentBuilderSetting notSigned =
00087 new DocumentBuilderSetting("signed",false,
00088 DocumentBuilderSettingStrategy.signed);
00089
00090 public final static DocumentBuilderSetting hasNullString =
00091 new DocumentBuilderSetting("hasNullString",true,
00092 DocumentBuilderSettingStrategy.hasNullString);
00093
00094
00095 public final static DocumentBuilderSetting notHasNullString =
00096 new DocumentBuilderSetting("hasNullString",false,
00097 DocumentBuilderSettingStrategy.hasNullString);
00098
00102 protected DocumentBuilderSetting(String property,
00103 boolean value, DocumentBuilderSettingStrategy strategy) {
00104 if(property == null) {
00105 throw new NullPointerException("property");
00106 }
00107 this.property = property;
00108 this.value = value;
00109 this.strategy = strategy;
00110 }
00111
00116 public final boolean hasConflict(DocumentBuilderSetting other) {
00117 if(other == null) {
00118 throw new NullPointerException("other");
00119 }
00120 if(other == this) {
00121 return true;
00122 }
00123 return strategy == other.strategy;
00124 }
00125
00126 public final boolean hasSetting(DOMTestDocumentBuilderFactory factory) {
00127 return strategy.hasSetting(factory) == value;
00128 }
00129
00130 public final void applySetting(DocumentBuilderFactory builder)
00131 throws DOMTestIncompatibleException {
00132 strategy.applySetting(builder,value);
00133 }
00134
00135 public final String toString() {
00136 StringBuffer builder = new StringBuffer(property);
00137 builder.append('=');
00138 builder.append(String.valueOf(value));
00139 return builder.toString();
00140 }
00141
00142
00143
00144 }