FileDocCategorySizeDatePackage
DOMTestDocumentBuilderFactory.javaAPI DocAndroid 1.5 API6348Wed May 06 22:41:04 BST 2009org.w3c.domts

DOMTestDocumentBuilderFactory

public abstract class DOMTestDocumentBuilderFactory extends Object
This class represents a particular parser and configuration (such as entity-expanding, non-validating, whitespace ignoring) for a test session. Individual tests or suites within a session can override the session properties on a call to createBuilderFactory.
author
Curt Arnold

Fields Summary
private final DocumentBuilderSetting[]
settings
Parser configuration
Constructors Summary
public DOMTestDocumentBuilderFactory(DocumentBuilderSetting[] settings)
Constructor

param
properties Array of parser settings, may be null.

    if (settings == null) {
      this.settings = new DocumentBuilderSetting[0];
    }
    else {
      this.settings = (DocumentBuilderSetting[]) settings.clone();
    }
  
Methods Summary
public java.lang.StringaddExtension(java.lang.String testFileName)

    String contentType = getContentType();
    if ("text/html".equals(contentType)) {
      return testFileName + ".html";
    }
    if ("image/svg+xml".equals(contentType)) {
      return testFileName + ".svg";
    }
    if ("application/xhtml+xml".equals(contentType)) {
      return testFileName + ".xhtml";
    }
    return testFileName + ".xml";
  
public java.lang.ObjectcreateXPathEvaluator(org.w3c.dom.Document doc)
Creates XPath evaluator

param
doc DOM document, may not be null

    try {
      Method getFeatureMethod = doc.getClass().getMethod("getFeature",
          new Class[] {String.class, String.class});
      if (getFeatureMethod != null) {
        return getFeatureMethod.invoke(doc, new Object[] {"XPath", null});
      }
    }
    catch (Exception ex) {
    }
    return doc;
  
public final DocumentBuilderSetting[]getActualSettings()
Creates an array of all determinable settings for the DocumentBuilder including those at implementation defaults.

param
builder must not be null


    DocumentBuilderSetting[] allSettings = new DocumentBuilderSetting[] {
        DocumentBuilderSetting.coalescing,
        DocumentBuilderSetting.expandEntityReferences,
        DocumentBuilderSetting.hasNullString,
        DocumentBuilderSetting.ignoringElementContentWhitespace,
        DocumentBuilderSetting.namespaceAware,
        DocumentBuilderSetting.signed,
        DocumentBuilderSetting.validating,
        DocumentBuilderSetting.notCoalescing,
        DocumentBuilderSetting.notExpandEntityReferences,
        DocumentBuilderSetting.notHasNullString,
        DocumentBuilderSetting.notIgnoringElementContentWhitespace,
        DocumentBuilderSetting.notNamespaceAware,
        DocumentBuilderSetting.notSigned,
        DocumentBuilderSetting.notValidating
    };

    List list = new ArrayList(allSettings.length / 2);
    for (int i = 0; i < allSettings.length; i++) {
      if (allSettings[i].hasSetting(this)) {
        list.add(allSettings[i]);
      }
    }
    DocumentBuilderSetting[] settings = new DocumentBuilderSetting[list.size()];
    for (int i = 0; i < settings.length; i++) {
      settings[i] = (DocumentBuilderSetting) list.get(i);
    }
    return settings;
  
public java.lang.StringgetContentType()

    return System.getProperty("org.w3c.domts.contentType", "text/xml");
  
public abstract org.w3c.dom.DOMImplementationgetDOMImplementation()

public abstract booleanhasFeature(java.lang.String feature, java.lang.String version)

public abstract booleanisCoalescing()

public abstract booleanisExpandEntityReferences()

public abstract booleanisIgnoringElementContentWhitespace()

public abstract booleanisNamespaceAware()

public abstract booleanisValidating()

public abstract org.w3c.dom.Documentload(java.net.URL url)

protected DocumentBuilderSetting[]mergeSettings(DocumentBuilderSetting[] newSettings)
Merges the settings from the specific test case or suite with the existing (typically session) settings.

param
settings new settings, may be null which will return clone of existing settings.

    if (newSettings == null) {
      return (DocumentBuilderSetting[]) settings.clone();
    }
    List mergedSettings = new ArrayList(settings.length + newSettings.length);
    //
    //    all new settings are respected
    //
    for (int i = 0; i < newSettings.length; i++) {
      mergedSettings.add(newSettings[i]);
    }
    //
    //    for all previous settings, take only those that
    //       do not conflict with existing settings
    for (int i = 0; i < settings.length; i++) {
      DocumentBuilderSetting setting = settings[i];
      boolean hasConflict = false;
      for (int j = 0; j < newSettings.length; j++) {
        DocumentBuilderSetting newSetting = newSettings[j];
        if (newSetting.hasConflict(setting) || setting.hasConflict(newSetting)) {
          hasConflict = true;
          break;
        }
      }
      if (!hasConflict) {
        mergedSettings.add(setting);
      }
    }

    DocumentBuilderSetting[] mergedArray =
        new DocumentBuilderSetting[mergedSettings.size()];
    for (int i = 0; i < mergedSettings.size(); i++) {
      mergedArray[i] = (DocumentBuilderSetting) mergedSettings.get(i);
    }
    return mergedArray;
  
public abstract org.w3c.domts.DOMTestDocumentBuilderFactorynewInstance(DocumentBuilderSetting[] settings)
Returns an instance of DOMTestDocumentBuilderFactory with the settings from the argument list and any non-revoked settings from the current object.

param
settings array of settings, may be null.