Java XML DocumentBuilder Create getDocumentBuilderFactory()

Here you can find the source of getDocumentBuilderFactory()

Description

Gets the document builder factory, creating it if necessary.

License

Open Source License

Return

the document builder factory.

Declaration

public static synchronized DocumentBuilderFactory getDocumentBuilderFactory() 

Method Source Code

//package com.java2s;

import javax.xml.parsers.DocumentBuilderFactory;

public class Main {
    /** Reusable document builder factory. */
    private static DocumentBuilderFactory documentBuilderFactory;

    /**//from  ww w .j av a 2s .  co m
     * Gets the document builder factory, creating it if necessary.
     * 
     * @return the document builder factory.
     */
    public static synchronized DocumentBuilderFactory getDocumentBuilderFactory() {
        if (documentBuilderFactory == null) {
            documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            documentBuilderFactory.setExpandEntityReferences(false);
        }
        return documentBuilderFactory;
    }
}

Related

  1. getDocumentBuilder(boolean secure)
  2. getDocumentBuilderFactory()
  3. getDocumentBuilderFactory()
  4. getDocumentBuilderFactory()
  5. getDocumentBuilderFactory()
  6. getDocumentBuilderFactory(boolean isNamespaceAware)
  7. getDocumentBuilderFactory(String schema)
  8. getDocumentBuilderFactoryClassName()
  9. getNewDocumentBuilder()