001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021package org.biojavax.bio.phylo.io.nexus;
022
023import java.util.List;
024
025import org.biojava.bio.seq.io.ParseException;
026
027/**
028 * Builds Nexus characters blocks.
029 * 
030 * @author Richard Holland
031 * @author Tobias Thierer
032 * @author Jim Balhoff
033 * @since 1.6
034 */
035public class CharactersBlockBuilder extends NexusBlockBuilder.Abstract
036                implements CharactersBlockListener {
037
038        private CharactersBlock block;
039
040        protected void addComment(final NexusComment comment) {
041                this.block.addComment(comment);
042        }
043        
044        protected CharactersBlock makeNewBlock() {
045                return new CharactersBlock();
046        }
047
048        protected NexusBlock startBlockObject() {
049                this.block = this.makeNewBlock();
050                this.resetStatus();
051                return this.block;
052        }
053
054        /**
055         * Allowed to be called by DATA subclass.
056         */
057        protected void resetStatus() {
058                // Nothing to do.
059        }
060
061        public void endBlock() {
062                // Don't care.
063        }
064
065        public void endTokenGroup() {
066                // Nothing to do.
067        }
068
069        public void addCharLabel(String charLabel) {
070                this.block.addCharLabel(charLabel);
071        }
072
073        public void addCharState(String charState) {
074                this.block.addCharState(charState);
075        }
076
077        public void addCharStateKeyword(String charState, String keyword) {
078                this.block.addCharStateKeyword(charState, keyword);
079        }
080
081        public void addEquate(String symbol, List symbols) {
082                this.block.addEquate(symbol, symbols);
083        }
084
085        public void addItem(String item) {
086                this.block.addItem(item);
087        }
088
089        public void addMatrixEntry(String taxa) {
090                this.block.addMatrixEntry(taxa);
091        }
092
093        public void addState(String state) {
094                this.block.addState(state);
095        }
096
097        public void addStateLabel(String state, String label) {
098                this.block.addStateLabel(state, label);
099        }
100
101        public void addSymbol(String symbol) {
102                this.block.addSymbol(symbol);
103        }
104
105        public void addTaxLabel(String taxLabel) throws ParseException {
106                this.block.addTaxLabel(taxLabel);
107        }
108
109        public void appendMatrixData(String taxa, Object data) {
110                this.block.appendMatrixData(taxa, data);
111        }
112
113        public void setCharStateLabel(String charState, String label) {
114                this.block.setCharStateLabel(charState, label);
115        }
116
117        public void setDataType(String dataType) {
118                this.block.setDataType(dataType);
119        }
120
121        public void setDimensionsNChar(int dimensionsNChar) {
122                this.block.setDimensionsNChar(dimensionsNChar);
123        }
124
125        public void setDimensionsNTax(int dimensionsNTax) {
126                this.block.setDimensionsNTax(dimensionsNTax);
127        }
128
129        public void setEliminateEnd(int eliminateEnd) {
130                this.block.setEliminateEnd(eliminateEnd);
131        }
132
133        public void setEliminateStart(int eliminateStart) {
134                this.block.setEliminateStart(eliminateStart);
135        }
136
137        public void setGap(String gap) {
138                this.block.setGap(gap);
139        }
140
141        public void setInterleaved(boolean interleaved) {
142                this.block.setInterleaved(interleaved);
143        }
144
145        public void setLabels(boolean labels) {
146                this.block.setLabels(labels);
147        }
148
149        public void setMatchChar(String matchChar) {
150                this.block.setMatchChar(matchChar);
151        }
152
153        public void setMissing(String missing) {
154                this.block.setMissing(missing);
155        }
156
157        public void setRespectCase(boolean respectCase) {
158                this.block.setRespectCase(respectCase);
159        }
160
161        public void setStatesFormat(String statesFormat) {
162                this.block.setStatesFormat(statesFormat);
163        }
164
165        public void setTokens(boolean tokens) {
166                this.block.setTokens(tokens);
167        }
168
169        public void setTransposed(boolean transposed) {
170                this.block.setTransposed(transposed);
171        }
172
173}