⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmldocumentbuilder.java

📁 JGAP(发音"jay-gap")是一款用Java编写的遗传算法包。提供了基本的遗传算法.你可以使用它来解决一些适用于遗传算法解决的问题.
💻 JAVA
字号:
/*
 * This file is part of JGAP.
 *
 * JGAP offers a dual license model containing the LGPL as well as the MPL.
 *
 * For licencing information please see the file license.txt included with JGAP
 * or have a look at the top of class org.jgap.Chromosome which representatively
 * includes the JGAP license policy applicable for any file delivered with JGAP.
 */
package org.jgap.xml;

import org.jgap.data.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;

/**
 * Class building an XML file. Can be used to persist objects like Genotype,
 * Chromosome or Gene (or a list of them) to an XML file.
 *
 * @author Klaus Meffert
 * @since 2.0
 */
public class XMLDocumentBuilder
    extends DocumentBuilderBase {
  /** String containing the CVS revision. Read out via reflection!*/
  private final static String CVS_REVISION = "$Revision: 1.8 $";

  protected void setAttribute(final Object a_xmlElement, final String a_key,
                              final String a_value) {
    ( (Element) a_xmlElement).setAttribute(a_key, a_value);
  }

  protected Object documentAppendChild(final Object a_xmlDocument,
                                       final Object a_element) {
    return ( (Document) a_xmlDocument).appendChild( (Element) a_element);
  }

  protected Object elementAppendChild(final Object a_xmlElement,
                                      final Object a_element) {
    return ( (Element) a_xmlElement).appendChild( (Element) a_element);
  }

  protected Object createElement(final Object a_doc, final Object a_xmlElement,
                                 final String a_tagName) {
    return ( (Document) a_doc).createElement(a_tagName);
  }

  /**
   * Convenience method to build an XML document from a generic input structure
   * (of type IDataCreators)
   * @param a_document the input structure holding the data to be represented
   * as XML document
   * @throws Exception
   * @return Object the XML document
   *
   * @author Klaus Meffert
   * @since 2.0
   */
  public Object buildDocument(final IDataCreators a_document)
      throws Exception {
    DocumentBuilder m_documentCreator = DocumentBuilderFactory.newInstance().
        newDocumentBuilder();
    Document xmlDoc = m_documentCreator.newDocument();
    return super.buildDocument(a_document, xmlDoc);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -