001package csv2html;
002
003import java.util.List;
004
005/**
006 * タプル:情報テーブルの中の各々のレコード。
007 */
008public class Tuple extends Object
009{
010        /**
011         * 属性リストを記憶するフィールド。
012         */
013        private Attributes attributes;
014
015        /**
016         * 値リストを記憶するフィールド。
017         */
018        private List<String> values;
019
020        /**
021         * 属性リストと値リストからタプルを作るコンストラクタ。
022         * @param instanceOfAttributes 属性リスト
023         * @param valueCollection 値リスト
024         */
025        public Tuple(Attributes instanceOfAttributes, List<String> valueCollection)
026        {
027                super();
028
029                this.attributes = instanceOfAttributes;
030                this.values = valueCollection;
031
032                return;
033        }
034
035        /**
036         * 属性リストを応答する。
037         * @return 属性リスト
038         */
039        public Attributes attributes()
040        {
041                return this.attributes;
042        }
043
044        /**
045         * 自分自身を文字列にして、それを応答する。
046         * @return 自分自身の文字列
047         */
048        public String toString()
049        {
050                StringBuffer aBuffer = new StringBuffer();
051                Class aClass = this.getClass();
052                aBuffer.append(aClass.getName());
053                aBuffer.append("[");
054                int index = 0;
055                for (String aString : this.values())
056                {
057                        if (index != 0) { aBuffer.append(","); }
058                        aBuffer.append(this.attributes().at(index));
059                        aBuffer.append("(" + aString + ")");
060                        index++;
061                }
062                aBuffer.append("]");
063
064                return aBuffer.toString();
065        }
066
067        /**
068         * 値リストを応答する。
069         * @return 値リスト
070         */
071        public List<String> values()
072        {
073                return this.values;
074        }
075}