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 */
021
022package org.biojavax.bio.seq.io;
023
024import org.biojava.bio.seq.io.SequenceBuilder;
025import org.biojava.bio.symbol.SymbolListFactory;
026
027
028/**
029 * Generates RichSequenceBuilder objects.
030 * @author Mark Schreiber
031 * @author Richard Holland
032 * @see RichSequenceBuilder
033 * @since 1.5
034 */
035public class SimpleRichSequenceBuilderFactory implements RichSequenceBuilderFactory {
036    private SymbolListFactory fact = null;
037    private int threshold = 0;
038    
039    /** Creates a new instance of SimpleRichSequenceBuilderFactory */
040    public SimpleRichSequenceBuilderFactory() {
041      this(null, 0);
042    }
043
044    /** 
045     * Creates a new instance of SimpleRichSequenceBuilderFactory
046     * @param fact the factory to use when building the <code>SymbolList</code>.
047     */
048    public SimpleRichSequenceBuilderFactory(SymbolListFactory fact) {
049      this(fact, 0);
050    }
051    
052    /** 
053     * Creates a new instance of SimpleRichSequenceBuilderFactory that uses
054     * a specified factory for <code>SymbolLists</code> longer than a specified
055     * length. Before that a <code>SimpleSymbolListFacotry</code> is used.
056     * @param fact the factory to use when building the <code>SymbolList</code>.
057     * @param threshold the threshold to exceed before using this factory
058     */
059    public SimpleRichSequenceBuilderFactory(SymbolListFactory fact, int threshold) {
060      this.fact = fact;
061      this.threshold = threshold;
062    }
063    /**
064     * {@inheritDoc}
065     */
066    public SequenceBuilder makeSequenceBuilder() {
067        if(this.fact == null){
068            return new SimpleRichSequenceBuilder(); 
069        }else{
070            return new SimpleRichSequenceBuilder(this.fact, this.threshold);
071        }
072    }
073    
074}