001/*
002
003 *                    BioJava development code
004
005 *
006
007 * This code may be freely distributed and modified under the
008
009 * terms of the GNU Lesser General Public Licence.  This should
010
011 * be distributed with the code.  If you do not have a copy,
012
013 * see:
014
015 *
016
017 *      http://www.gnu.org/copyleft/lesser.html
018
019 *
020
021 * Copyright for this code is held jointly by the individual
022
023 * authors.  These should be listed in @author doc comments.
024
025 *
026
027 * For more information on the BioJava project and its aims,
028
029 * or to join the biojava-l mailing list, visit the home page
030
031 * at:
032
033 *
034
035 *      http://www.biojava.org/
036
037 *
038
039 */
040
041package org.biojava.bio.seq.io.agave;
042
043import java.util.ArrayList;
044import java.util.Iterator;
045import java.util.List;
046
047
048
049/**
050
051 * xrefs
052
053 *
054
055 * @author Hanning Ni    Doubletwist Inc
056  * @author Greg Cox
057
058*/
059
060public class  AGAVEXrefs{
061
062     private List db_ids ;
063
064     private List xrefs ;
065
066     /** add @param id **/
067
068     public void addDbId(AGAVEDbId id)
069
070     {
071
072         if( db_ids == null )
073
074             db_ids =  new ArrayList(1) ;
075
076         db_ids .add( id ) ;
077
078     }
079
080     /** add @param xref **/
081
082     public void addXref(AGAVEXref xref)
083
084     {
085
086         if( xrefs == null )
087
088             xrefs = new ArrayList(1) ;
089
090         xrefs.add( xref ) ;
091
092     }
093
094     /** return a set of DbId **/
095
096     public Iterator getDbIds()
097
098     {
099
100         return db_ids.iterator() ;
101
102     }
103
104     /** return a set of AGAVEXref **/
105
106     public Iterator getXrefs()
107
108     {
109
110         return xrefs.iterator() ;
111
112     }
113
114     /**
115
116      * @param indent  the leading space
117
118      *  @param indent_unit the unit of indenting for xml format
119
120      *
121
122      **/
123
124     public String toString(String indent, String indent_unit)
125
126     {
127
128       StringBuffer tmp = new StringBuffer();
129
130       tmp.append(indent +  "<xrefs>" + "\n" );
131
132       Iterator it = db_ids.iterator() ;
133
134       while( it.hasNext() )
135
136       {
137
138           tmp.append( ((AGAVEDbId)it.next()).toString(indent + indent_unit, indent_unit) ) ;
139
140       }
141
142       it = xrefs.iterator() ;
143
144       while( it.hasNext() )
145
146       {
147
148           tmp.append( ((AGAVEXref)it.next()).toString(indent + indent_unit, indent_unit) ) ;
149
150       }
151
152       tmp.append(indent + "</xrefs>" + "\n" );
153
154       return tmp.substring(0) ;
155
156     }
157
158     /** the agave xml representation of xrefs **/
159
160     public String toString()
161
162     {
163
164       StringBuffer tmp = new StringBuffer();
165
166       tmp.append( "<xrefs>" + "\n" );
167
168       Iterator it = db_ids.iterator() ;
169
170       while( it.hasNext() )
171
172       {
173
174           tmp.append(it.next().toString() ) ;
175
176       }
177
178       it = xrefs.iterator() ;
179
180       while( it.hasNext() )
181
182       {
183
184           tmp.append(it.next().toString() ) ;
185
186       }
187
188       tmp.append("</xrefs>" + "\n" );
189
190       return tmp.substring(0) ;
191
192     }
193
194}
195