Java XML DocumentBuilder Create getDocumentBuilder()

Here you can find the source of getDocumentBuilder()

Description

get Document Builder

License

LGPL

Declaration

public static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

public class Main {
    private static DocumentBuilderFactory documentBuilderFactory;
    private static DocumentBuilder documentBuilder;

    public static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
        if (documentBuilder == null) {
            documentBuilder = newDocumentBuilder();
        }/*from   w  w w  . j  av a 2s  .  co m*/
        return documentBuilder;
    }

    public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
        return getDocumentBuilderFactory().newDocumentBuilder();
    }

    public static DocumentBuilderFactory getDocumentBuilderFactory() {
        if (documentBuilderFactory == null) {
            documentBuilderFactory = DocumentBuilderFactory.newInstance();
        }
        return documentBuilderFactory;
    }
}

Related

  1. getDocumentBuilder()
  2. getDocumentBuilder()
  3. getDocumentBuilder()
  4. getDocumentBuilder()
  5. getDocumentBuilder()
  6. getDocumentBuilder()