Create a new {@link DocumentBuilderFactory} using the defaults defined in
this class ({@link #DEFAULT_DOM_NAMESPACE_AWARE},
{@link #DEFAULT_DOM_VALIDATING} etc.).

@return Never <code>null</code>.
4793
@Nonnull
  public static DocumentBuilderFactory createDefaultDocumentBuilderFactory ()
  {
    final DocumentBuilderFactory aDocumentBuilderFactory = DocumentBuilderFactory.newInstance ();
    aDocumentBuilderFactory.setNamespaceAware (DEFAULT_DOM_NAMESPACE_AWARE);
    aDocumentBuilderFactory.setValidating (DEFAULT_DOM_VALIDATING);
    aDocumentBuilderFactory.setIgnoringElementContentWhitespace (DEFAULT_DOM_IGNORING_ELEMENT_CONTENT_WHITESPACE);
    aDocumentBuilderFactory.setExpandEntityReferences (DEFAULT_DOM_EXPAND_ENTITY_REFERENCES);
    aDocumentBuilderFactory.setIgnoringComments (DEFAULT_DOM_IGNORING_COMMENTS);
    aDocumentBuilderFactory.setCoalescing (DEFAULT_DOM_COALESCING);
    try
    {
      // Set secure processing to be the default. This is anyway the default in
      // JDK8
      aDocumentBuilderFactory.setFeature (EXMLParserFeature.SECURE_PROCESSING.getName (), true);
    }
    catch (final ParserConfigurationException ex1)
    {
      // Ignore
    }
    try
    {
      aDocumentBuilderFactory.setXIncludeAware (DEFAULT_DOM_XINCLUDE_AWARE);
    }
    catch (final UnsupportedOperationException ex)
    {
      // Ignore
    }
    return aDocumentBuilderFactory;
  }
566605
public static DefaultConstraintsCatalog newBundle() {
        DefaultConstraintsCatalog c = new DefaultConstraintsCatalog();
        c.add(new AmongBuilder());
        c.add(new BanBuilder());
        c.add(new ResourceCapacityBuilder());
        c.add(new RunningCapacityBuilder());
        c.add(new FenceBuilder());
        c.add(new GatherBuilder());
        c.add(new KilledBuilder());
        c.add(new LonelyBuilder());
        c.add(new OfflineBuilder());
        c.add(new OnlineBuilder());
        c.add(new OverbookBuilder());
        c.add(new PreserveBuilder());
        c.add(new QuarantineBuilder());
        c.add(new ReadyBuilder());
        c.add(new RootBuilder());
        c.add(new RunningBuilder());
        c.add(new SleepingBuilder());
        c.add(new SplitBuilder());
        c.add(new SplitAmongBuilder());
        c.add(new SpreadBuilder());
        c.add(new SeqBuilder());
        c.add(new MaxOnlineBuilder());
        c.add(new NoDelayBuilder());
        c.add(new BeforeBuilder());
        c.add(new SerializeBuilder());
        c.add(new SyncBuilder());
        return c;
    }
973861
private DocumentBuilder getDocumentBuilderFromPool()
            throws ParserConfigurationException {
        DocumentBuilder builder = documentBuilderPool.pollFirst();
        if (builder == null){
            builder = getDomFactory().newDocumentBuilder();
        }
        builder.setErrorHandler(errorHandler);
        return builder;
    }
11252
@Nonnull
  public static DocumentBuilderFactory createDocumentBuilderFactory (@Nonnull final Schema aSchema)
  {
    ValueEnforcer.notNull (aSchema, "Schema");

    final DocumentBuilderFactory aDocumentBuilderFactory = createDefaultDocumentBuilderFactory ();
    aDocumentBuilderFactory.setSchema (aSchema);
    return aDocumentBuilderFactory;
  }
301454
public static DocumentBuilderFactory newInstance(String factoryClassName,
            ClassLoader classLoader) {
        if (factoryClassName == null) {
            throw new FactoryConfigurationError("factoryClassName == null");
        }
        if (classLoader == null) {
            classLoader = Thread.currentThread().getContextClassLoader();
        }
        try {
            Class<?> type = classLoader != null
                    ? classLoader.loadClass(factoryClassName)
                    : Class.forName(factoryClassName);
            return (DocumentBuilderFactory) type.newInstance();
        } catch (ClassNotFoundException e) {
            throw new FactoryConfigurationError(e);
        } catch (InstantiationException e) {
            throw new FactoryConfigurationError(e);
        } catch (IllegalAccessException e) {
            throw new FactoryConfigurationError(e);
        }
    }
1305684
public ProtoNetwork buildProtoNetwork() {
        ProtoNetwork pn = new ProtoNetwork();

        // handle document header
        DocumentTable dt = pn.getDocumentTable();
        dt.addDocumentHeader(new DocumentHeader(doc.getHeader()));

        // handle namespaces
        NamespaceGroup nsg = doc.getNamespaceGroup();
        if (nsg != null) {
            NamespaceTable nt = pn.getNamespaceTable();

            if (nsg.getDefaultResourceLocation() != null) {
                org.openbel.framework.common.model.Namespace dns =
                        new Namespace("", nsg.getDefaultResourceLocation());
                nt.addNamespace(new TableNamespace(dns), 0);
            }

            // associate namespaces to document id 0
            final List<Namespace> nsl = nsg.getNamespaces();
            if (hasItems(nsl)) {
                for (org.openbel.framework.common.model.Namespace ns : nsl) {
                    nt.addNamespace(new TableNamespace(ns), 0);
                }
            }
        }

        // handle annotation definitions
        if (hasItems(doc.getDefinitions())) {
            for (AnnotationDefinition ad : doc.getDefinitions()) {
                AnnotationDefinitionTable adt =
                        pn.getAnnotationDefinitionTable();
                adt.addAnnotationDefinition(new TableAnnotationDefinition(ad),
                        0);
            }
        }

        // handle statement groups
        for (StatementGroup statementGroup : doc.getStatementGroups()) {
            buildProtoNetwork(pn, statementGroup,
                    new HashMap<String, Annotation>());
        }

        // create proto nodes
        final TermTable tt = pn.getTermTable();
        final ProtoNodeTable pnt = pn.getProtoNodeTable();
        final List<String> labels = tt.getTermValues();
        for (int i = 0, n = labels.size(); i < n; i++) {
            pnt.addNode(i, labels.get(i));
        }

        // create proto edges, process only simple edges now
        final Map<Integer, Integer> termNodeMap = pnt.getTermNodeIndex();
        final StatementTable st = pn.getStatementTable();
        final ProtoEdgeTable pet = pn.getProtoEdgeTable();
        final List<TableStatement> stmts = st.getStatements();
        for (int i = 0, n = stmts.size(); i < n; i++) {
            final TableStatement ts = stmts.get(i);
            final int subjectTerm = ts.getSubjectTermId();
            if (ts.getObjectTermId() != null) {
                final int objectTerm = ts.getObjectTermId();

                // find proto node index for subject / object terms
                final int source = termNodeMap.get(subjectTerm);
                final int target = termNodeMap.get(objectTerm);

                // create proto edge and add to table
                pet.addEdges(i, new ProtoEdgeTable.TableProtoEdge(source, ts
                        .getRelationshipName(), target));
            }
        }

        return pn;
    }
323546
public static DocumentBuilder newDocumentBuilder(final DocumentBuilderFactory factory)
   {
      try
      {
         final DocumentBuilder builder = factory.newDocumentBuilder();
         return builder;
      }
      catch (Exception e)
      {
         throw MESSAGES.unableToCreateInstanceOf(e, DocumentBuilder.class.getName());
      }
   }
1071144
@Nonnull
  public static XPath createNewXPath ()
  {
    return createNewXPath (s_aXPathFactory,
                           (XPathVariableResolver) null,
                           (XPathFunctionResolver) null,
                           (NamespaceContext) null);
  }
472420
public PojoBuilder withCompleteConstructor() {
		pojoCreationCheck();

		// first we need to check if there are any fields to add to constructor
		// because default constructor (without fields) is already present
		Map<String, JFieldVar> nonTransientAndNonStaticFields = getNonTransientAndNonStaticFields();

		// if nonTransientAndNonStaticFields is not empty
		if (!Optional.ofNullable(nonTransientAndNonStaticFields).map(Map::isEmpty).orElse(true)) {
			// Create complete constructor
			JMethod constructor = this.pojo.constructor(JMod.PUBLIC);
			Map<String, JVar> superParametersToAdd = getSuperParametersToAdd(this.pojo);
			addSuperConstructorInvocation(constructor, superParametersToAdd);
			constructor.javadoc().add("Creates a new " + this.pojo.name() + ".");

			Iterator<Map.Entry<String, JFieldVar>> iterator = nonTransientAndNonStaticFields.entrySet().iterator();

			while (iterator.hasNext()) {
				Map.Entry<String, JFieldVar> pair = iterator.next();

				constructor.param(pair.getValue().type(), pair.getKey());
				constructor.body().assign(JExpr._this().ref(pair.getKey()), JExpr.ref(pair.getKey()));
			}
		}

		return this;
	}
828567
protected XContentBuilder newBuilder() throws IndexException {
    try {
      XContentBuilder builder = XContentFactory.jsonBuilder();

      if (debug()) {
        builder = builder.prettyPrint();
      }

      return builder;
    } catch (final Throwable t) {
      throw new IndexException(t);
    }
  }
454359
public static synchronized Document getDefaultDocument()
    {
        if (defaultDocument == null)
        {
            DocumentBuilderFactory documentBuilderFactory = 
                DocumentBuilderFactory.newInstance();
            DocumentBuilder documentBuilder = null;
            try
            {
                documentBuilder = documentBuilderFactory.newDocumentBuilder();
            }
            catch (ParserConfigurationException e)
            {
                // Can not happen, since it's the default configuration
                throw new XmlException("Could not create default document", e);
            }
            defaultDocument = documentBuilder.newDocument();
        }
        return defaultDocument;
    }
869756
private static DocumentBuilderFactory constructDocumentBuilderFactory() {

        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();

        documentBuilderFactory.setValidating(true);
        documentBuilderFactory.setNamespaceAware(true);

        try {
            documentBuilderFactory.setAttribute("http://apache.org/xml/features/validation/schema", true);
        } catch (IllegalArgumentException e) {
            // Ignore
        }
        documentBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                "http://www.w3.org/2001/XMLSchema");
        documentBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
                "classpath:/jadira-bindings.xsd");
        return documentBuilderFactory;
    }
822988
public InputStream getBuilderXML() throws IOException {
        return builderXMLPath == null ?
            Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
            DocFile.createFileForInput(this, builderXMLPath).openInputStream();
    }
883209
public BType getBuilder() {
    if (builder == null) {
      // builder.mergeFrom() on a fresh builder
      // does not create any sub-objects with independent clean/dirty states,
      // therefore setting the builder itself to clean without actually calling
      // build() cannot break any invariants.
      builder = newBuilderForType(message.getDescriptorForType(), this);
      builder.mergeFrom(message); // no-op if message is the default message
      markClean(builder);
    }
    return builder;
  }
1126321
public static DocumentBuilder getXmlParser() {
    DocumentBuilder db = null;
    try {
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setValidating(false);

      //Disable DTD loading and validation
      //See http://stackoverflow.com/questions/155101/make-documentbuilder-parse-ignore-dtd-references
      dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
      dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

      db = dbf.newDocumentBuilder();
      db.setErrorHandler(new SAXErrorHandler());

    } catch (ParserConfigurationException e) {
      System.err.printf("%s: Unable to create XML parser\n", XMLUtils.class.getName());
      e.printStackTrace();

    } catch(UnsupportedOperationException e) {
      System.err.printf("%s: API error while setting up XML parser. Check your JAXP version\n", XMLUtils.class.getName());
      e.printStackTrace();
    }

    return db;
  }
1113844
private Object createDefaultResource(String className, ResourceInfo resourceRefInfo) throws Exception {
        if (className != null) {
            String javaCompDefaultFilter = "(" + com.ibm.ws.resource.ResourceFactory.JAVA_COMP_DEFAULT_NAME + "=*)";
            String createsFilter = FilterUtils.createPropertyFilter(ResourceFactory.CREATES_OBJECT_CLASS, className);
            String filter = "(&" + javaCompDefaultFilter + createsFilter + ")";
            return createResourceWithFilter(filter, resourceRefInfo);
        }
        return null;
    }
410327
@CheckReturnValue
  public static <ReqT, RespT> Builder<ReqT, RespT> newBuilder() {
    return newBuilder(null, null);
  }