/*
 * Copyright (c) 2007, Going Dot Com Inc. All rights reserved.
 */

package jp.co.going.xbrl.instance;

import java.sql.Connection;
import java.util.ArrayList;

import jp.co.going.xbrl.common.XbException;
import jp.co.going.xbrl.common.XbConstants;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 * @author Going Dot Com Inc.
 */
class XbFootNote extends XbContext {

    private Document doc;

    protected XbFootNote(Connection conn, Document doc) throws XbException {
        this.doc = doc;

        etcDAO = XbFootNoteDAO.getInstance(conn);
    }

    /**
     * FootNote情報を作成する
     * @param footNoteId contextID
     * @return footnoteTag
     * @throws XbException
     */
    protected void createFootNote(String taxGroupId, String footNoteId, Element rootInstance) throws XbException {

        // footnote(root)情報取得
        ArrayList<XbEtcObj> footNoteList = etcDAO.getFootNote(taxGroupId, footNoteId, "0");

        for (int i = 0;i < footNoteList.size();i ++) {
            XbEtcObj obj = footNoteList.get(i);
            // 再帰処理
            Element footNoteItem = super.createEtc(this.doc, taxGroupId, obj, XbConstants.TAG_LINK);
            // footNoteに設定
            super.appendChild(rootInstance, footNoteItem);
        }
    }
}